2 added 2497 characters in body
source | link
class Psdev_Charity_IndexController extends Mage_Core_Controller_Front_Action
{



    public function indexAction()
    {

        try {
            for($i = 0; $i < 5; $i++) {
                $model = Mage::getModel('psdev_charity/charity');
                $model->setCharity_name>setCharityName('Donuts' . $i);
                $model->setCharity_description>setCharityDescription('Round and Sugary');
                $model->setCharity_image>setCharityImage('not an image link');
                $model->save();
            }
        } catch(Exception $e) {
            Mage::getSingleton('core/session')->addError($e->getMessage());
            Mage::log($e->getMessage());
        }

        $this->loadLayout();

        $content = 'Fake charities have been created';
        $block = $this->getLayout()
            ->createBlock('core/text', 'example-block')
            ->setText($content);



        $this->getLayout()->getBlock('content')->append($block);


        $this->renderLayout();
    }
}

Update: 10/30/2014

It seems the error is thrown at model->save() but only if I try to set attributes. If I remove the calls (setCharityName()) the exception is not thrown, but of course, there is nothing in the database.

Stack Trace Can't retrieve entity config: eav/psdev_charity

#0 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/Resource.php(277): Mage::throwException('Can't retrieve ...')
#1 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(284): Mage_Core_Model_Resource->getTableName(Array)
#2 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php(508): Mage_Core_Model_Resource_Db_Abstract->getTable(Array)
#3 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(468): Mage_Eav_Model_Entity_Attribute_Abstract->getBackendTable()
#4 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(424): Mage_Eav_Model_Entity_Abstract->addAttribute(Object(Mage_Eav_Model_Entity_Attribute))
#5 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(529): Mage_Eav_Model_Entity_Abstract->getAttribute('charity_descrip...')
#6 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(1113): Mage_Eav_Model_Entity_Abstract->loadAllAttributes(Object(Psdev_Charity_Model_Charity))
#7 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Psdev_Charity_Model_Charity))
#8 /var/www/html/paulsandel.com/app/code/community/Psdev/Charity/controllers/IndexController.php(17): Mage_Core_Model_Abstract->save()
#9 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Psdev_Charity_IndexController->indexAction()
#10 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#11 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#13 /var/www/html/paulsandel.com/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#14 /var/www/html/paulsandel.com/index.php(86): Mage::run('', 'store')
#15 {main}
class Psdev_Charity_IndexController extends Mage_Core_Controller_Front_Action
{



    public function indexAction()
    {

        try {
            for($i = 0; $i < 5; $i++) {
                $model = Mage::getModel('psdev_charity/charity');
                $model->setCharity_name('Donuts' . $i);
                $model->setCharity_description('Round and Sugary');
                $model->setCharity_image('not an image link');
                $model->save();
            }
        } catch(Exception $e) {
            Mage::getSingleton('core/session')->addError($e->getMessage());
            Mage::log($e->getMessage());
        }

        $this->loadLayout();

        $content = 'Fake charities have been created';
        $block = $this->getLayout()
            ->createBlock('core/text', 'example-block')
            ->setText($content);



        $this->getLayout()->getBlock('content')->append($block);


        $this->renderLayout();
    }
}
class Psdev_Charity_IndexController extends Mage_Core_Controller_Front_Action
{



    public function indexAction()
    {

        try {
            for($i = 0; $i < 5; $i++) {
                $model = Mage::getModel('psdev_charity/charity');
                $model->setCharityName('Donuts' . $i);
                $model->setCharityDescription('Round and Sugary');
                $model->setCharityImage('not an image link');
                $model->save();
            }
        } catch(Exception $e) {
            Mage::getSingleton('core/session')->addError($e->getMessage());
            Mage::log($e->getMessage());
        }

        $this->loadLayout();

        $content = 'Fake charities have been created';
        $block = $this->getLayout()
            ->createBlock('core/text', 'example-block')
            ->setText($content);



        $this->getLayout()->getBlock('content')->append($block);


        $this->renderLayout();
    }
}

Update: 10/30/2014

It seems the error is thrown at model->save() but only if I try to set attributes. If I remove the calls (setCharityName()) the exception is not thrown, but of course, there is nothing in the database.

Stack Trace Can't retrieve entity config: eav/psdev_charity

#0 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/Resource.php(277): Mage::throwException('Can't retrieve ...')
#1 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(284): Mage_Core_Model_Resource->getTableName(Array)
#2 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php(508): Mage_Core_Model_Resource_Db_Abstract->getTable(Array)
#3 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(468): Mage_Eav_Model_Entity_Attribute_Abstract->getBackendTable()
#4 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(424): Mage_Eav_Model_Entity_Abstract->addAttribute(Object(Mage_Eav_Model_Entity_Attribute))
#5 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(529): Mage_Eav_Model_Entity_Abstract->getAttribute('charity_descrip...')
#6 /var/www/html/paulsandel.com/app/code/core/Mage/Eav/Model/Entity/Abstract.php(1113): Mage_Eav_Model_Entity_Abstract->loadAllAttributes(Object(Psdev_Charity_Model_Charity))
#7 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Eav_Model_Entity_Abstract->save(Object(Psdev_Charity_Model_Charity))
#8 /var/www/html/paulsandel.com/app/code/community/Psdev/Charity/controllers/IndexController.php(17): Mage_Core_Model_Abstract->save()
#9 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Psdev_Charity_IndexController->indexAction()
#10 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#11 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /var/www/html/paulsandel.com/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#13 /var/www/html/paulsandel.com/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#14 /var/www/html/paulsandel.com/index.php(86): Mage::run('', 'store')
#15 {main}
1
source | link

