2

In Mage_Sales_Model_Resource_Report_Bestsellers_Collection::_initSelect() on Line 138

$mainTable = $this->getTable('sales/bestsellers_aggregated_yearly');

Magento throws an error: Can't retrieve entity config: sales/bestsellers_aggregated_yearly but table sales_bestsellers_aggregated_yearly does exist.

Why does Magento not find this table?

I did a Magento update from ce-1.4.0.1 that might have messed up something...

Update

getTable() is calling Mage_Core_Model_Resource::getTableName() and this looks like this:

    $parts = explode('/', $modelEntity);
    if (isset($parts[1])) {
        list($model, $entity) = $parts;
        $entityConfig = false;
        if (!empty(Mage::getConfig()->getNode()->global->models->{$model}->resourceModel)) {
            $resourceModel = (string)Mage::getConfig()->getNode()->global->models->{$model}->resourceModel;
            $entityConfig  = $this->getEntity($resourceModel, $entity);
        }

        if ($entityConfig && !empty($entityConfig->table)) {
            $tableName = (string)$entityConfig->table;
        } else {
            Mage::throwException(Mage::helper('core')->__('Can\'t retrieve entity config: %s', $modelEntity));
        }

In app/code/core/Mage/Sales/etc/config.xml the correct table is defined as sales_bestsellers_aggregated_yearly with the config path:

/config/global/models/sales_resource/entities/bestsellers_aggregated_yearly

To find modules messing with this config i did:

grep -R "bestsellers_aggregated_yearly" app/

And found only core files:

app/code/core/Mage/Sales/Model/Resource/Report/Bestsellers/Collection.php
app/code/core/Mage/Sales/sql/sales_setup/*
app/code/core/Mage/Sales/etc/config.xml
2

Problem was a module's etc/config.xml which was overwriting resourceModel of <sales>:

    <models>
        <sales>
            <class>Mage_Sales_Model</class>
            <resourceModel>sales_mysql4</resourceModel>
        </sales>
         ...

It was a copy of the old Sales config that did not include bestsellers_aggregated_yearly nor any other new stuff. I removed this bad config completely because it contained no change compared to the sales config in the old Magento core.

0

It looks like something got messed up in the sales module or by a module overriding Mage_Sales. Have a look at the config.xml of Mage_Sales where the alias sales is defined. (Xpath: /config/global/models/sales_resource/entities/bestsellers_aggregated_yearly)

Then check if any custom modul destorys something in here, you can get closer by dumping the full XML config. (see https://stackoverflow.com/questions/11784811/inspect-config-xml-tree-magento-generates)

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.