加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – Magento:两个模块可以扩展相同的核心模型吗?

发布时间:2020-12-13 17:06:26 所属栏目:PHP教程 来源:网络整理
导读:是否可以创建两个扩展相同核心模型的模块,如Mage_Customer_Model_Customer? 当我访问(重载)核心模型时,我会收到什么? 解决方法 您可以跨自定义模型扩展Model类: class Namespace_Module_Model_Customer1 extends Mage_Customer_Model_Customer 在app / co
是否可以创建两个扩展相同核心模型的模块,如Mage_Customer_Model_Customer?

当我访问(重载)核心模型时,我会收到什么?

解决方法

您可以跨自定义模型扩展Model类:

class Namespace_Module_Model_Customer1 extends Mage_Customer_Model_Customer

在app / code / local / Namespace / Customer / Model / Customer1.php中定义,并且:

class Namespace_Module_Model_Customer2 extends Mage_Customer_Model_Customer

在app / code / local / Namespace / Customer / Model / Customer2.php中定义.

应该没问题 – 你必须在调用它时指定你想要的模型:

Mage::getModel('namespace/customer1')->method()

要么

Mage::getModel('namespace/customer2')->method()

核心模型将保持不变:

Mage::getModel('customer/customer')

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读