Magento 1.9 Custom Entity, Can't retrieve entity config: eav/psdev_charity

I'm receiving this error when I attempt to save a model of type custom entity: Can't retrieve entity config: eav/psdev_charity. I suspect this is a problem with my configuration, however I'm so far unable to track it down. I'm on Magento 1.9 CE. Cache is disabled, developer mode is on, and I delete the contents of var prior to testing.

Here's my my module's config:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Psdev_Charity>
        <version>0.0.1</version>
        </Psdev_Charity>
    </modules>
    <frontend>
        <routers>
            <psdev_charity>
                <use>standard</use>
                <args>
                    <module>Psdev_Charity</module>
                    <frontName>psdev_charity</frontName>
                </args>
            </psdev_charity>
        </routers>
    </frontend>
    <global>
         <models>
             <psdev_charity>
                 <class>Psdev_Charity_Model</class>
                 <resourceModel>charity_resource</resourceModel>
             </psdev_charity>
             <charity_resource>
                 <class>Psdev_Charity_Model_Resource</class>
                 <entities>
                     <psdev_charity>
                         <table>psdev_charity</table>
                     </psdev_charity>
                 </entities>
             </charity_resource>
        </models>
        <resources>
            <charity_setup>
                <setup>
                    <module>Psdev_Charity</module>
                    <class>Psdev_Charity_Model_Resource_Setup</class>
                </setup>
            </charity_setup>
        </resources>
    </global>
</config>

Here's my model:

class Psdev_Charity_Model_Charity extends Mage_Core_Model_Abstract
{
    protected function _construct()
    {
        parent::_construct();
        $this->_init('psdev_charity/charity');
    }
}

Here's my Resource Model

class Psdev_Charity_Model_Resource_Charity extends Mage_Eav_Model_Entity_Abstract 
{
    protected function _construct()
    {
        $resource = Mage::getSingleton('core/resource');
        $this->setType('psdev_charity');
        $this->setConnection(
            $resource->getConnection('charity_read'),
            $resource->getConnection('charity_write')
        );
    }
}

Here's my collection

<?php
class Psdev_Charity_Model_Resource_Charity_Collection extends Mage_Eav_Model_Entity_Collection_Abstract
{
    protected function _construct()
    {
        parent::_construct();

        $this->_init(
            'psdev_charity/charity',
            'psdev_charity/charity'
        );
    }
}

Here's the controller where the error occurs. Error occurs at model->save()

class Psdev_Charity_IndexController extends Mage_Core_Controller_Front_Action
{



    public function indexAction()
    {

        try {
            for($i = 0; $i < 5; $i++) {
                $model = Mage::getModel('psdev_charity/charity');
                $model->setCharity_name('Donuts' . $i);
                $model->setCharity_description('Round and Sugary');
                $model->setCharity_image('not an image link');
                $model->save();
            }
        } catch(Exception $e) {
            Mage::getSingleton('core/session')->addError($e->getMessage());
            Mage::log($e->getMessage());
        }

        $this->loadLayout();

        $content = 'Fake charities have been created';
        $block = $this->getLayout()
            ->createBlock('core/text', 'example-block')
            ->setText($content);



        $this->getLayout()->getBlock('content')->append($block);


        $this->renderLayout();
    }
}

Here's the Setup Class

<?php
$installed = false;
$installer = $this;

try {

$installer->startSetup();
$installer->addEntityType('psdev_charity', array(
    'entity_model' => 'psdev_charity',
    'table' => 'psdev_charity'
));

$installer->createEntityTables(
    $this->getTable('psdev_charity')
);

$installer->addAttribute('psdev_charity', 'charity_name', array(
    'type' => 'varchar',
    'label' => 'Charity Name',
    'input' => 'text',
    'required' => true,
    'user_defined' => true,
    'unique' => true,
    'is_visible_on_front' => true,
    'is_comparable' => false,
    'is_visible' => true,
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE
));

$installer->addAttribute('psdev_charity', 'charity_description', array(
    'type' => 'text',
    'label' => 'Charity Description',
    'input' => 'textarea',
    'required' => true,
    'user_defined' => true,
    'unique' => false,
    'is_html_allowed_on_front' => true,
    'wysiwyg_enabled' => true,
    'is_visible_on_front' => true,
    'is_comparable' => false,
    'is_visible' => true,
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE
));

$installer->addAttribute('psdev_charity', 'charity_image', array(
    'type' => 'varchar',
    'label' => 'Charity Image',
    'input' => 'image',
    'backend' => 'catalog/category_attribute_backend_image',
    'is_visible' => true,
    'user_defined' => true,
    'is_visible_on_front' => true,
    'is_comparable' => false,
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE
));

$installed = true;

} catch (Exception $e) {
$message = 'Could not complete Charity Module Installation: ' . $e->getMessage();
Mage::getSingleton('core/session')->addError($message);
Mage::log($message);
}

if($installed === true) {
$message = 'Charity Module has been installed';
Mage::getSingleton('core/session')->addSuccess($message);
Mage::log($message);
}


$installer->endSetup();

If anyone can point me in the right direction, I would be greatly appreciative. I'm finding it extremely difficult to troubleshoot, as there is only weak central documentation, and most of the data I can find is for a different version, or different specifics.

Thanks!