Reputation: 493
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
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
Reputation: 634
To save resources it is better to use:
Mage::getModel('catalog/product')->getCollection()->getAllIds();
Upvotes: 6
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
Reputation: 166076
foreach(Mage::getModel('catalog/product')->getCollection() as $product)
{
var_dump($product->getId());
}
Upvotes: 1