Php 在Magento中配置扩展模块
我试图在Magento中扩展客户模块,但运气不太好 我有: 将MyModule_Customer.xml添加到etc/modules目录,并使用正确的名称和路径进行设置。 创建了一个MyModule/Customer/etc/config.xml 创建了一个MyModule/Customer/Model/Customer.php(从Core/Customer复制)。我在我的新类中添加了一个Mage::log,但它从不记录任何内容 有些事情我不确定。 php类声明是否扩展了Mage_Customer_Model_Customer类或Mage_Core_Model_抽象类。我在网上读到的并不一致 这是MyModule/etc/config.xml中重写部分的正确格式吗? MyModule\u客户\u型号\u客户 .... 还是应该有另一个元素在内部?我尝试在路径周围添加,但这完全阻止了Magento的工作 编辑: 本地/MyModule/Customer/etc/config.xml 这实际上是Mage/Customer config.xml的副本,其中重新定义了模块并添加了重写部分Php 在Magento中配置扩展模块,php,magento,Php,Magento,我试图在Magento中扩展客户模块,但运气不太好 我有: 将MyModule_Customer.xml添加到etc/modules目录,并使用正确的名称和路径进行设置。 创建了一个MyModule/Customer/etc/config.xml 创建了一个MyModule/Customer/Model/Customer.php(从Core/Customer复制)。我在我的新类中添加了一个Mage::log,但它从不记录任何内容 有些事情我不确定。 php类声明是否扩展了Mage_Custome
<pre>
global>
models>
customer>
rewrite>
customer>
MyModule_Customer_Model_Customer
/customer>
/rewrite>
/customer>
/models>
/global>
</pre>
所以,这就是一切。我在网上阅读的教程建议这应该是微不足道的,那么我做错了什么呢?
任何帮助都将不胜感激。谢谢。您不应该将自己的模块命名为与原始模块相同的名称,在本例中为“客户”。它可以工作,但很混乱。适用于Magento和其他可能处理您的代码的开发人员 当覆盖客户模型时,您需要扩展Mage_Customer_model_Customer。在这种情况下,您只需将该方法放置在要重写的类中。 不需要复制完整的父类
请添加完整的config.xml:)我终于找到了解决方案。在扩展类中,使用require_一次引用核心类。例如,require_once('Mage/Customer/Model/Customer.php') 请发布您的完整代码我认为您应该在config.xml
MyModule\u Customer\u model\u Customer
中覆盖核心模型,谢谢您,Alek,这是答案的一部分,但我发现我缺少的实际行是通过:require\u一次包含核心php文件('Mage/Customer/Model/Customer.php')。然后一切开始工作。
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MyModule_Customer>
<active>true</active>
<codePool>local</codePool>
<depends>
Mage_Customer
</depends>
</MyModule_Customer>
</modules>
</config>
class MyModule_Customer_Model_Customer extends Mage_Customer_Model_Customer