Question

On /admin page I get

a:5:{i:0;s:107:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'shop.sales_order' doesn't exist";i:1;s:4477:"#0 /lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT SUM((IFN...', Array)
#4 /lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT SUM((IFN...', Array)
#5 /lib/Zend/Db/Adapter/Abstract.php(734): Varien_Db_Adapter_Pdo_Mysql->query('SELECT SUM((IFN...', Array)
#6 /lib/Varien/Data/Collection/Db.php(734): Zend_Db_Adapter_Abstract->fetchAll('SELECT SUM((IFN...', Array)
#7 /app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT SUM((IFN...', Array)
#8 /lib/Varien/Data/Collection/Db.php(566): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
#9 /app/code/core/Mage/Adminhtml/Block/Dashboard/Totals.php(70): Varien_Data_Collection_Db->load()
#10 /app/code/core/Mage/Core/Block/Abstract.php(261): Mage_Adminhtml_Block_Dashboard_Totals->_prepareLayout()
#11 /app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#12 /app/code/core/Mage/Adminhtml/Block/Dashboard.php(50): Mage_Core_Model_Layout->createBlock('adminhtml/dashb...')
#13 /app/code/core/Mage/Core/Block/Abstract.php(261): Mage_Adminhtml_Block_Dashboard->_prepareLayout()
#14 /app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#15 /app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('adminhtml/dashb...', 'dashboard')
#16 /app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('adminhtml/dashb...', 'dashboard')
#17 /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))
#18 /app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#19 /app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#20 /app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#21 /app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#22 /app/code/core/Mage/Adminhtml/controllers/DashboardController.php(40): Mage_Adminhtml_Controller_Action->loadLayout()
#23 /app/code/core/Mage/Core/Controller/Varien/Action.php(417): Mage_Adminhtml_DashboardController->indexAction()
#24 /app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#25 /app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#26 /app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#27 /app/Mage.php(683): Mage_Core_Model_App->run(Array)
#28 /index.php(118): Mage::run('', 'store')

This is caused by a modules config.xml:

<global>
    <models>
        <sales>
            <class>Mage_Sales_Model</class>
            <resourceModel>sales_mysql4</resourceModel>
        </sales>
        <sales_mysql4>
            <class>Mage_Sales_Model_Mysql4</class>
            <entities>
                <quote><table>sales_flat_quote</table></quote>
                <quote_item><table>sales_flat_quote_item</table></quote_item>
                <quote_address><table>sales_flat_quote_address</table></quote_address>
                <quote_address_item><table>sales_flat_quote_address_item</table></quote_address_item>
                <quote_item_option><table>sales_flat_quote_item_option</table></quote_item_option>
                <quote_payment><table>sales_flat_quote_payment</table></quote_payment>
                <quote_address_shipping_rate><table>sales_flat_quote_shipping_rate</table></quote_address_shipping_rate>

                <order><table>sales_order</table></order>
                <order_tax><table>sales_order_tax</table></order_tax>
                <order_item><table>sales_flat_order_item</table></order_item>
                <order_item_option><table>sales_flat_order_item_option</table></order_item_option>
                <order_entity><table>sales_order_entity</table></order_entity>

The sales_order table is a relic from a old version. As I can not use getTable('sales/order') here, what other table could I use here?

Was it helpful?

Solution

sales_order is an old table from the EAV olden days (<=1.3.2.4CE/1.8EE) of the sales module.

This may be evidence of an upgrade gone awry. To my knowledge getTable should always return sales_flat_order after 1.4CE. Check to make sure that the Mage_Sales module is correctly installed, all upgrade scripts are in place, and that the config.xml file lists the correct module version for 1.8+

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top