Jump to content

Zapytanie SQL które wyświetli wszystkie kombinacje i atrybuty produktów


medyczny

Recommended Posts

Moje zapytanie jakie mam to

SELECT
    p.id_product 'Product ID',
    pl.name 'Product name',
    p.wholesale_price 'Cost price',
    GROUP_CONCAT(DISTINCT(al.name) SEPARATOR ", ") AS 'Product Variants',
    s.quantity 'Remaining pieces'
FROM
    ps_product p
LEFT JOIN ps_product_lang pl ON
    (
        p.id_product = pl.id_product AND pl.id_lang = 1
    )
LEFT JOIN ps_product_attribute pa ON
    (p.id_product = pa.id_product)
LEFT JOIN ps_stock_available s ON
    (
        p.id_product = s.id_product AND(
            (
                pa.id_product_attribute IS NULL AND s.id_product_attribute = 0
            ) OR(
                s.id_product_attribute = pa.id_product_attribute
            )
        )
    )
LEFT JOIN ps_product_attribute_combination pac ON
    (
        pac.id_product_attribute = pa.id_product_attribute
    )
LEFT JOIN ps_attribute_lang al ON
    (
        al.id_attribute = pac.id_attribute AND al.id_lang = 1
    )
GROUP BY
    p.id_product,
    pac.id_product_attribute
ORDER BY
    p.id_product

 

Jednak nie jest on w takiej formie w której mógłbym ją zaimportować później do presty. Proszę o pomoc w edycji tego kodu

Edited by medyczny (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...