2013-02-18 45 views
0

我嘗試重寫getSelectionQtyTitlePrice方法 我在賓夕法尼亞州創建了一個文件 My_Bundle.xml如何重寫方法getSelectionQtyTitlePrice

<?xml version="1.0" ?> 
<config> 
    <modules> 
     <My_Bundle> 
      <active>true</active> 
      <codePool>local</codePool> 
     </My_Bundle> 
    </modules> 
</config> 

- >系統 - >高級模塊存在,並在應用程序能夠 /代碼/地方/我/包/座/目錄/產品/瀏覽/類型/包 Option.php

class My_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option 
{ 
    public function getSelectionQtyTitlePrice($_selection, $includeContainer = false) 
    { 
     $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection); 
     $this->setFormatProduct($_selection); 
     $priceTitle = $_selection->getSelectionQty()*1 . ' x ' . $this->escapeHtml($_selection->getName()); 

     $priceTitle .= ' &nbsp; ' . ($includeContainer ? '<span class="price-notice">' : '') 
      . '' . $this->formatPriceString($price, $includeContainer) 
      . ($includeContainer ? '</span>' : ''); 

     return $priceTitle; 
    } 
} 

在app /代碼/地方/我/包的/ etc/config.xml中

<?xml version="1.0"?> 
<config> 
    <modules> 
     <My_Bundle> 
      <version>0.0.1</version> 
     </My_Bundle> 
    </modules> 

    <global> 
     <blocks> 
      <bundle> 
        <rewrite> 
         <catalog_product_view_type_bundle_option>My_Bundle_Block_Catalog_Product_View_Type_Bundle_Option</catalog_product_view_type_bundle_option> 
        </rewrite> 
      </bundle> 
     </blocks> 
    </global> 
</config> 

但該解決方案不重寫getSelectionQtyTitlePrice方法。 THX求助

回答

2

看看@http://www.magentocommerce.com/boards/viewthread/265060/#t357807

由於此塊從不實例,你應該重寫其 的子類,並把它們應用本地變更。

所以: config.xml中

<bundle> 
    <rewrite> 
     <catalog_product_view_type_bundle_option_select>Module_Block_Bundle_Option_Select</catalog_product_view_type_bundle_option_select> 
     <catalog_product_view_type_bundle_option_multi>Module_Block_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi> 
     <catalog_product_view_type_bundle_option_radio>Module_Block_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio> 
     <catalog_product_view_type_bundle_option_checkbox>Module_Block_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox> 
    </rewrite> 
</bundle>