gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:10:48 25 4
gpt4 key购买 nike

是否可以创建两个模块来扩展相同的核心模型,如 Mage_Customer_Model_Customer

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

最佳答案

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

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')

关于php - Magento:两个模块可以扩展相同的核心模型吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5342120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com