我正在尝试覆盖 getSelectionQtyTitlePrice 方法我创建了一个文件 My_Bundle.xml
<?xml version="1.0" ?>
<config>
<modules>
<My_Bundle>
<active>true</active>
<codePool>local</codePool>
</My_Bundle>
</modules>
</config>
在 PA -> System->Advanced 模块存在并在 app/code/local/My/Bundle/Block/Catalog/Product/View/Type/Bundle 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 .= ' ' . ($includeContainer ? '<span class="price-notice">' : '')
. '' . $this->formatPriceString($price, $includeContainer)
. ($includeContainer ? '</span>' : '');
return $priceTitle;
}
}
在 app/code/local/My/Bundle/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 方法。谢谢帮助