我正在尝试扩展Magento中的Customer模块,但运气不佳。
我已经:将MyModule_Customer.xml添加到etc / modules目录,并使用正确的名称和路径进行设置。创建一个MyModule / Customer / etc / config.xml创建一个MyModule / Customer / Model / Customer.php(从Core / Customer复制)。我在新类中添加了Mage :: log,但从未记录任何内容。
有些事情我不确定。我的Customer.php类声明是否扩展了Mage_Customer_Model_Customer类或Mage_Core_Model_Abstract类。我在网上阅读的内容不一致。
这是MyModule / etc / config.xml中重写部分的正确格式吗?MyModule_Customer_Model_Customer ....还是应该在其中另一个元素?我尝试添加路径,但这使Magento完全停止工作。
编辑:local / MyModule / Customer / etc / config.xml这实际上是Mage / Customer config.xml的副本,其中模块已重新定义,并且添加了重写部分
<pre>
global>
models>
customer>
rewrite>
customer>
MyModule_Customer_Model_Customer
/customer>
/rewrite>
/customer>
/models>
/global>
</pre>
但这导致Magento破裂,什么也不显示。我目前的最佳猜测如上所述,但删除了最内部的客户元素。
编辑2:这是所有代码app / etc / modules / MyModule_Customer.xml
<?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>
关于这种格式的查询-我看到的大多数文章在这里都没有depends元素,但是尽管我应该尝试,但这样做已经足够了,这很有意义。但是,对吗?
我的本地/MyModule/Customer/Model/Customer.php声明:
class MyModule_Customer_Model_Customer extends Mage_Customer_Model_Customer
所以,就是一切。我在网上阅读的教程建议这应该很简单,那么我在做什么错呢?任何帮助将非常感激。谢谢。
我终于找到了解决方案。在扩展类中,使用require_once引用核心类。例如require_once('Mage / Customer / Model / Customer.php');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句