我想在可配置产品的页面上显示简单产品的评论。
有人能帮上忙吗?
致以问候!
发布于 2014-07-10 05:53:27
下面的代码将显示可配置产品和简单产品的评分和评论。请注意,您还应该修改产品页面顶部的摘要,该摘要显示审查计数和总体平均评分。
将/app/code/core/Mage/Review/Block/Product/View.php从核心复制到本地,并进行修改。第75行是:
$this->_reviewsCollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addEntityFilter('product', $this->getProduct()->getId())
->setDateOrder();将其更改为:
if ($this->getProduct()->isConfigurable()){
//Get both configurable product and associated simple product reviews
$children_ids = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($this->getProduct()->getId());
$entity_ids = array($this->getProduct()->getId(), $children_ids);
$this->_reviewsCollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addFieldToFilter('entity_pk_value', array('in' => $entity_ids))
->setDateOrder();
} else {
$this->_reviewsCollection = Mage::getModel('review/review')->getCollection()
->addStoreFilter(Mage::app()->getStore()->getId())
->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
->addEntityFilter('product', $this->getProduct()->getId())
->setDateOrder();
}https://stackoverflow.com/questions/11287964
复制相似问题