2

我正在尝试实例化审阅助手类,但失败了。我需要访问 Mage_Review_Block_Product_View 类的 getReviewsSummaryHtml()(app/code/code/Mage/Review/Block/Product/View.php)。

我试过这个:

Mage::helper('review/product')->getReviewsSummaryHtml($_product, false, true);

但我收到致命错误:找不到类'Mage_Review_Helper_Product'。

我究竟做错了什么?

(ps 我不能使用 $this->getReviewsSummaryHtml 因为 $this 超出范围。)

谢谢

4

2 回答 2

4

该方法getReviewsSummaryHtml()在 中定义Mage_Review_Block_Product_View。您可以在任何地方使用Mage::app()->getLayout()->createBlock('review/product_view',$product);. 但是,为了使其工作,您还需要有一个名为 的块实例product_review_list.count,它通常定义在 中review.xml,类型为core/template,并使用review/product/view/count.phtml模板。

于 2011-11-29T15:20:37.100 回答
1

你应该简单地做:

Mage::helper('review')

为了获得名为 Data.php 的助手类

函数 getReviewsSummaryHtml() 位于一个块中,您应该只能从模板中调用该函数(理想情况下)。

如果您已将该功能移至帮助程序,则可以这样称呼它:

Mage::helper('review')->getReviewsSummaryHtml();

您应该在本地进行所有这些更改。

于 2011-11-29T15:20:08.857 回答