Magento Forum

   
Getting Specific Store Products
 
geoz
Jr. Member
 
Total Posts:  10
Joined:  2008-12-12
 

Hi I am trying to get the products from my magento store in a small external app. It is a multi-store site and I’m using the following basic code ..

require_once 'app/Mage.php';
    
Mage::app('default');

   
$products Mage::getModel('catalog/product')->getCollection();
   
$products->addAttributeToFilter('status'1);//enabled
   
$products->addAttributeToFilter('visibility'4);//catalog, search
   
$products->addAttributeToSelect('*');
   
$prodIds=$products->getAllIds();
                
    
$product Mage::getModel('catalog/product');
        
    foreach(
$prodIds as $productId{
                       
...... do stuff
   }

However I want to restrict the products to only those visible in a specific store - In particular I want the prices, currency and image urls to be consistant with a selected store. what do I need to do to achieve that?

Any help appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

Just a wild guess, but maybe addStoreFilter() helps: http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection.html#addStoreFilter

 
Magento Community Magento Community
Magento Community
Magento Community
 
geoz
Jr. Member
 
Total Posts:  10
Joined:  2008-12-12
 

I tried addStoreFilter($storeId), but did’nt change the store context, urls still pointed to default store. Finally found something that worked for me. Before getting products ...

Mage::app()->setCurrentStore($storeId);

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top