I'm trying to create the collection of latest 5 reviews from products with specific attribute (e.g. - brand
). Here is my current code that displays just latest 5 reviews:
<?php
$reviews = Mage::getModel('review/review')->getResourceCollection();
$reviews->addStoreFilter( Mage::app()->getStore()->getId() )
->addStatusFilter( Mage_Review_Model_Review::STATUS_APPROVED )
->setDateOrder()
->addRateVotes()
->setPageSize(5)
->setCurPage(1)
->load();
?>
<!-- Print reviews -->
<ol>
<?php
foreach($reviews as $review) {
$review_data = $review->getData();
$product = Mage::getModel('catalog/product')->load( $review_data['entity_pk_value'] );
?>
<li>
<h4>Review of: <?php echo $product->getName() ?></h4>
<p><?php echo $review_data['detail']; ?></p>
</li>
<?php
}
?>
</ol>
Is there any way to apply some filter to $reviews
collection so it'll contain just reviews from specific attribute name?
Thanks for help.
UPD: code that works: https://gist.github.com/dimsemenov/5845535