我正在关注this tutorial。本教程并非100%完成,让用户填补了一些空白。我很好。中断的部分是$collection = Mage::getModel('employee/employee')->getCollection();
。我假设这是因为我要求Magento调用我需要定义的客户getCollection方法。我已经查看了,似乎无法找到如何创建集合文件的示例。
有人能指出几个例子吗?
谢谢。
答案 0 :(得分:0)
1) file in **app\code\local\NCM\Employee\etc\config.xml**
<?xml version="1.0"?>
<config>
<modules>
<NCM_Employee>
<version>0.1.0</version>
</NCM_Employee>
</modules>
<frontend>
<routers>
<employee>
<use>standard</use>
<args>
<module>NCM_Employee</module>
<frontName>employee</frontName>
</args>
</employee>
</routers>
<layout>
<updates>
<employee>
<file>employee.xml</file>
</employee>
</updates>
</layout>
</frontend>
<admin>
<routers>
<employee>
<use>admin</use>
<args>
<module>NCM_Employee</module>
<frontName>employee</frontName>
</args>
</employee>
</routers>
</admin>
<adminhtml>
<menu>
<employee module="employee">
<title>Employee</title>
<sort_order>71</sort_order>
<children>
<items module="employee">
<title>Manage Items</title>
<sort_order>0</sort_order>
<action>employee/adminhtml_employee</action>
</items>
</children>
</employee>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<NCM_Employee>
<title>Employee Module</title>
<sort_order>10</sort_order>
</NCM_Employee>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<employee>
<file>employee.xml</file>
</employee>
</updates>
</layout>
</adminhtml>
<global>
<models>
<employee>
<class>NCM_Employee_Model</class>
<resourceModel>employee_mysql4</resourceModel>
</employee>
<employee_mysql4>
<class>NCM_Employee_Model_Mysql4</class>
<entities>
<employee>
<table>employee</table>
</employee>
</entities>
</employee_mysql4>
</models>
<resources>
<employee_setup>
<setup>
<module>NCM_Employee</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</employee_setup>
<employee_write>
<connection>
<use>core_write</use>
</connection>
</employee_write>
<employee_read>
<connection>
<use>core_read</use>
</connection>
</employee_read>
</resources>
<blocks>
<employee>
<class>NCM_Employee_Block</class>
</employee>
</blocks>
<helpers>
<employee>
<class>NCM_Employee_Helper</class>
</employee>
</helpers>
</global>
</config>
2) file in **app\code\local\NCM\Employee\Model\Employee.php**
class NCM_Employee_Model_Employee extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('employee/employee');
}
}
3) file in **app\code\local\NCM\Employee\Model\Mysql4\Employee.php**
class NCM_Employee_Model_Mysql4_Employee extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
$this->_init('employee/employee', 'employee_id');
}
}
4) file in **app\code\local\NCM\Employee\Model\Mysql4\Employee\Collection.php**
class NCM_Employee_Model_Mysql4_Employee_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('employee/employee');
}
}
答案 1 :(得分:0)
谢谢WojtekT。我从我的etc / config.xml
中遗漏了这篇文章 <models>
<categoryrules>
<class>Rogue_CategoryRules_Model</class>
<resourceModel>categoryrules_mysql4</resourceModel>
</categoryrules>
<categoryrules_mysql4>
<class>Rogue_CategoryRules_Model_Mysql4</class>
<entities>
<rules>
<table>rogue_category_rules</table>
</rules>
</entities>
</categoryrules_mysql4>
</models>