Jump to content

SQL-Abfrage bezahlte bestellungen exportieren


D3n1z

Recommended Posts

Hallo, ich versuche meine bezahlten bestellungen als csv zu speichern damit ich sie in DHL Easylog einlesen kann und ein Paketzettel drucken kann.

 

Mein Code bis jetzt:

SELECT d.id_order, os.name AS Status, d.product_name AS Produkt, d.product_price AS Preis, d.product_quantity AS Menge, o.payment AS Bezahlung, o.date_upd AS Datum, CONCAT_WS(' ', g.firstname, g.lastname) AS Kunde, gl.name AS Kundengruppe
    FROM sm_order_detail d
    LEFT JOIN sm_orders o ON (d.id_order= o.id_order)
    LEFT JOIN sm_customer g ON (o.id_customer = g.id_customer)
    LEFT JOIN sm_group_lang gl ON (g.id_default_group = gl.id_group)
    LEFT JOIN sm_order_state_lang os ON (o.current_state = os.id_order_state)
GROUP BY d.id_order

Wie bekomme ich den Namen, Land, Straße, PLZ + Ort noch dahinter?

Link to comment
Share on other sites

Was meinst du mit "Namen"?

 

Hier eine erweiterte Abfrage:

SELECT d.id_order, os.name AS Status, d.product_name AS Produkt, ROUND(d.product_price,2) AS Preis, d.product_quantity AS Menge, o.payment AS Bezahlung, o.date_upd AS Datum, CONCAT_WS(' ', a.firstname, a.lastname) AS Kunde, a.address1 AS Strasse, a.postcode AS PLZ, a.city AS Ort, cl.name AS Land, gl.name AS Kundengruppe
    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 AS a ON (o.id_customer = a.id_customer)
    LEFT JOIN ps_country_lang AS cl ON (a.id_country = cl.id_country )
    LEFT JOIN ps_group_lang gl ON (g.id_default_group = gl.id_group)
    LEFT JOIN ps_order_state_lang os ON (o.current_state = os.id_order_state)
 GROUP BY d.id_order

Ist jetzt Prestashop-Standard bei Database Prefix. Bei dir ist der Prefix ja sm_.

Edited by Martijn++ (see edit history)
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...