Jump to content

how to get all out of stocks on a week ago prestashop


Ehsanai

Recommended Posts

I Create these code:

SELECT  DISTINCT 

a.`id_order` ,
od.product_id,
od.product_name ,
s.quantity

FROM  `ps_orders` a 

LEFT JOIN  `ps_order_detail` od ON  (od.`id_order` = a.`id_order`)
LEFT JOIN  `ps_order_state` os  ON  (    os.`id_order_state` = a.`current_state`  )
LEFT JOIN  `ps_order_state_lang` osl  ON  (    os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = 1  )

LEFT JOIN ps_product_lang pl ON (od.`product_id`  = pl.id_product)
LEFT JOIN ps_product_attribute pa ON (od.`product_id` = pa.id_product)
 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)
            
 LEFT JOIN `ps_stock_available` s ON (od.`product_id`  = s.id_product AND (s.id_product_attribute = pa.id_product_attribute OR CASE WHEN pa.id_product_attribute is null THEN s.id_product_attribute = 0 END) )


WHERE 1    AND s.quantity <= 0 AND  a.`id_order` >= '1000' 
ORDER BY a.`id_order`  DESC

But it show the zero quantity for Product that have attributes.

Can you check it?

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