新的Magento后端功能
我跟在后面。本教程并非100%完整,用户需要填补一些空白。我同意。中断的部分是$collection=Mage::getModel'employee/employee'->getCollection;。我假设这是因为我要求Magento调用我需要定义的customer getCollection方法。我看了一遍,似乎找不到如何创建集合文件的示例 有人能给我举几个例子吗新的Magento后端功能,magento,collections,module,adminhtml,Magento,Collections,Module,Adminhtml,我跟在后面。本教程并非100%完整,用户需要填补一些空白。我同意。中断的部分是$collection=Mage::getModel'employee/employee'->getCollection;。我假设这是因为我要求Magento调用我需要定义的customer getCollection方法。我看了一遍,似乎找不到如何创建集合文件的示例 有人能给我举几个例子吗 谢谢。谢谢你,沃伊特。我的etc/config.xml中缺少这一部分 1) file in **app\code\local\N
谢谢。谢谢你,沃伊特。我的etc/config.xml中缺少这一部分
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');
}
}
<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>
您是否定义了员工模型?谢谢WojtekT。我的etc/config.xml中缺少这一部分。如果允许,我会更新我的答案。