tags:

views:

82

answers:

2

Hi All

I have a custom page as my magento homepage. It's content is hardcoded on the default CMS page (which shows if a CMS homepage isn't enabled in the CMS pages section of the admin).

I have a list of products showing there (pulled from best-selling/highest rated etc). However, the review links and the add-to-compare links don't show on this page. The list of products is displayed using the same code as the default template/catalog/product/list.phtml, and everything else works except for these 2 things.

It seems that both the following code snippets have no effect on pages other than the default category listing page:

<?php $_compareUrl=$this->getAddToCompareUrl($_product); ?>

&

<?php echo $this->getReviewsUrl() ?>

I'm guessing that there's something else that needs to be called in order for these to work, but can't figure out what it is. Everything else from the product collection is available.

I load my product collection using the following code:

$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', $visibility)
$_productCollection->load(); 

Any ideas?

A: 

I'm guessing it's because the Block that is serving up your product list may not be correct. I believe it should be Mage_Catalog_Block_Catalog_Product_List. How exactly are you loading in the list of products?

Prattski
Added the code I use to my original question above.
Sam
That's your problem then. You are missing out on all the functionality provided by the product blocks (information that doesn't just come straight out of the database). If you were using a CMS page, you could add a product listing by putting something in like:{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}But, if it's a template, I don't know off the top of my head, but you need to utilize the functionality of the product blocks, not just a collection of product data straight from the database.
Prattski
A: 

OK, so after a while digging around, I found that you can use the following to get the compare url working:

<?php $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ?>
<span class="addto">
    <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
</span>

Still not sure about the review urls, but I've made an acceptable workaround for that so I'm gonna mark this as answered.

If anyone comes up with an answer though please do still post it!

Sam