Magento News
Magento – Loading root collection loads all products
Regarding using multiple stores, with different root categories:
I have 2 stores set up, with different roots. One has 14 products, the other 6.
If I use the following on my homepage (simply to show how many products are in the root category for that store – in this case with an ID of
I get 20 products – so all products in the store, from all roots:
$_testproductCollection = Mage::getModel('catalog/category')->load(8)
->getProductCollection()
->addAttributeToSelect('*')->load();
echo "NO. OF PRODUCTS IS ".$_testproductCollection->count();
However, if I change the ID to a sub-category, I get the correct amount of products. There are only 6 products in this root:

But the count shows 20 (as there’s 20 in the whole store – or both roots).
Anyone know what’s up? Is it a bug?
I also noticed that if you go to Manage Products and use the store view filter, it doesn’t do anything, still showing 20 products in the store view whose root has only 6 products:

Magento – Loading root collection loads all products
Possibly Related Posts:
- Database query different results
- Menu highlight in magento under admin
- magento disable a banner on certain category pages or have a banner with multiple links
- Magento, using ACL for frontend. Possible?
- Magento IE-7 Fix In Windows XP
RSS Feed