Jump to content

SQL query to take orders in multistore


acpkor

Recommended Posts

Hello, I am applying this SQL query

 

SELECT ord.id_order,`reference`,`ddw_order_date`,`product_name`,`product_quantity`,`date_add` FROM `ps_orders` as ord INNER JOIN `ps_order_detail` as od ON ord.id_order = od.id_order WHERE `valid` = 1 AND `date_add` BETWEEN '2022-04-24' AND '2022-05-30'

 

I don't know why, but it only takes the orders from store 1.
I don't know why it doesn't get all the orders, those from store 1 and those from store 2.

Does anyone know why this happens?

Thank you,

Link to comment
Share on other sites

20 minutes ago, acpkor said:

Hello, I am applying this SQL query

 

SELECT ord.id_order,`reference`,`ddw_order_date`,`product_name`,`product_quantity`,`date_add` FROM `ps_orders` as ord INNER JOIN `ps_order_detail` as od ON ord.id_order = od.id_order WHERE `valid` = 1 AND `date_add` BETWEEN '2022-04-24' AND '2022-05-30'

 

I don't know why, but it only takes the orders from store 1.
I don't know why it doesn't get all the orders, those from store 1 and those from store 2.

Does anyone know why this happens?

Thank you,

Hi,
I've checked it, and it seems correct. Please take a look at my experiment on a test multistore: https://prnt.sc/g6KKhFnCUGa- 
You can add the ord.`id_shop` column to easily check if it returns any rows from other shop or not. 
Are you sure that in the date interval there was valid orders on the second shop? 
I hope that I could help.
Have a nice day, Leo.

  • Like 1
Link to comment
Share on other sites

Hi `prestachamps`,

perfect. Thank you
I have added ord.`id_shop` and it works correctly.
shows the products of the 2 stores

How can I make the query show me all the products regardless of the status of the order?

  • Like 1
Link to comment
Share on other sites

1 hour ago, acpkor said:

Hi `prestachamps`,

perfect. Thank you
I have added ord.`id_shop` and it works correctly.
shows the products of the 2 stores

How can I make the query show me all the products regardless of the status of the order?

Hi,
The above query returns the products from the order details, regardless of the status of the order. 
If you want to filter the query by the order states, you can use the ord.`current_state` column in the where statement. 
I hope that I could help.
Have a nice day, Leo.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...