2012-06-07 2 views
0

Я следую this tutorial. Учебник не заполнен на 100% и оставляет пользователю возможность заполнить некоторые пробелы. Я в порядке с этим. Часть, которая ломается, составляет $collection = Mage::getModel('employee/employee')->getCollection();. Я предполагаю, что это потому, что я прошу Magento вызвать метод getCollection клиента, который мне нужно определить. Я просмотрел и не могу найти пример того, как создать файл коллекции.Новые функциональные возможности Magento

Может ли кто-нибудь указать мне на несколько примеров?

спасибо.

+0

У вас есть модель «Сотрудник»? – WojtekT

+0

Спасибо WojtekT. Мне не хватало эту часть из моего etc/config.xml. Я обновлю свой ответ, когда SO позволит мне. –

ответ

0

Thank you 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> 
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'); 
    } 
} 
Смежные вопросы