Jump to content

How can i see total price of my wharehouse in prestashop 1.7?


Recommended Posts

I would like to know how I can see the total in money of the products I have in stock, including quantities, combinations of all products.
The customer would like to know the total value of the goods available.

SQL QUERY in Catalog-->products (show from prestashop frontend)


Solution (partial):

EDIT: - -

this sql doesn't work, because if i change the quantity it doesn't update the total price!!!




SELECT SQL_CALC_FOUND_ROWS p.`id_product`  AS `id_product`,

SUM(sa.`price`) AS `totalMoney`
FROM  `ps_product` p 
 LEFT JOIN `ps_product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = 1 AND pl.`id_shop` = 1) 
 LEFT JOIN `ps_stock_available` sav ON (sav.`id_product` = p.`id_product` AND sav.`id_product_attribute` = 0 AND sav.id_shop = 1  AND sav.id_shop_group = 0 ) 
 JOIN `ps_product_shop` sa ON (p.`id_product` = sa.`id_product` AND sa.id_shop = 1) 
 LEFT JOIN `ps_category_lang` cl ON (sa.`id_category_default` = cl.`id_category` AND cl.`id_lang` = 1 AND cl.id_shop = 1) 
 LEFT JOIN `ps_category` c ON (c.`id_category` = cl.`id_category`) 
 LEFT JOIN `ps_shop` shop ON (shop.id_shop = 1) 
 LEFT JOIN `ps_image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = 1) 
 LEFT JOIN `ps_image` i ON (i.`id_image` = image_shop.`id_image`) 
 LEFT JOIN `ps_product_download` pd ON (pd.`id_product` = p.`id_product`) 
WHERE (1 AND sav.`quantity`  >=1)
ORDER BY  `id_product` desc



Edited by taradda13 (see edit history)
Link to comment
Share on other sites

  • 8 months later...
Le 20/01/2023 à 12:01 PM, taradda13 a dit :

Any news?

Here are the news :

SELECT SUM(IFNULL(stock.quantity, 0)) nombre_produits, SUM(stock.quantity*IFNULL((
    SELECT AVG(pa_shop.price)
    FROM ps_product_attribute pa
    INNER JOIN ps_product_attribute_shop pa_shop ON (pa.id_product_attribute = pa_shop.id_product_attribute AND pa_shop.id_shop = 1)
    WHERE p.id_product = pa.id_product
    AND pa_shop.price != 0
), p_shop.price)) valeur_vente
FROM ps_product p
INNER JOIN ps_product_shop p_shop ON (p.id_product = p_shop.id_product AND p_shop.id_shop = 1)
INNER JOIN ps_product_lang pl
    ON (p.id_product = pl.id_product AND pl.id_lang = 1 AND pl.id_shop = 1)
LEFT JOIN ps_stock_available stock ON (stock.id_product = p.id_product AND stock.id_product_attribute = 0)
WHERE 1 = 1;

Have a good day 😉

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