Jump to content

Edit History

ps8modules

ps8modules

Full query for id_shop = 1, id_lang = 1.

You can insert the SQl query into your phpMyAdmin and you will see the result.

The sign column is the + or - sign of the reaction.
So the result is physical_quantity column * sign column.

 

SELECT SQL_CALC_FOUND_ROWS
              sm.id_stock_mvt,
              sm.id_stock,
              sm.id_order,
              sm.id_employee,
              sm.employee_lastname,
              sm.employee_firstname,
              sm.physical_quantity,
              sm.date_add,
              sm.sign,
              smrl.id_stock_mvt_reason,
              smrl.name                                   AS movement_reason,
              p.id_product                                AS product_id,
              COALESCE(pa.id_product_attribute, 0)        AS combination_id,
              IF(
                  LENGTH(COALESCE(pa.reference, "")) = 0,
                  IF(LENGTH(TRIM(p.reference)) > 0, p.reference, "N/A"),
                  CONCAT(p.reference, " ", pa.reference)
              )                                           AS product_reference,
              pl.name                                     AS product_name,
              p.id_supplier                               AS supplier_id,
              COALESCE(s.name, "N/A")                     AS supplier_name,
              COALESCE(ic.id_image, 0)                    AS product_cover_id,
              (SELECT GROUP_CONCAT(
                        DISTINCT CONCAT(agl.name, " - ", al.name)
                        SEPARATOR ", "
                    )
                    FROM ps_product_attribute pa2
                    JOIN ps_product_attribute_combination pac ON (
                        pac.id_product_attribute = pa2.id_product_attribute
                    )
                    JOIN ps_attribute a ON (
                        a.id_attribute = pac.id_attribute
                    )
                    JOIN ps_attribute_lang al ON (
                        a.id_attribute = al.id_attribute
                        AND al.id_lang = 1
                    )
                    JOIN ps_attribute_group ag ON (
                        ag.id_attribute_group = a.id_attribute_group
                    )
                    JOIN ps_attribute_group_lang agl ON (
                        ag.id_attribute_group = agl.id_attribute_group
                        AND agl.id_lang = 1
                    )
                    WHERE pa2.id_product=p.id_product AND pa2.id_product_attribute=pa.id_product_attribute)
                    AS combination_name,
              (SELECT GROUP_CONCAT(
                        DISTINCT CONCAT(agl.name)
                        SEPARATOR ", "
                    )
                    FROM ps_product_attribute pa2
                    JOIN ps_product_attribute_combination pac ON (
                        pac.id_product_attribute = pa2.id_product_attribute
                    )
                    JOIN ps_attribute a ON (
                        a.id_attribute = pac.id_attribute
                    )
                    JOIN ps_attribute_group ag ON (
                        ag.id_attribute_group = a.id_attribute_group
                    )
                    JOIN ps_attribute_group_lang agl ON (
                        ag.id_attribute_group = agl.id_attribute_group
                        AND agl.id_lang = 1
                    )
                    WHERE pa2.id_product=p.id_product AND pa2.id_product_attribute=pa.id_product_attribute)
                    AS attribute_name
           FROM ps_stock_mvt sm
            INNER JOIN ps_stock_mvt_reason_lang smrl ON (
              smrl.id_stock_mvt_reason = sm.id_stock_mvt_reason
              AND smrl.id_lang = 1)
            INNER JOIN ps_stock_available sa ON (sa.id_stock_available = sm.id_stock)
            LEFT JOIN ps_product p ON (p.id_product = sa.id_product)
            LEFT JOIN ps_product_attribute pa ON (pa.id_product_attribute = sa.id_product_attribute)
            LEFT JOIN ps_product_lang pl ON (
                p.id_product = pl.id_product AND
                pl.id_lang = 1
            )
            INNER JOIN ps_product_shop ps ON (
                p.id_product = ps.id_product AND
                ps.id_shop = 1
            )
            LEFT JOIN ps_image ic ON (
                p.id_product = ic.id_product AND
                ic.cover = 1
            )
            LEFT JOIN ps_image_shop ims ON (
                p.id_product = ims.id_product AND
                ic.id_image  = ims.id_image AND
                ims.id_shop = 1 AND
                ims.cover = 1
            )
            LEFT JOIN ps_supplier s ON (p.id_supplier = s.id_supplier)
            LEFT JOIN ps_product_attribute_combination pac ON (
                pac.id_product_attribute = pa.id_product_attribute
            )
            LEFT JOIN ps_product_attribute_shop pas ON (
                pas.id_product = pa.id_product AND
                pas.id_product_attribute = pa.id_product_attribute AND
                pas.id_shop = 1
            )
            WHERE
            sa.id_shop = 1 AND
            sa.id_shop_group = 0 AND
            sa.id_product_attribute = COALESCE(pa.id_product_attribute, 0)
            
            GROUP BY sm.id_stock_mvt
            HAVING 1 
            ORDER BY date_add DESC 
        

 

