New Magento backend functionality
-
13-06-2021 - |
题
I'm following this tutorial. The tutorial isn't 100% complete and leaves the user to fill in some of the gaps. I'm fine with that. The part that breaks is $collection = Mage::getModel('employee/employee')->getCollection();
. I'm assuming this is because I'm asking Magento to call a customer getCollection method which I need to define. I've looked through and can't seem to find an example of how to create a collection file.
Can anyone point me to a few examples?
Thank you.
解决方案 2
Thank you WojtekT. I was missing this piece from my 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>
其他提示
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');
}
}
不隶属于 StackOverflow