Magento - addStoreFilter not working?

前端 未结 4 2081
灰色年华
灰色年华 2020-12-18 09:10

When getting a product collection in Magento, I would expect the StoreFilter to do just that, filter by the current store. But I can\'t get it to work.

Say I have 2

4条回答
  •  醉梦人生
    2020-12-18 09:28

    This worked for me:

    Mage::app()->setCurrentStore($storeId); 
    $productCollection = Mage::getModel('catalog/product')
                ->getCollection()
                ->addStoreFilter()
                ->addAttributeToSelect(array('sku','price'));
    

提交回复
热议问题