Reputation: 1963
I have added 2 stores into magento admin Canada and Australia
now I want to get store wise product collection
Currently getting Product collection in mangeto admin controller using
$collection = Mage::getModel('catalog/product')->getCollection();
using this I am getting all the products i tried this
$collection->setStoreId(2); // here 2 is the store id
but not much luck :( is there I am missing something? I extended class Mage_Adminhtml_Controller_Action
Upvotes: 2
Views: 5970
Reputation: 900
get active store id :- $storeId =Mage::app()->getStore()->getStoreId();
you can use below code may be help you
$collection->setStoreId($storeId)
$collection->addStoreFilter($storeId)
Upvotes: 3
Reputation: 1293
Please try this -
Filter Current Store Products -
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addStoreFilter();
For more please follow this - Product Collection in Magento
-
Thanks
Upvotes: 1