重写的模型实体未执行

时间:2011-12-14 15:00:04

标签: php magento

我正在尝试覆盖客户的地址和客户模型实体。它在我的开发环境中工作,但我不能让它在生产中运行。他们都使用Magento 1.6.0.0。

我可能有两个方面出错:

  1. 我可能没有上传所有必需的文件,但不知道我错过了什么。我已经尝试过FTP整个模块目录,所以如果有其他文件,它们必须来自代码的另一部分。
  2. 数据库中缺少/不正确数据的数据。这似乎更有可能,但我不知道在哪里看(我通过PhpMyAdmin直接设置数据而不是使用Magento安装文件 - 这是一个自定义的Magento项目,所以不需要在其他任何地方重现/复制它未来。)
  3. 无论如何,这就是我所拥有的,以防我在代码级别做错了。

    覆盖

    class Zac_Attack_Model_Entity_Address extends Mage_Customer_Model_Entity_Address
    {
        protected function _afterSave( Varien_Object $address )
        {
            // this method never gets called.
        }
    }
    
    class Zac_Attack_Model_Entity_Customer extends Mage_Customer_Model_Entity_Customer
    {
        protected function _saveAddresses( Varien_Object $address )
        {
            // this method never gets called.
        }
    }
    

    config.xml中

    <models>
        <customer_entity>
            <rewrite>
                <address>Zac_Attack_Model_Entity_Address</address>
                <customer>Zac_Attack_Model_Entity_Customer</customer>
            </rewrite>
        </customer_entity>
    </models>
    

    覆盖是为了我们可以将第三种类型的主地址添加到客户地址。在数据库中为新地址正确设置了属性 - 如果我手动将地址设置为'default_custom'地址,它将显示在前端和后端的客户详细信息中,但没有模型实体,系统赢了'输入地址。如果我没有找到我所缺少的东西,我总是可以将逻辑移动到各种“保存”功能,但我更愿意继续采用Magento核心代码已经采用的方法。

    我在这里做错了什么想法?

2 个答案:

答案 0 :(得分:0)

您是否在app/etc/modules/*添加了配置文件?

该配置文件是否包含<enabled/>节点,其值为true

该配置文件是否包含正确代码池的名称? (社区或当地人)。

您的模块名称是否显示在模块的高级 - 禁用输出列表中?您是否尝试使用Module List Module来调试它未显示的原因?

您是否尝试编写为您实例化模型实例的代码并检查您的类名是否已被使用

$model = Mage::getMode('foo/bar');
var_dump(get_class($model));

你确定你所覆盖的方法没有被调用吗?

是否有另一个模块重写了同一个类?

答案 1 :(得分:0)

config.xml不应该像:

<models>
    <customer>
        <rewrite>
            <entity_address>Zac_Attack_Model_Entity_Address</entity_address>
            <entity_customer>Zac_Attack_Model_Entity_Customer</entity_customer>
        </rewrite>
    </customer>
</models>