Rohan Patil
Rohan Patil

Reputation: 1963

Magento Get all Product Collection in Admin Controller by Store id's

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

Answers (2)

Vishal
Vishal

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

aforankur
aforankur

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

Related Questions