magento覆盖第三方块

时间:2016-01-04 11:22:48

标签: php magento

尝试覆盖名为info.php的块 班级名称

Epicor_Customerconnect_Block_Customer_Orders_Details_Info

创建了一个新模块,为etc / modules创建了xml。

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <DotNetIT_OrderInfo>
            <active>true</active>
            <codePool>local</codePool>           
        </DotNetIT_OrderInfo>
    </modules>
</config>

创建了config.xml

<?xml version="1.0"?>
<config>
<modules>
    <DotNetIT_OrderInfo>
        <version>0.0.1</version>
    </DotNetIT_OrderInfo>
</modules>
<global>
    <models>
        <OrderInfo>
            <class>
                DotNetIT_OrderInfo_Model
            </class>
        </OrderInfo>
    </models>       
    <blocks>
        <customerconnect>
            <rewrite>
                   <info>DotNetIT_OrderInfo_Block_Customer_Orders_Details_Info</info>
            </rewrite>
        </customerconnect>
        <OrderInfo>
            <class>DotNetIT_OrderInfo_Block</class>
        </OrderInfo>
    </blocks>
    <helpers>
        <DotNetIT_OrderInfo>
            <class>DotNetIT_OrderInfo_Helper</class>
        </DotNetIT_OrderInfo>          
    </helpers>
</global>

</config>

创建了具有相同文件夹结构的新块。还扩展了原始文件。

class DotNetIT_OrderInfo_Block_Customer_Orders_Details_Info extends Epicor_Customerconnect_Block_Customer_Orders_Details_Info {

在新块中,我创建一个var_dump来查看它是否使用了新块。但没有任何事情意味着它没有被使用

我还需要做什么?我覆盖了一切吗?或者我的配置重写不正确?

编辑:同样,我正在扩展的类已经扩展了另一个,

class Epicor_Customerconnect_Block_Customer_Orders_Details_Info extends Epicor_Customerconnect_Block_Customer_Info

Epicor_Customerconnect_Block_Customer_Info extends Mage_Core_Block_Template

1 个答案:

答案 0 :(得分:1)

这可能适合你。

应用\等\模块\ DotNetIT_OrderInfo.xml

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

应用\代码\本地\ DotNetIT \订单信息\等\ config.xml中

<?xml version="1.0"?>
<config>
  <modules>
    <DotNetIT_OrderInfo>
      <version>0.1.0</version>
    </DotNetIT_OrderInfo>
  </modules>
  <global>
    <helpers>
      <orderinfo>
        <class>DotNetIT_OrderInfo_Helper</class>
      </orderinfo>
    </helpers>
    <blocks>
      <orderinfo>
        <class>DotNetIT_OrderInfo_Block</class>
      </orderinfo>
            <customerconnect>
                <rewrite>
                    <customer_orders_details_info>DotNetIT_OrderInfo_Block_Customerconnect_Customer_Orders_Details_Info</customer_orders_details_info>
                </rewrite>
            </customerconnect>
    </blocks>
  </global>
</config> 

应用\代码\本地\ DotNetIT \订单信息\块\ Customerconnect \客户\订单\详细\ info.php的

<?php
class DotNetIT_OrderInfo_Block_Customerconnect_Customer_Orders_Details_Info extends Epicor_Customerconnect_Block_Customer_Orders_Details_Info
{
}