37336792
37336792

Reputation: 493

Get all site product ID in magento

Now, i want to get all product ID of my site. IS there a simple way to get all product ID in my site of magento,

Upvotes: 1

Views: 6875

Answers (4)

Hassan Ali Shahzad
Hassan Ali Shahzad

Reputation: 2724

little variation If you All Product id from particular categories then:

    $category_ids = array(11,16); // your category ids
            $productIds = array();

            foreach($category_ids as $category_id){
                $category = Mage::getModel('catalog/category')->load($category_id);
                $result = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category)->getAllIds();
                $productIds = array_merge($productIds,$result);
            }
var_dump($productIds);

Upvotes: 0

Aleksey Razbakov
Aleksey Razbakov

Reputation: 634

To save resources it is better to use:

Mage::getModel('catalog/product')->getCollection()->getAllIds();

Upvotes: 6

Krista K
Krista K

Reputation: 21851

Or if you have access to command line, run mysql -u your_username -p magento_database and then you can run this query: SELECT entity_id, sku FROM catalog_product_entity; don't forget that you might need something like LIMIT 0,30 or WHERE sku LIKE '%shirt%'. You can get to this via the command line or from phpmyadmin (if available). phpmyadmin has a query window in it somewhere.

I normally do sneaky things in Magento by creating php scripts in the var/export/ folder. Then you do not need to worry about how to interact with the Magento/Zend/MVC framework.

Upvotes: 0

Alana Storm
Alana Storm

Reputation: 166076

foreach(Mage::getModel('catalog/product')->getCollection() as $product)
{
    var_dump($product->getId());
}

Upvotes: 1

Related Questions