我想重写块文件:/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php,下面是我的步骤,但它不起作用:
ScreentShot:http://imm.io/J36p
代码:http://www.heypasteit.com/clip/0JJ8
谁知道问题是什么?
答案 0 :(得分:2)
在链接代码(后面的后代)中,路径为global/blocks/catalog/rewrite/Product_View_Options_Select
应该
global/blocks/catalog/rewrite/product_view_options_select
,因为块类在布局XML文件中使用小写指定(例如。https://github.com/benmarks/magento-mirror/blob/1.7.0.2/app/design/frontend/base/default/layout/catalog.xml#L228)。
/app/code/local/Lbb/Catalog/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Lbb_Catalog>
<version>0.1.0</version>
</Lbb_Catalog>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<product_view_options_type_select>Lbb_Catalog_Block_Product_View_Options_Type_Select</product_view_options_type_select>
</rewrite>
</catalog>
</blocks>
</global>
</config>
答案 1 :(得分:0)
我从一个工作示例中获取此代码,因此它应该可以正常工作
/app/code/local/RWS/CustomOptions/Options/Type/Select.php
<?php
class RWS_CustomOptions_Options_Type_Select extends Mage_Catalog_Block_Product_View_Options_Abstract
{
public function getValuesHtml()
{
.....
/app/code/local/RWS/CustomOptions/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<RWS_CustomOptions>
<version>0.1.0</version>
</RWS_CustomOptions>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<product_view_options_type_select>RWS_CustomOptions_Options_Type_Select</product_view_options_type_select>
</rewrite>
</catalog>
</blocks>
</global>
</config>
/app/etc/modules/RWS_CustomOptions.xml
<?xml version="1.0"?>
<config>
<modules>
<RWS_CustomOptions>
<active>true</active>
<codePool>local</codePool>
</RWS_CustomOptions>
</modules>
<config>
要测试,请在magento admin中添加一个(简单)产品,并使用自定义选择选项go go product detail / view page。