Jump to content

Any Mysql experts to help contstruct a Mysql statement ?


gray

Recommended Posts

Any Mysql experts to help construct a Mysql statement ?

I used to have a brilliant little module to do a task, which was to list all products and quantities within a certain date range, that were tagged as 'Payment Recieved'

Unfortunatly that module has not been maintained for the last couple of years.

So I am asking if there are any Mysql experts to help construct a Mysql statement to do that task.

 

Link to comment
Share on other sites

2 hours ago, gray said:

Any Mysql experts to help construct a Mysql statement ?

I used to have a brilliant little module to do a task, which was to list all products and quantities within a certain date range, that were tagged as 'Payment Recieved'

Unfortunatly that module has not been maintained for the last couple of years.

So I am asking if there are any Mysql experts to help construct a Mysql statement to do that task.

 

d

Edited by wepresta (see edit history)
Link to comment
Share on other sites

Hey, if you can attach the module here I can update it to work.  Also make sure to include your prestashop version.

I would need to know payment received order stat id.

or

from phpmyadmin or ps sql manager

First, get the order_state ID(s)

SELECT id_order_state, name
FROM ps_order_state_lang
WHERE name LIKE '%Payment%' OR name LIKE '%Received%';

 

Use those IDs in this report query

This returns product + total qty for orders whose current status is “Payment Received”, within a date range:

SELECT
  od.product_id,
  od.product_reference,
  od.product_name,
  SUM(od.product_quantity) AS qty_sold
FROM ps_orders o
JOIN ps_order_detail od      ON od.id_order = o.id_order
WHERE o.current_state IN (/* put id_order_state(s) here */)
  AND o.date_add >= '2026-01-01 00:00:00'
  AND o.date_add <= '2026-01-31 23:59:59'
GROUP BY
  od.product_id, od.product_reference, od.product_name
ORDER BY qty_sold DESC;
 

  • Like 1
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...