2

I have been creating magento extension using MySql4 approach. Today I was trying with new approach (as I understand EAV approach). All working fine but cannot call model->collection at all. I have searched everywhere but no luck. Basically followed this link.

digitalcinema/chromeextension/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <DigitalCinema_ChromeExtension>
        <version>1.0.1</version>
    </DigitalCinema_ChromeExtension>
</modules>

<frontend>
    <routers>
        <chrome_extension>
            <use>standard</use>
            <args>
                <module>DigitalCinema_ChromeExtension</module>
                <frontName>chrome_extension</frontName>
            </args>
        </chrome_extension>
    </routers>

    <layout>
        <updates>
            <chrome_extension>
                <file>DigitalCinema_ChromeExtension.xml</file>
            </chrome_extension>
        </updates>
    </layout>
</frontend>

<global>
    <blocks>
        <chrome_extension>
            <class>DigitalCinema_ChromeExtension_Block</class>
        </chrome_extension>
    </blocks>

    <helpers>
        <chrome_extension>
            <class>DigitalCinema_ChromeExtension_Helper</class>
        </chrome_extension>
    </helpers>

    <models>
        <chrome_extension>
            <class>DigitalCinema_ChromeExtension_Model</class>
            <resourceModel>chrome_extension_resource</resourceModel>
        </chrome_extension>
        <chrome_extension_resource>
            <class>DigitalCinema_ChromeExtension_Model_Resource</class>
            <etities>
                <chromeextension>
                    <table>chrome_extension</table>
                </chromeextension>
            </etities>
        </chrome_extension_resource>
    </models>


    <resources>
        <chrome_extension_setup>
            <setup>
                 <module>DigitalCinema_ChromeExtension</module>
            </setup>
        </chrome_extension_setup>
    </resources>

</global>

<adminhtml>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <chrome_extension_options>
                                        <title>XML Generate for Chrome Extension</title>
                                    </chrome_extension_options>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</adminhtml>

<admin>
    <routers>
        <adminhtml>
            <use>admin</use>
            <args>
                <modules>
                    <chrome_extension before="Mage_Adminhtml">DigitalCinema_ChromeExtension_Adminhtml</chrome_extension>
                    <frontName>chrome_extension</frontName>
                </modules>
            </args> 
        </adminhtml>
    </routers>
</admin>

<crontab>
    <jobs>
        <chrome_extension>
            <schedule>
                <cron_expr>*/1 * * * *</cron_expr>
            </schedule>
            <run>
                <model>chrome_extension/observer::importProduct</model>
            </run>
        </chrome_extension>
    </jobs>
</crontab>
</config>

DigitalCinema/ChromeExtension/Model/Chromeextension.php

class DigitalCinema_ChromeExtension_Model_Chromeextension extends Mage_Core_Model_Abstract
{
    protected function _construct()
    {
        $this->_init('chrome_extension/chromeextension');
    }
}

DigitalCinema/ChromeExtension/Model/Resource/Chromeextension.php

class DigitalCinema_ChromeExtension_Model_Resource_Chromeextension extends Mage_Core_Model_Resource_Db_Abstract
{
    protected function _construct()
    {
        $this->_init('chrome_extension/chromeextension', 'chromeextension_id');
    }
}

DigitalCinema/ChromeExtension/Model/Resource/Chromeextension/Collection.php

class DigitalCinema_ChromeExtension_Model_Resource_Chromeextension_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
    public function _construct()
    {
        $this->_init('chrome_extension/chromeextension');
    }
}

DigitalCinema/ChromeExtension/sql/chrome_extension_setup/install-1.0.1.php

$installer = $this;

$installer->startSetup();

$table = $installer->getConnection()
    ->newTable($installer->getTable('chrome_extension'))
     //******** 
     //********I should use $installer->getTable('chrome_extension/chromeextension')) but this also gives me same error.
     //********
    ->addColumn('chromeextension_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity'  => true,
        'unsigned'  => true,
        'nullable'  => false,
        'primary'   => true,
        ), 'Id')
    ->addColumn('type', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
        'nullable'  => true,
        ), 'Type')
    ->addColumn('filename', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
        'nullable'  => true,
        ), 'File Name')
    ->addColumn('path', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
        'nullable'  => true,
        ), 'Path')
    ->addColumn('time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
        'nullable'  => true,
        ), 'Time')
    ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
        'nullable'  => false,
        ), 'Store ID')
    ->addIndex($installer->getIdxName('sitemap/sitemap', array('store_id')),
        array('store_id'))
    ->addForeignKey($installer->getFkName('chrome_extension', 'store_id', 'core/store', 'store_id'),
        'store_id', $installer->getTable('core/store'), 'store_id',
        Varien_Db_Ddl_Table::ACTION_CASCADE,
        Varien_Db_Ddl_Table::ACTION_CASCADE)
    ->setComment('XML For Chrome Extension');

$installer->getConnection()->createTable($table);

$installer->endSetup();

DigitalCinema/ChromeExtension/controllers/IndexController.php

class DigitalCinema_ChromeExtension_IndexController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {
        $t = Mage::getModel('chrome_extension/chromeextension');//->getCollection();

       $d = $t->getCollection();
       var_dump($d);
       echo get_class($t);

    }
}

DigitalCinema/ChromeExtension/helpers/Data.php

class DigitalCinema_ChromeExtension_Helper_Data extends Mage_Core_Helper_Abstract
{
}

Not sure if I need setup file too

This giving me Can't retrieve entity config: chrome_extension/chromeextension.

I am not sure what is missing/typo or anything. As I understand my mistake is somewhere in resourceModel section.

echo get_class($t); in Indexcontroller.php prints DigitalCinema_ChromeExtension_Model_Chromeextension and var_dump($t) returns:

object(DigitalCinema_ChromeExtension_Model_Chromeextension)[90]
  protected '_eventPrefix' => string 'core_abstract' (length=13)
  protected '_eventObject' => string 'object' (length=6)
  protected '_resourceName' => string 'chrome_extension/chromeextension' (length=32)
  protected '_resource' => null
  protected '_resourceCollectionName' => string 'chrome_extension/chromeextension_collection' (length=43)
  protected '_cacheTag' => boolean false
  protected '_dataSaveAllowed' => boolean true
  protected '_isObjectNew' => null
  protected '_data' => 
    array (size=0)
      empty
  protected '_hasDataChanges' => boolean false
  protected '_origData' => null
  protected '_idFieldName' => null
  protected '_isDeleted' => boolean false
  protected '_oldFieldsMap' => 
    array (size=0)
      empty
  protected '_syncFieldsMap' => 
    array (size=0)
      empty

Please suggest. Thanks in advance.

2
  • What's the line of code that results in "Can't retrieve entity config: chrome_extension/chromeextension."? is kind of unclear from your question? is it this one: $d = $t->getCollection(); ?
    – Marius
    May 6 '15 at 7:01
  • yes, that's right and I can see you have pointed typo in your answer, I will correct it tomorrow. All day wasted not finding typo, poor me. May 6 '15 at 9:05
3

You have a tag <etities> in your config.xml.
It should be <entities>. You are missing an n in here:

        <etities>
            <chromeextension>
                <table>chrome_extension</table>
            </chromeextension>
        </etities>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.