Magento – Using getPriceHtml on custom product collection doesn't return correct tax price

I have a product collection called using the following (set to show 6 items):

$_testproductCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->setPageSize(6);
$_testproductCollection->load();

then i get the 6 products details with a foreach:

foreach($_testproductCollection as $_testproduct){ 
    echo "Price is ".$this->htmlEscape($this->getPriceHtml($_product, true))."<br/>"; 
};

this works ok until I set my store to show prices inclusive of tax. Instead of showing 2 different prices, for example:

Excl. Tax: $138.56 
Incl. Tax: $149.99

it shows the same price for both. If I add a call to the loaded product collection again immediately after it’s loaded:

$_productCollection=$this->getLoadedProductCollection();

…it works fine, the prices are correct, but then it’s skipping the setPageSize function and returning the full store collection of products.

How can I get the correct tax prices to show, and what is it in the getLoadedProductCollection that corrects this? The function is in Mage/Catalog/Block/Product/List.php

One thought on “Magento – Using getPriceHtml on custom product collection doesn't return correct tax price”

Leave a Reply

Your email address will not be published. Required fields are marked *