ps8modules

ps8modules

Full query for id_shop = 1, id_lang = 1.

You can insert the SQl query into your phpMyAdmin and you will see the result

 

SELECT SQL_CALC_FOUND_ROWS
              sm.id_stock_mvt,
              sm.id_stock,
              sm.id_order,
              sm.id_employee,
              sm.employee_lastname,
              sm.employee_firstname,
              sm.physical_quantity,
              sm.date_add,
              sm.sign,
              smrl.id_stock_mvt_reason,
              smrl.name                                   AS movement_reason,
              p.id_product                                AS product_id,
              COALESCE(pa.id_product_attribute, 0)        AS combination_id,
              IF(
                  LENGTH(COALESCE(pa.reference, "")) = 0,
                  IF(LENGTH(TRIM(p.reference)) > 0, p.reference, "N/A"),
                  CONCAT(p.reference, " ", pa.reference)
              )                                           AS product_reference,
              pl.name                                     AS product_name,
              p.id_supplier                               AS supplier_id,
              COALESCE(s.name, "N/A")                     AS supplier_name,
              COALESCE(ic.id_image, 0)                    AS product_cover_id,
              (SELECT GROUP_CONCAT(
                        DISTINCT CONCAT(agl.name, " - ", al.name)
                        SEPARATOR ", "
                    )
                    FROM ps_product_attribute pa2
                    JOIN ps_product_attribute_combination pac ON (
                        pac.id_product_attribute = pa2.id_product_attribute
                    )
                    JOIN ps_attribute a ON (
                        a.id_attribute = pac.id_attribute
                    )
                    JOIN ps_attribute_lang al ON (
                        a.id_attribute = al.id_attribute
                        AND al.id_lang = 1
                    )
                    JOIN ps_attribute_group ag ON (
                        ag.id_attribute_group = a.id_attribute_group
                    )
                    JOIN ps_attribute_group_lang agl ON (
                        ag.id_attribute_group = agl.id_attribute_group
                        AND agl.id_lang = 1
                    )
                    WHERE pa2.id_product=p.id_product AND pa2.id_product_attribute=pa.id_product_attribute)
                    AS combination_name,
              (SELECT GROUP_CONCAT(
                        DISTINCT CONCAT(agl.name)
                        SEPARATOR ", "
                    )
                    FROM ps_product_attribute pa2
                    JOIN ps_product_attribute_combination pac ON (
                        pac.id_product_attribute = pa2.id_product_attribute
                    )
                    JOIN ps_attribute a ON (
                        a.id_attribute = pac.id_attribute
                    )
                    JOIN ps_attribute_group ag ON (
                        ag.id_attribute_group = a.id_attribute_group
                    )
                    JOIN ps_attribute_group_lang agl ON (
                        ag.id_attribute_group = agl.id_attribute_group
                        AND agl.id_lang = 1
                    )
                    WHERE pa2.id_product=p.id_product AND pa2.id_product_attribute=pa.id_product_attribute)
                    AS attribute_name
           FROM ps_stock_mvt sm
            INNER JOIN ps_stock_mvt_reason_lang smrl ON (
              smrl.id_stock_mvt_reason = sm.id_stock_mvt_reason
              AND smrl.id_lang = 1)
            INNER JOIN ps_stock_available sa ON (sa.id_stock_available = sm.id_stock)
            LEFT JOIN ps_product p ON (p.id_product = sa.id_product)
            LEFT JOIN ps_product_attribute pa ON (pa.id_product_attribute = sa.id_product_attribute)
            LEFT JOIN ps_product_lang pl ON (
                p.id_product = pl.id_product AND
                pl.id_lang = 1
            )
            INNER JOIN ps_product_shop ps ON (
                p.id_product = ps.id_product AND
                ps.id_shop = 1
            )
            LEFT JOIN ps_image ic ON (
                p.id_product = ic.id_product AND
                ic.cover = 1
            )
            LEFT JOIN ps_image_shop ims ON (
                p.id_product = ims.id_product AND
                ic.id_image  = ims.id_image AND
                ims.id_shop = 1 AND
                ims.cover = 1
            )
            LEFT JOIN ps_supplier s ON (p.id_supplier = s.id_supplier)
            LEFT JOIN ps_product_attribute_combination pac ON (
                pac.id_product_attribute = pa.id_product_attribute
            )
            LEFT JOIN ps_product_attribute_shop pas ON (
                pas.id_product = pa.id_product AND
                pas.id_product_attribute = pa.id_product_attribute AND
                pas.id_shop = 1
            )
            WHERE
            sa.id_shop = 1 AND
            sa.id_shop_group = 0 AND
            sa.id_product_attribute = COALESCE(pa.id_product_attribute, 0)
            
            GROUP BY sm.id_stock_mvt
            HAVING 1 
            ORDER BY date_add DESC 
        

 

