I am creating a random list of products that refreshes every hour. I've got most of it done but there is one problem: getPriceHTML
is returning NULL
. This function is used in the normal category product lists and works perfectly there.
This code does give a correct getPriceHTML
$_productCollection = Mage::getModel('catalog/product')->getCollection();
But what I need is to get a random product, no matter what category it is in, so that is not an option.
The following code is the code I use to get random products:
$this->_productCollection = Mage::getResourceModel('catalog/product_collection');
Mage::getModel('catalog/layer')->prepareProductCollection($this->_productCollection);
$this->_productCollection->getSelect()->order('rand()');
$this->_productCollection->addStoreFilter();
$this->_productCollection->setPage(1, 3);
And later on:
foreach($this->_productCollection AS $_product)
{
echo $this->getPriceHtml($_product, true);
}
For simple products this does give the correct price, but it returns NULL
for grouped products. Yes, I am extending to Mage_Catalog_Block_Product
.
Please keep in mind that I know that there are other functions to get the price, but I specifically want to know why this isn't working as it should.
true
at that function, since it doesn't seem to be overridden in any way. Removing it still gives the same result too anyway.