Skip to content

Magento DB Query For Sales Product Details

Magento one of the best CMS for e-commerce website creation. Today I’m going to share some cool queries by which you will get detail of your sale product with its Increment Id, Buyer Name and  Email address.Magento DB structure is very complex, if i”m not wrong then when you install magento then you will get 250 – 270 tables in your database.  Where many tables hold your product catalog details and as like what type product and category of product and all. In magento you will get all sold product data/details in some tables and the name of those tables are

  1. sales_flat_order
  2. sales_flat_order_address
  3. sales_flat_order_grid
  4. sales_falte_order_item
  5. sales_flat_quote_item
  6. sales_flat_quote_address

Those tables hold all details of your sold product. Now it’s time of db query for get all product data from database by fire a single query.

SELECT sales_flat_order.entity_id,sales_flat_quote_address.firstname, sales_flat_quote_address.lastname,,sales_flat_order_grid.increment_id FROM sales_flat_order LEFT JOIN sales_flat_quote_address ON sales_flat_quote_address.quote_id = sales_flat_order.quote_id
LEFT JOIN sales_flat_order_grid ON sales_flat_order_grid.entity_id = sales_flat_order.entity_id WHERE sales_flat_quote_address.address_type = ['your address type'] ORDER by sales_flat_order.entity_id desc

When you fire this query in your database then you will get all sold product details with your customer number in descending form.

If you like this then share and like this on my fb page. 🙂

Previous article

Yii2 base Rest API Creation

Next article

Magento script for get collection of multiple product id's data

Join the discussion

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: