Jump to content

SQL EXPORT ORDER (Weight problem)


Recommended Posts

Hi,

I'm trying code SQL to export orders, I got all fields working, less order weight. I create for export data to shipping (DPD) without module.

After searching and too many tries I can't get it, always bring to me "0.00000", I think is usefull for many people, thats why I post.

Code for Prestashop 1.5.6.2:

SELECT
CONCAT_WS(' ', g.firstname, g.lastname, d.id_order) AS Cliente,
ad.company AS Empresa,
ad.address1 AS Direccion,
ad.address2 AS Direccion2,
ad.postcode AS CodigoPostal,
ad.city AS Poblacion,
ste.name AS Provincia,
cl.name AS Pais,
ad.phone_mobile AS Telefono,
o.payment AS FormaPago,
peso.weight AS Peso,
o.total_paid AS Importe
FROM ps_order_detail d 
LEFT JOIN ps_orders o ON (d.id_order = o.id_order)
LEFT JOIN ps_customer g ON (o.id_customer = g.id_customer)
LEFT JOIN ps_address ad ON (o.id_address_delivery = ad.id_address)
LEFT JOIN ps_state ste ON (ste.id_state = ad.id_state)
LEFT JOIN ps_country_lang cl ON (cl.id_country = ad.id_country)
LEFT JOIN ps_order_carrier peso ON (peso.weight = "weight")
WHERE o.current_state = 40 && cl.id_lang = 4
GROUP BY cl.id_lang = 4

 

If someone want use it, just have to change:

o.current_state = 40   (4o is ID of the order state I create to facilitate export the orders I want, just have create one or use one you have, IE: Payment accepted, Shipped...)

cl.id_lang = 4   (4 is ID of language, this field avoid get 1 line per item of the order and each store language)

CONCAT_WS(' ', g.firstname, g.lastname, d.id_order) AS Cliente,    (I want get the ID order on the name field, if you dont remove "d.id_order" (dont forget remove the coma after g.lastname)

 

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...