Search code examples
magentoblockproduct

Magento $this->getPriceHtml($_product, true) not showing


I'm not entirely sure why this is not working, and I've been stuck on it for hours.

I have a file called banners.phtml, which is created using the following layout update:

<block type="catalog/product" name="banners" template="page/html/banners.phtml">
<!-- there are further blocks in here, but aren't important --->
</block>

The type is catalog/product, and on the page I have a loop which feeds an SKU to each product Model load:

<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku', get_field('product_sku')); ?>

Then when I use:

<?php echo $this->getPriceHtml($_product, true) ?>

Nothing shows - it doesn't break the site, but nothing shows. I've seen it mentioned that the product block type needs to be loaded - but I thought that's what catalog/product was doing... Does anyone have any ideas?


Solution

  • I realised the reason was because my collection was full of grouped products only. Therefore I added

    ->addMinimalPrice() 
    

    to the collection query and it worked.