ps8modules

ps8modules

Full query for id_shop = 1, id_lang = 1.

 

SELECT SQL_CALC_FOUND_ROWS
              sm.id_stock_mvt,
              sm.id_stock,
              sm.id_order,
              sm.id_employee,
              sm.employee_lastname,
              sm.employee_firstname,
              sm.physical_quantity,
              sm.date_add,
              sm.sign,
              smrl.id_stock_mvt_reason,
              smrl.name                                   AS movement_reason,
              p.id_product                                AS product_id,
              COALESCE(pa.id_product_attribute, 0)        AS combination_id,
              IF(
                  LENGTH(COALESCE(pa.reference, "")) = 0,
                  IF(LENGTH(TRIM(p.reference)) > 0, p.reference, "N/A"),
                  CONCAT(p.reference, " ", pa.reference)
              )                                           AS product_reference,
              pl.name                                     AS product_name,
              p.id_supplier                               AS supplier_id,
              COALESCE(s.name, "N/A")                     AS supplier_name,
              COALESCE(ic.id_image, 0)                    AS product_cover_id,
              (SELECT GROUP_CONCAT(
                        DISTINCT CONCAT(agl.name, " - ", al.name)
                        SEPARATOR ", "
                    )
                    FROM ps_product_attribute pa2
                    JOIN ps_product_attribute_combination pac ON (
                        pac.id_product_attribute = pa2.id_product_attribute
                    )
                    JOIN ps_attribute a ON (
                        a.id_attribute = pac.id_attribute
                    )
                    JOIN ps_attribute_lang al ON (
                        a.id_attribute = al.id_attribute
                        AND al.id_lang = 1
                    )
                    JOIN ps_attribute_group ag ON (
                        ag.id_attribute_group = a.id_attribute_group
                    )
                    JOIN ps_attribute_group_lang agl ON (
                        ag.id_attribute_group = agl.id_attribute_group
                        AND agl.id_lang = 1
                    )
                    WHERE pa2.id_product=p.id_product AND pa2.id_product_attribute=pa.id_product_attribute)
                    AS combination_name,
              (SELECT GROUP_CONCAT(
                        DISTINCT CONCAT(agl.name)
                        SEPARATOR ", "
                    )
                    FROM ps_product_attribute pa2
                    JOIN ps_product_attribute_combination pac ON (
                        pac.id_product_attribute = pa2.id_product_attribute
                    )
                    JOIN ps_attribute a ON (
                        a.id_attribute = pac.id_attribute
                    )
                    JOIN ps_attribute_group ag ON (
                        ag.id_attribute_group = a.id_attribute_group
                    )
                    JOIN ps_attribute_group_lang agl ON (
                        ag.id_attribute_group = agl.id_attribute_group
                        AND agl.id_lang = 1
                    )
                    WHERE pa2.id_product=p.id_product AND pa2.id_product_attribute=pa.id_product_attribute)
                    AS attribute_name
           FROM ps_stock_mvt sm
            INNER JOIN ps_stock_mvt_reason_lang smrl ON (
              smrl.id_stock_mvt_reason = sm.id_stock_mvt_reason
              AND smrl.id_lang = 1)
            INNER JOIN ps_stock_available sa ON (sa.id_stock_available = sm.id_stock)
            LEFT JOIN ps_product p ON (p.id_product = sa.id_product)
            LEFT JOIN ps_product_attribute pa ON (pa.id_product_attribute = sa.id_product_attribute)
            LEFT JOIN ps_product_lang pl ON (
                p.id_product = pl.id_product AND
                pl.id_lang = 1
            )
            INNER JOIN ps_product_shop ps ON (
                p.id_product = ps.id_product AND
                ps.id_shop = 1
            )
            LEFT JOIN ps_image ic ON (
                p.id_product = ic.id_product AND
                ic.cover = 1
            )
            LEFT JOIN ps_image_shop ims ON (
                p.id_product = ims.id_product AND
                ic.id_image  = ims.id_image AND
                ims.id_shop = 1 AND
                ims.cover = 1
            )
            LEFT JOIN ps_supplier s ON (p.id_supplier = s.id_supplier)
            LEFT JOIN ps_product_attribute_combination pac ON (
                pac.id_product_attribute = pa.id_product_attribute
            )
            LEFT JOIN ps_product_attribute_shop pas ON (
                pas.id_product = pa.id_product AND
                pas.id_product_attribute = pa.id_product_attribute AND
                pas.id_shop = 1
            )
            WHERE
            sa.id_shop = 1 AND
            sa.id_shop_group = 0 AND
            sa.id_product_attribute = COALESCE(pa.id_product_attribute, 0)
            
            GROUP BY sm.id_stock_mvt
            HAVING 1 
            ORDER BY date_add DESC 
        

 

×
×
  • Create New...