Can't retrieve entity config: sales/sales_flat_order
-
22-10-2019 - |
Pergunta
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.
Solução
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
.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange