2012-06-20 77 views
0

我無法提供任何代碼,因爲這是問題的一部分,但我相信如果您指引我朝着正確的方向行事,我可以粘貼您告訴我的文件中的代碼。如何更改Magento中的產品評論的元標題

我在我的網站上啓用了產品評論: 但是,產品頁面標題和產品評論頁面標題相同,併爲我的搜索引擎優化工作提供了大量重複頁面。

例子: 正常頁面 http://www.theprinterdepo.com/hp-laser-p2015dn-printer-cb368a

相同的產品審查頁 http://www.theprinterdepo.com/review/product/list/id/1133/

什麼想法?

感謝

回答

2

,我不知道有任何功能了,它允許您指定產品評論網頁不同的標題框的。我可能是錯的,但?

所以,這留下了兩種方法可以用來實現這一點。

  1. 核心區塊覆蓋
  2. 事件/觀察員

我會選擇在這裏選擇2。即使有了這個選項,仍然有不同的方法來實現這一點。這裏是其中之一......

所以,一旦你創建你的模塊,你就需要聲明觀察者在你的config.xml:

<?xml version="1.0"?> 
<config> 

    <!-- other config xml --> 

    <frontend> 
     <events> 
      <controller_action_layout_render_before_review_product_list> 
       <observers> 
        <productmeta> 
         <class>YourCompany_YourModule_Model_Observer</class> 
         <method>controller_action_layout_render_before_review_product_list</method> 
        </productmeta> 
       </observers> 
      </controller_action_layout_render_before_review_product_list> 
     </events> 
    </frontend> 

    <!-- other config xml --> 

</config> 

那麼你的觀察員將與此類似。 ..

<?php 

class YourCompany_YourModule_Model_Observer 
{ 
    /** 
    * @pram Varien_Event_Observer $observer 
    * @return void 
    */ 
    public function controller_action_layout_render_before_review_product_list(Varien_Event_Observer $observer) 
    { 
     $title = "Your new page title"; 
     Mage::app()->getLayout()->getBlock('head')->setData('title', $title); 
    } 
}