Magento中非EAV Model继承自Mage_Core_Model_Abstract,需要实现_construct方法
先通过model的tag找到model的resource model的定义标签, 再从resource model的定义标签中找到对应的resource model名字。
非EAV ResourceModel继承自Mage_Core_Model_Mysql4_Abstract, 里面也需要实现
另外在Setup类中有 $this->getTable('xxx');
这里的参数是<table>标签中的表名。
ResourceModel中也有一个getTable方法,里面的参数是entity name。
protected function _construct(){
$this->_init('Model tag 名/ResourceModel tag名');
}先通过model的tag找到model的resource model的定义标签, 再从resource model的定义标签中找到对应的resource model名字。
非EAV ResourceModel继承自Mage_Core_Model_Mysql4_Abstract, 里面也需要实现
protected function _construct(){
$this->_init('Model tag 名/ResourceModel tag名','表格主键列名');
}另外在Setup类中有 $this->getTable('xxx');
这里的参数是<table>标签中的表名。
ResourceModel中也有一个getTable方法,里面的参数是entity name。
本文介绍了Magento中非EAV模型及资源模型的构造方法。详细解释了如何通过构造函数初始化模型和资源模型,并指出了资源模型中getTable方法的使用方式。
4659

被折叠的 条评论
为什么被折叠?



