2

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.

1 Answer 1

4

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());
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.