PrestaShop: db table structure for orders,cart,cart product,pack,product, product attribute explanation

Trabla: PrestaShop: db table structure for orders,cart,cart product,pack,product, product attribute  explanation


Solving:
PrestaShop: db table structure for orders,cart,cart product,pack,product, product attribute  explanation

1. One Order - one Cart
2. One Cart has one or more cart products,
each cart product reference to product and
product attribute ( product attribute combinations )
3. Pack is product, includes sub products
Table fields:
id_product_pack - id of product ( id from table ps_product)
id_product_item  - id of product in pack (id from table ps_product )
4. ps_product_attribute_combination - map attribute ( e.g. Color ) with product attribute

Example query to get all products with attributes selected in order:
NOTE: only for standart products!!! Not process packs ( Pack of existing products )

SELECT
                o.id_order
            ,    c.id_cart
            ,    cp.id_product
            ,   pac.id_product_attribute
            ,    a.id_attribute

            ,    a.*
FROM
            ps_orders AS o
INNER JOIN  ps_cart c ON c.id_cart = o.id_cart
INNER JOIN  ps_cart_product AS cp ON cp.id_cart = c.id_cart

INNER JOIN  ps_product_attribute AS pa ON pa.id_product_attribute = cp.id_product_attribute
INNER JOIN  ps_product_attribute_combination AS pac ON pac.id_product_attribute = pa.id_product_attribute
INNER JOIN  ps_attribute AS a ON a.id_attribute = pac.id_attribute

WHERE
            o.id_order = PUT_ORDER_ID_HERE


 

No comments:

Post a Comment