1

i have found this but really don't understand what to do in step 1. Could anybody advise me. Or is there a better way to get this done.

Step1: You can get review Collection by below code:

$Collection=Mage::getModel('review/review')->getCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->addRateVotes()
                ->setDateOrder();

Step2: Create a Cms page from admin>Cms>Page> and at Design tab and put this code

<reference name="content">
<block type="core/template" name="review.form" template="catalog/allreview.phtml"/>
</reference>   

Step3: create allreview.phtml on app/design/frontend/your package/your template/templete/catalog/ and put below this phtml file you can put review details by below code:

<?php
    $_items = array_reverse( $Collection->getItems());

    foreach ($_items as $_review):
        $productId =  $_review->getentity_pk_value();
         $_review->getTitle();
         $_votes = $_review->getRatingVotes();
         $_review->getDetail()
          $this->formatDate($_review->getCreatedAt()) ?>
              $this->__('[Posted %s]', $this->formatDate($_review->getCreatedAt()), 'long');

    endforeach;
?>

1 Answer 1

1

Without using a module you could just put step one with step three in your catalog/allreview.phtml.

<?php
$Collection=Mage::getModel('review/review')->getCollection()
            ->setPageSize(1)
            ->addStoreFilter(Mage::app()->getStore()->getId())
            ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
            ->addRateVotes()
            ->setDateOrder();
$collection->getSelect()->limit(1);         
$_items = array_reverse( $Collection->getItems());
foreach ($_items as $_review):
    $productId =  $_review->getentity_pk_value();
     $_review->getTitle();
     $_votes = $_review->getRatingVotes();
     $_review->getDetail();
     $this->formatDate($_review->getCreatedAt());
     $this->__('[Posted %s]', $this->formatDate($_review->getCreatedAt()), 'long');
     echo "<ul><h3>". $_review->getTitle()."</h3>";
     echo "<li>".$_review->getDetail()."</li>";
     echo "<li>". $this->formatDate($_review->getCreatedAt())."</li>";
endforeach;
?>

This can then be called within CMS page by adding below to content:

{block type="core/template" name="all_reviews" template="catalog/allreview.phtml"}}

Or below to custom layout xml:

<reference name="content">
    <block type="core/template" name="all.reviews" alias="reviews" template="catalog/allreview.phtml">
    </block>
</reference>

It is normally recommended however to use a module for the collection and then call the collection from within the phtml file in your theme.

12
  • thanks but it does nothing. i created reviews.phtml and put that in /app/design/frontend/ultimo/default/template/catalog
    – bramvds
    Jun 11, 2017 at 17:37
  • Add this to your content in the CMS page instead of doing the layout:{{block type="core/template" name="all_reviews" template="catalog/reviews.phtml"}}</div>
    – harri
    Jun 11, 2017 at 17:40
  • i added: 1. {{block type="core/template" name="all_reviews" template="catalog/allreview.phtml"}} to the content of the page 2. added the code in allreview.phtml in app/design/frontend/ultimo/default/template/catalog still nothing, even not the content heading title. marktbay.nl/test
    – bramvds
    Jun 11, 2017 at 17:57
  • So you have flushed cache in between doing these steps?
    – harri
    Jun 11, 2017 at 18:01
  • Strange how these is no footer within this page also.
    – harri
    Jun 11, 2017 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.