1

I'm listing all the reviews on a particular page of my magento store:

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

foreach($review_collection as $_review) {
    // ...
}

My question is how can I get the product of each review, something like this:

$product = $_review->getProduct();

So I can also list the product title and its URL so customers can click on the review to the particular product page.

Better yet, displaying the product cover photo as well so users can compare the product photo with the custom ones.

How can I do this?

1

1 Answer 1

0

Got it. Just get product ID of each review and then load its product like this:

$productId = $_review -> getEntityPkValue();
$product = Mage::getModel('catalog/product')
        ->setStoreId(Mage::app()->getStore()->getId())
        ->load($productId);

Your Answer

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

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