Click Fraud Protection
PHP related blog, freelancer to hire!

Magento invoices mysql table located

If you’re looking where Magento stores its invoices, first step was to locate table sales_order_invoice, but such table doesn’t exists.

Good starting point is always a Magento API, which shows you a little bit how to digg for information.

I’ve located api.xml file responsible for invoices API and then found Model which does all magic.

app/code/core/Mage/Sales/Model/Order/Invoice/Api.php

Check method

public function items($filters = null) – to get all invoices

or

public function info($invoiceIncrementId)  – how to read invoice details

Next very important thing – Entities – this will tell you how all elements are structured and where located in mysql table

app/code/core/Mage/Sales/Model/Entity/Setup.php

For example:

'invoice' => array(
'entity_model'      => 'sales/order_invoice',
'table'             =>'sales/order_entity',

Invoices are store in sales_order_entity ( try SELECT * FROM sales_order_entity WHERE entity_type_id = 16)

Invoices items

'invoice_item' => array(
'entity_model'      => 'sales/order_invoice_item',
//'table'=>'sales/invoice',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id'     => array(
'type'=>'static',
'backend'=>'sales_entity/order_invoice_attribute_backend_child'
),

That should be enough to see what’s going on

Leave a Reply