22 hours ago, calichelozano said:Hi Patron, I hope you're having a great week start!I don't know if I can do this request here, but since you're so good and were able to help me eith your code, here it goes: Is there an sql query to export just the users that bought "X" product with their phone numbers and selecting a date range?
Thank you very much!
SELECT DISTINCT c.id_customer, CONCAT(c.firstname, ' ', c.lastname) AS customer_name, COALESCE(a.phone_mobile, a.phone, '') AS phone, o.id_order, o.reference AS order_reference, o.date_add AS order_date FROM ps_order_detail od INNER JOIN ps_orders o ON od.id_order = o.id_order INNER JOIN ps_customer c ON o.id_customer = c.id_customer LEFT JOIN ps_address a ON o.id_address_delivery = a.id_address WHERE od.product_id = 123 -- ← replace 123 with your product’s ID AND o.date_add BETWEEN '2025-01-01' AND '2025-06-30' -- ← set your start/end dates ORDER BY o.date_add DESC;
Above is a template you can paste into your PrestaShop Admin → “SQL Manager” (replace the table prefix ps_ if yours is different). It will pull every customer who bought product “X” in a given date range, along with their phone number (preferring mobile if available).