Created
February 6, 2017 12:12
-
-
Save meminuygur/51a30c664fe858d3db6befcbd6896f9b to your computer and use it in GitHub Desktop.
Magento1 Reviews List for a Category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$_category = // INITIALIZED CATEGORY etc Mage::registry('current_category') or Mage::getModel('catalog/category)->load(##CATID##); | |
$productCollection = Mage::getResourceModel('catalog/product_collection') | |
->addCategoryFilter($_category) | |
->getAllIds(); | |
$reviewcollection = Mage::getModel('review/review')->getCollection() | |
->addStoreFilter(Mage::app()->getStore()->getId()) | |
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED) | |
->addFieldToFilter('entity_id', Mage_Review_Model_Review::ENTITY_PRODUCT) | |
->addFieldToFilter('entity_pk_value', array('in' => $productCollection)) | |
->setDateOrder() | |
->addRateVotes(); | |
$items = $reviewcollection->getItems(); | |
?> | |
<?php if (count($items)):?> | |
<div class="box-collateral box-reviews" id="customer-reviews"> | |
<h2><?php echo $this->__('Customer Reviews') ?></h2> | |
<?php echo $this->getChildHtml('toolbar') ?> | |
<ol> | |
<?php foreach ($items as $_review):?> | |
<li> | |
<?php | |
$_product = Mage::getModel('catalog/product')->load($_review['entity_pk_value']); | |
$image_link = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(65,65); | |
?> | |
<div class="avatar-image" img="<?php echo $image_link; ?>"> | |
<?php /*<img src="<?php echo Mage::getDesign()->getSkinUrl("images/avatar.jpg"); ?>" width="65" height="65"/> */;?> | |
<a href="/<?php echo $_product->getUrlPath();?>"><img src="<?php echo $image_link;?>"></a> | |
</div> | |
<div class="review-area"> | |
<strong class="review-title"><?php echo $this->htmlEscape($_review->getTitle()) ?></strong> | |
<span class="review-by"> <?php echo $this->__('review by %s', "<b>".$this->htmlEscape($_review->getNickname())."</b>") ?> <?php echo $this->__('on %s', $this->formatDate($_review->getCreatedAt()), 'long') ?></span> | |
<div class="ratings-list"> | |
<?php foreach ($_review->getRatingVotes() as $_vote): ?> | |
<div class="rating-item"> | |
<span class="label"><?php echo $_vote->getRatingCode() ?></span> | |
<div class="rating-box"> | |
<div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div> | |
</div> | |
</div> | |
<?php endforeach; ?> | |
</div> | |
<p><?php echo nl2br($this->htmlEscape($_review->getDetail())) ?></p> | |
</div> | |
<div class="clearer"></div> | |
</li> | |
<?php endforeach; ?> | |
</ol> | |
</div> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment