Magento 1.9 – How to Get Product Price Filtered by Store

magento-1.9

I am trying to get product price according to store Id in Magento. I am using the below code :

$store_id=2;
$collection=Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name','image', 'price','special_price', 'special_packing','prosort','description','special_from_date','special_to_date'))
->addStoreFilter($store_id)
->addAttributeToSort('position');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

foreach($collection as $product){

$products = Mage::getModel('catalog/product')->load($product->getId());
print_r($products->getPrice());
}

But in return i get Default price, is there anything i am missing or doing wrong?

Any help appreciated.

Best Answer

Replace addStoreFilter to setStore . Try following way,

$store_id=2;
$collection=Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name','image', 'price','special_price', 'special_packing','prosort','description','special_from_date','special_to_date'))
    ->setStore($store_id)
    ->addAttributeToSort('position');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

foreach($collection as $product){

    $products = Mage::getModel('catalog/product')->load($product->getId());
    print_r($products->getPrice());
}
Related Topic