是否可以创建两个模块来扩展相同的核心模型,如 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/