自定义模型集合,错误:出于安全原因,默认情况下禁用

时间:2014-01-10 23:14:39

标签: magento-1.7

我已经使用他的集合创建了一个自定义模型但是当我尝试获取集合magento seys时:出于安全原因默认禁用。

$stores = Mage::getModel("training/animal")->getCollection();

$stores = Mage::getResourceModel("training/animal_collection");

首先我写的代码:

app/code/local/Trainig/Animal/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Training_Animal>
            <version>0.1.0</version>
        </Training_Animal>        
    </modules>
    <global>
        <models>
            <training>
                <class>Training_Animal_Model</class>
                <resourceModel>training_animal_resource</resourceModel>
            </training>
            <training_animal_resource>
                <class>Training_Animal_Model_Mysql4</class>
                <entities>
                    <animal>
                        <table>training_animal_entity</table>
                    </animal>
                </entities>
            </training_animal_resource>
        </models>
        <resources>
            <training_animal_setup>
                <setup>
                    <module>Training_Animal</module>
                    <class>Mage_Core_Model_Resource_Setup</class>
                </setup> 
                <connection>
                    <use>core_setup</use>
                </connection>
                <training_write>
                    <connection>
                        <use>core_write</use>
                    </connection>
                </training_write>
                <training_read>
                    <connection>
                        <use>core_read</use>
                    </connection>
                </training_read>                
            </training_animal_setup>
        </resources> 
    </global>
    <frontend>
        <routers>
            <training>
                <use>standard</use>
                <args>
                    <module>Training_Animal</module>
                    <frontName>traininganimal</frontName>
                </args>
            </training>
        </routers>
    </frontend>
</config>

应用程序/代码/本地/训练/动物/型号/ Animal.php

class Training_Animal_Model_Animal extends Mage_Core_Model_Abstract{
    public function _construct() {
        parent::_construct();
        $this->_init("training/animal");
    }
}

应用程序/代码/本地/训练/动物/型号/ Mysql4 / Animal.php

class Training_Animal_Model_Mysql4_Animal extends Mage_Core_Model_Abstract{
    public function _construct() {
        $this->_init("training/animal", "entity_id");
    }
}

AAP /代码/本地/训练/动物/型号/ Mysql4 /动物/ Collection.php

class Training_Animal_Model_Mysql4_Animal_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract{
        public function _construct() {
            $this->_init("training/animal");
        }
    }

有人知道我的错误在哪里?

1 个答案:

答案 0 :(得分:1)

我想你应该写一下                  法师:: getModel( “训练/动物”) - &GT; getCollection();作为Mage :: getModel(“模块名称/模块名称”)