【问题标题】:magento rewrite catalog block Product/View/Options/Type/Select.phpmagento 重写目录块 Product/View/Options/Type/Select.php
【发布时间】:2013-02-23 01:56:20
【问题描述】:

我想重写块文件:/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php,下面是我的步骤,但它不起作用:

截屏:http://imm.io/J36p

代码:http://www.heypasteit.com/clip/0JJ8

谁知道问题出在哪里?

【问题讨论】:

    标签: magento


    【解决方案1】:

    在链接代码中(下面为后代),路径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>  
    

    【讨论】:

      【解决方案2】:

      我从一个工作示例中获得此代码,所以它应该可以工作

      /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 product detail/view 页面。

      【讨论】:

      • @prashanthpadala ... 定义不工作是什么意思?类被重写了吗?
      猜你喜欢
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      • 2014-06-25
      • 2012-02-14
      • 1970-01-01
      相关资源
      最近更新 更多