Question

I'm quite new to magento development and could not find any information on this theme.

I know that the catalog_product_flat* tables are indexed and are only existing, if magento is set to use flat tables. Therefore data stored here might get deleted and the tables could get recreated with data from other tables.

Is the same true for the sales_flat* tables? I'm writing a module and I'm storing data in these tables. If they could get dropped and then reconstructed by magento i would loose this data. Is it safe to store data only in these tables? Or should i use other tables and then populate the data in sales_flat* with these?

For example i would like to store the payment date if an invoice in sales_flat_invoice and sales_flat_invoice_grid. Because the german tax office needs these dates instead of the date the invoice was issued.

Was it helpful?

Solution

The sales_flat_* tables do not follow the same rules as the catalog_flat_* tables.
They are here to stay. Those are the actual tables that hold the order (and onthers) informations.
The name flat was added in Magento CE 1.4 when the orders became flat entities. At first they were EAV and the table name was sales_order. but in order to migrate from EAV to flat there was a need for an other table name. I guess they added flat because it was the logical thing to do.
In conclusion, you can add data to those tables. They wont get recreated.

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