Joe Posted February 28, 2018 Share Posted February 28, 2018 Hello everyone ! I want to change a quantity of product when quantity <= 0. I don't know where change the code php.. I konw the files (Admin Product Controller) but i try and is not working... I want to change this input automatically... I try to change the file (products.js in js/admin ) and the file (controller/adminproductcontroller) but is not working :s.. If people have idea ! Thanks Link to comment Share on other sites More sharing options...
Joe Posted March 2, 2018 Author Share Posted March 2, 2018 up Link to comment Share on other sites More sharing options...
mkinternet Posted March 5, 2018 Share Posted March 5, 2018 If you want to control product quantity after order was placed you have to override classes/stock/StockAvailable::updateQuantity 1 Link to comment Share on other sites More sharing options...
Joe Posted March 5, 2018 Author Share Posted March 5, 2018 (edited) Thanks man !! But what's override ? :/ Sorry i know code php etc. But a i don't konw prestashop code >.< ! it's here ? : public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null) { if (!Validate::isUnsignedId($id_product)) { return false; } $product = new Product((int)$id_product); if (!Validate::isLoadedObject($product)) { return false; } $stockManager = Adapter_ServiceLocator::get('Core_Business_Stock_StockManager'); $stockManager->updateQuantity($product, $id_product_attribute, $delta_quantity, $id_shop = null); return true; } Edited March 5, 2018 by Joe (see edit history) Link to comment Share on other sites More sharing options...
mkinternet Posted March 5, 2018 Share Posted March 5, 2018 $product_quantity = StockAvailable::getQuantityAvailableByProduct($id_product); if( ($product_quantity+$delta_quantity)>=0){ $stockManager = Adapter_ServiceLocator::get('Core_Business_Stock_StockManager'); $stockManager->updateQuantity($product, $id_product_attribute, $delta_quantity, $id_shop = null); } Somenthing like this. I didnt check it. Link to comment Share on other sites More sharing options...
Joe Posted March 6, 2018 Author Share Posted March 6, 2018 14 hours ago, mkinternet said: $product_quantity = StockAvailable::getQuantityAvailableByProduct($id_product); if( ($product_quantity+$delta_quantity)>=0){ $stockManager = Adapter_ServiceLocator::get('Core_Business_Stock_StockManager'); $stockManager->updateQuantity($product, $id_product_attribute, $delta_quantity, $id_shop = null); } Somenthing like this. I didnt check it. Thanks man !! 14 hours ago, mkinternet said: Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now