【问题标题】:Magento - Review helperMagento - 审核助手
【发布时间】:2011-11-29 14:52:07
【问题描述】:

我正在尝试实例化审阅助手类但失败了.. 我需要访问 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”。

我做错了什么?

(p.s. 我不能使用 $this->getReviewsSummaryHtml 因为 $this 超出了范围。)

谢谢

【问题讨论】:

    标签: magento helpers review


    【解决方案1】:

    方法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 模板。

    【讨论】:

      【解决方案2】:

      你应该这样做:

      Mage::helper('review')
      

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

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

      如果您已将该函数移至 helper,则可以这样称呼它:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-10
        • 2011-04-24
        • 2015-03-29
        • 2016-10-08
        • 2012-07-08
        • 2018-11-28
        • 2016-03-08
        相关资源
        最近更新 更多