Magento 1.7 Product Collection – Wrong Price When Products Are Loaded from Collection

magento-1.7priceproduct-collection

I have a Magento site with several stores. Each store displays products in different currency. I'm trying to load products from one of the stores using product collection.

$_col = Mage::getModel('catalog/product')->getCollection();
$_col->addAttributeToSelect('*');
$_col->addIdFilter($product_ids_to_be_loaded);
$_col->setStoreId($store_id);
$_col->addFinalPrice();

Unfortunately when I try to 'display' the price using:

for($_col as $p) {
    echo $this->getPriceHtml($p, true);
}

it displays wrong price (I assume it's price in default currency).

When I load products using:

$model = Mage::getModel('catalog/product');
for($_col as $p) {
    $p = $model->load($_product->getId());
    echo $this->getPriceHtml($p, true);
}

it works fine. How come? What am I doing wrong?

Best Answer

I use the following which works well:

$collection = Mage::getResourceModel('catalog/product_collection');
$collection ->addMinimalPrice()
            ->addFinalPrice()
            ->addTaxPercents();

Try it without the store id filter, then with it.

Magento has also got the following method which can be used as filter:

public function addPriceData($customerGroupId = null, $websiteId = null)
Related Topic