I want to load a model called Repository in my code. The data is inserted correctly in db by model script, primary key is set to 'repository_id'. However, I am not able to read my data, so I might have a problem but I don't see where. Call :
$repos = Mage::getModel('Module/repository')->getCollection();
var_dump($repos); // bool false
$repos = Mage::getResourceModel('Module/repository_collection');
var_dump($repos); // bool false
$repos = Mage::getModel('Module/repository')->getResourceCollection(); // error Mage registry key "_resource_singleton/Module/repository" already exists
var_dump($repos);
app/code/local/Company/Module/Model/Mysql4/Resource/Repository/Collection.php
class Company_Module_Model_Resource_Repository_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
$this->_init('Module/repository');
}
}
app/code/local/Company/Module/Model/Mysql4/Resource/Repository.php
class Company_Module_Model_Resource_Repository extends Mage_Core_Model_Mysql4_Abstract
{
protected function _construct()
{
$this->_init('Module/repository', 'repository_id');
}
}
app/code/local/Company/Module/Model/Repository.php
class Company_Module_Model_Repository extends Mage_Core_Model_Abstract
{
public function _construct()
{
$this->_init('Module/repository');
}
}
app/code/local/Company/Module/etc/config.xml
<config>
<global>
<models>
<Module>
<class>Company_Module_Model</class>
<resourceModel>company_module_resource</resourceModel>
</Module>
<company_module_resource>
<class>Company_Module_Model_Resource</class>
<entities>
<repository>
<table>company_repository</table>
</repository>
</entities>
</company_module_resource>
</models>
</global>
</config>
Edit : I forgot to mention that i am on magento 1.4, thats why i use mysql4 ressources. Thanks