1

I am trying to add column existing table sales_flat_order but it's returning an error

Can't retrieve entity config: sales/sales_flat_order

my code is:

<?php
 //@var $installer Mage_Sales_Model_Entity_Setup
$installer = $this;
$installer->startSetup();
$installer->run("
ALTER TABLE `{$installer->getTable('sales/sales_flat_order')}` ADD `giftwrap` SMALLINT NULL;
ALTER TABLE `{$installer->getTable('sales/sales_flat_order')}` ADD `giftwrap_price` DECIMAIL(12,5) NULL;
");
$installer->endSetup();

can I know where I went wrong?

thanks.

2

sales_flat_order is the full name of the table and you should use alias in $installer->getTable()

If you take a look in app\code\core\Mage\Sales\etc\config.xml there is table definition

<sales_resource>
    <class>Mage_Sales_Model_Resource</class>
    <deprecatedNode>sales_mysql4</deprecatedNode>
    <entities>
       ....
       <order>
           <table>sales_flat_order</table>
       </order>
       ...
    </entities>
</sales_resource>

So $installer->getTable() should get parameter module_alias/table_alias.

In your case

module_alias = sales

table_alias = order

$installer->getTable('sales/order')

As a result it will return table name sales_flat_order.

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.