Customer Configuration Error After Upgrade – Can’t Retrieve Entity Config

ce-1.4.0.1ce-1.8.0.0configurationcustomerupgrade

I upgraded from ce-1.4.0.1 to ce-1.8 following the wiki.

Now I am getting an error report if I try to open an order in admin backend:

a:5:{i:0;s:60:"Can't retrieve entity config: customer/eav_attribute_website";i:1;s:5784:"#0 /htdocs/app/code/core/Mage/Core/Model/Resource.php(272): Mage::throwException('Can't retrieve ...')
#1 /htdocs/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(276): Mage_Core_Model_Resource->getTableName('customer/eav_at...')
#2 /htdocs/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(488): Mage_Core_Model_Resource_Db_Abstract->getTable('customer/eav_at...')
#3 /htdocs/app/code/core/Mage/Customer/Model/Resource/Attribute/Collection.php(64): Mage_Core_Model_Resource_Db_Collection_Abstract->getTable('customer/eav_at...')
#4 /htdocs/app/code/core/Mage/Eav/Model/Resource/Attribute/Collection.php(153): Mage_Customer_Model_Resource_Attribute_Collection->_getEavWebsiteTable()
#5 /htdocs/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(135): Mage_Eav_Model_Resource_Attribute_Collection->_initSelect()
#6 /htdocs/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Array)
#7 /htdocs/app/code/core/Mage/Core/Model/Config.php(1380): Mage_Core_Model_Config->getModelInstance('customer_entity...', Array)
#8 /htdocs/app/Mage.php(490): Mage_Core_Model_Config->getResourceModelInstance('customer/attrib...', Array)
#9 /htdocs/app/code/core/Mage/Eav/Model/Config.php(354): Mage::getResourceModel('customer/attrib...')
#10 /htdocs/app/code/core/Mage/Eav/Model/Config.php(478): Mage_Eav_Model_Config->_initAttributes(Object(Mage_Eav_Model_Entity_Type))
#11 /htdocs/app/code/core/Mage/Eav/Model/Entity/Abstract.php(512): Mage_Eav_Model_Config->getEntityAttributeCodes(Object(Mage_Eav_Model_Entity_Type), Object(Mage_Customer_Model_Customer))
#12 /htdocs/app/code/core/Mage/Eav/Model/Entity/Abstract.php(952): Mage_Eav_Model_Entity_Abstract->loadAllAttributes(Object(Mage_Customer_Model_Customer))
#13 /htdocs/app/code/core/Mage/Core/Model/Abstract.php(225): Mage_Eav_Model_Entity_Abstract->load(Object(Mage_Customer_Model_Customer), NULL, NULL)
#14 /htdocs/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Messages.php(47): Mage_Core_Model_Abstract->load(NULL)
#15 /htdocs/app/code/core/Mage/Core/Block/Abstract.php(261): Mage_Adminhtml_Block_Sales_Order_View_Messages->_prepareLayout()
#16 /htdocs/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#17 /htdocs/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('adminhtml/sales...', 'order_messages')
#18 /htdocs/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('adminhtml/sales...', 'order_messages')
#19 /htdocs/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#20 /htdocs/app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#21 /htdocs/app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#22 /htdocs/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#23 /htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#24 /htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#25 /htdocs/app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#26 /htdocs/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(59): Mage_Adminhtml_Controller_Action->loadLayout()
#27 /htdocs/app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(115): Mage_Adminhtml_Sales_OrderController->_initAction()
#28 /htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(417): Mage_Adminhtml_Sales_OrderController->viewAction()
#29 /htdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#30 /htdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#31 /htdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#32 /htdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#33 /htdocs/index.php(118): Mage::run('', 'store')
#34 {main}";s:3:"url";s:85:"/index.php/admin/sales_order/view/order_id/5127/key/67a2fd6d316d39b604620cca7d04c71f/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}
~

This problem has been reported quite often at magentocommerce.com and I tried several solutions without any luck:

  • changed tables to InnoDB:

    ALTER TABLE report_compared_product_index ENGINE=InnoDB;
    ALTER TABLE report_viewed_product_index ENGINE=InnoDB;
    ALTER TABLE eav_attribute_label ENGINE=InnoDB;
    ALTER TABLE customer_eav_attribute ENGINE=InnoDB;

  • I also cleared cache and reindexed

  • sql fix that helped others:

    UPDATE eav_entity_type SET attribute_model = 'customer/attribute', additional_attribute_table = 'customer/eav_attribute', entity_attribute_collection = 'customer/attribute_collection' WHERE eav_entity_type.entity_type_code = 'customer';

How can I dig into this?

Or would it be better to try the upgrade again from the start?

Best Answer

I search where customer_eav_attribute_website is defined

grep -R "customer_eav_attribute_website" app

And got: app/code/core/Mage/Customer/etc/config.xml

I dumped my config with a test_script.php:

include "app/Mage.php";
Mage::app();
echo Mage::app()->getConfig()->getXmlString();

and found customer_eav_attribute_website there so this was not overwritten. So I looked at the config.xml again there you see a few lines above customer_eav_attribute_website the resourceModel is defined:

    <models>
        <customer>
            <class>Mage_Customer_Model</class>
            <resourceModel>customer_resource</resourceModel>
        </customer>
        <customer_resource>
                ...
                <eav_attribute_website>
                    <table>customer_eav_attribute_website</table>
                </eav_attribute_website>
        </customer_resource>

Comparing this to the dump I had customer_entity instead of customer_resource. With this the correct config block is not used at all because of the wrong resourceModel. I searched for customer_entity and found the bad module.

Now I compared the modules config.xml with the wrong resourceModel with the old Magento core code in app/code/core/Mage/Customer/etc/config.xml (not the updated core!). The config.xml turned out to be mostly a copy of the core, so I removed all not modified tags and left only what was inserted. Now it works fine!