无法检索实体配置

ton*_*9uk 1 config magento

我正在创建一个模块(我的第一个模块,没有教程)并且收到了错误

'无法检索实体配置'

在环顾各种网站并尝试不同的选择后,我停下来了.我假设完整的消息:

Error in file: "/Users/myname/Sites/magentotest/app/code/local/Ps/Pref/sql/pref_setup/mysql4-install-0.1.0.php" - Can't retrieve entity config: pref/prefNewsSignUp
Run Code Online (Sandbox Code Playgroud)

问题出在我的config.xml上,我需要在某个地方添加一个实体节点,其中包含与mysql4有关的内容.....但我需要添加的内容以及我需要放在该节点中的内容仍然是一个谜我此刻 我的配置文件是

<global>
    <model>
        <pref>
            <class>Ps_Pref_Models</class>
        </pref>
    </model>

    <resources>
        <pref_setup>
            <setup>
                <module>Ps_Pref</module>
                <class>Ps_Pref_Models_Resource_Setup</class>
            </setup>
        </pref_setup>
    </resources>
</global>
Run Code Online (Sandbox Code Playgroud)

============================== 编辑 =================== =============

我现在回到教程阶段,试着去理解我哪里出错了.这个Alan Storm教程 看起来非常类似于我的目标,但我仍然遇到了"无法检索实体配置"的相同问题(我已经完成了所有我的配置和var_dumped在IndexController中的各种选项,但是无法获得传递了这个问题,这对我没有任何意义)我留下了一些我认为有用的var_dump以及它们返回的内容(我希望这个编辑不会太混乱)

文件结构

+诗

- + Prefcentre

- +型号

--- + Mysql4

---- Preferences.php

--- Preferences.php

- +控制器

--- IndexController.php

- +等

--- config.xml中

PS/Prefcentre /型号/ Mysql4 /首选项

class Ps_Prefcentre_Model_Mysql4_Preferences
extends Mage_Core_Model_Mysql4_Abstract
{
protected function _construct()
{
    $this->_init('prefcentre/preferences', 'prefcentre_id');
}
}
Run Code Online (Sandbox Code Playgroud)

PS/Prefcentre /型号/首选项

class Ps_Prefcentre_Model_Preferences
extends Mage_Core_Model_Abstract
{
protected function _construct()
{
    $this->_init('prefcentre/preferences');
}
}
Run Code Online (Sandbox Code Playgroud)

PS/Prefcentre /索引控制器

class Ps_Prefcentre_IndexController
extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
    $params = $this->getRequest()->getParams();
    $prefs = Mage::getModel('prefcentre/preferences');
    echo ("Loading the blogpost with an Id of " . $params['id']);
    $prefs->load($params['id']);//returns "Can't retrieve entity config"
//        $prefs->getData('title');//returns array(0)
    $data = $prefs->getData();
    var_dump($data);

//        $pref = Mage::getModel('prefcentre/preferences');
//        echo get_class($pref);//returns Ps_Prefcentre_Model_Preferences
}
}
Run Code Online (Sandbox Code Playgroud)

PS/Prefcentre的/ etc/config.xml中

<config>
<global>
<!--....-->
    <models>
        <prefcentre>
            <class>Ps_Prefcentre_Model</class>
            <resourceModel>prefcentre_mysql4</resourceModel>
        </prefcentre>

        <prefcentre_mysql4>
            <class>Ps_Prefcentre_Model_Mysql4</class>
            <entities>
                <prefcentre>
                    <table>prefcentre</table>
                </prefcentre>
            </entities>
        </prefcentre_mysql4>  
    </models>
    <resources>
        <prefcentre_write>
            <connection>
                <use>core_write</use>
            </connection>
        </prefcentre_write>
        <prefcentre_read>
            <connection>
                <use>core_read</use>
            </connection>
        </prefcentre_read>
    </resources>
<!--....-->
</global>
</config>
Run Code Online (Sandbox Code Playgroud)

ben*_*rks 8

您缺少表名引用.在某处您使用句柄指定了一个表名pref/prefNewsSignUp,但您没有提供必要的xpath.你有资源模型节点吗?你有适当的xpath和文本吗?

<global>
    <model>
        <pref>
            <class>Ps_Pref_Models</class>
            <resourceModel>pref_resource</resourceModel>
        </pref>
        <pref_resource>
            <class>Ps_Pref_Models_Resource</class>
            <entities>
                <prefNewsSignUp><table>table_name</table></prefNewsSignUp>
            </entities>
        </pref_resource>
    </model>
Run Code Online (Sandbox Code Playgroud)