cancel
Showing results for 
Search instead for 
Did you mean: 

Product Review on Homepage

Product Review on Homepage

How can I display a product review on the homepage? I have a single product store and want to display all the reviews on the homepage as well.

 

Magento 1.9

Tags (2)
3 REPLIES

Re: Product Review on Homepage

There is no trick for you to do this out of the box, but you can achieve it easily with the following snippet (simple version):

1. Create class Yourvendor_Yourmodule_Block_Review with the following content:

<?php
class Yourvendor_Yourmodule_Block_Review extends Mage_Core_Block_Template 
{
    public function getReviewCollection() { 
        $collection = Mage::getModel('review/review')
            ->getCollection()
            ->addStoreFilter(Mage::app()->getStore()->getId()) 
            ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
            ->addEntityFilter('product', $this->getProductId())
            ->setDateOrder('desc');

        return $collection;
    }
}

2. Create template file with following content:

<?php $_collection = $this->getReviewCollection(); ?>
<ul>
<?php foreach ($_collection as $_review): ?>
<li>
    <?php echo $this->escapeHtml($_review->getTitle()); ?>
    <?php echo $this->escapeHtml($_review->getNickname()); ?>
    <?php echo $this->escapeHtml($_review->getDetail()); ?>
</li>
<?php endforeach; ?>
</ul>

3. Put following code into CMS page which represents your homepage content:

{{block type="yourvendor_yourmodule/review" template="namespace/module/review.phtml" product_id="XXX"}}

If you're not developer, this will not going to be easy piece for you.

 

 

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue

Re: Product Review on Homepage

Where/how do I create a class? Yourvendor_Yourmodule_Block_Review

What is "Yourvendor_Yourmodule" ?

I understand steps 2 and 3.

Thank you.

Re: Product Review on Homepage

This is not supposed to be done by Merchant, you have to be developer. There is good and really affordable Magento 1 tutorial on https://code.tutsplus.com/courses/magento-fundamentals.

 

In this case, you should add that block into app/code/local/Yourvendor/Yourmodule/Block/Review.php.

 

Also, you need config.xml for this module in app/code/local/Yourvendor/Yourmodule/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Yourvendor_Yourmodule>
            <version>0.1.0</version>
        </Yourvendor_Yourmodule>
    </modules>
    <global>
        <blocks>
            <yourvendor_yourmodule>
                <class>Yourvendor_Yourmodule_Block</class>
            </yourvendor_yourmodule>
        </blocks>
    </global>
</config>

And you need modules XML in app/etc/modules/Yourvendor_Yourmodule.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Yourvendor_Yourmodule>
            <active>true</active>
            <codePool>local</codePool>
        </Yourvendor_Yourmodule>
    </modules>
</config> 

 

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue