Reputation: 2991
I am creating a module (my first one, without tutorials) and have received the error
'Can't retrieve entity config'
after looking around various sites and trying different options, i've come to a stop. I assume from the full message:
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
That the problem is with my config.xml and that I need to add an entity node somewhere containing something to do with mysql4.....but where I need to add that and what I need to put in that node remains a mystery to me at the moment. My config file is
<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>
==============================EDIT================================
I have now gone back to the tutorial stage to try and understand where I am going wrong. this Alan Storm tutorial seems very similar to what i'm aiming for, but I still come across the same problem of "Can't retrieve entity config" (I have gone through all my config and var_dumped various options in IndexController, but cant get passed the problem, and this is not making any sense to me) I have left a couple of the var_dumps that I think will be useful and what they have returned (I hope this edit isn't too confusing)
FOLDER STRUCTURE
+Ps
-+Prefcentre
--+Model
---+Mysql4
----Preferences.php
---Preferences.php
--+controllers
---IndexController.php
--+etc
---config.xml
Ps/Prefcentre/Model/Mysql4/Preferences
class Ps_Prefcentre_Model_Mysql4_Preferences
extends Mage_Core_Model_Mysql4_Abstract
{
protected function _construct()
{
$this->_init('prefcentre/preferences', 'prefcentre_id');
}
}
Ps/Prefcentre/Model/Preferences
class Ps_Prefcentre_Model_Preferences
extends Mage_Core_Model_Abstract
{
protected function _construct()
{
$this->_init('prefcentre/preferences');
}
}
Ps/Prefcentre/IndexController
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
}
}
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>
Upvotes: 1
Views: 15597
Reputation: 8159
I had similar issue, and my solution was to replace the code below:
public function indexAction()
{
$params = $this->getRequest()->getParams();
$prefs = Mage::getModel('prefcentre/preferences');
....
for
public function indexAction()
{
$params = $this->getRequest()->getParams();
$prefs = Mage::getModel('ps_prefcentre/preferences');
....
That is it, by adding the model prefix I got it sorted.
Upvotes: 2
Reputation: 23205
You are missing a table name reference. Somewhere you are specified a tablename using the handle pref/prefNewsSignUp
and you have not provided the necessary xpath. Do you have a resource model node? Do you have the appropriate xpath and text under it?
<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>
Upvotes: 8
Reputation: 2384
<model>
<pref>
<class>Ps_Pref_Models</class>
</pref>
</model>
Shouldn' t it be :
<models>
<pref>
<class>Ps_Pref_Model</class>
</pref>
</models>
Upvotes: 1