Jump to content

Change quantity of product automatically


Joe

Recommended Posts

Hello everyone :D !

 

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... image.thumb.png.17cd946c8ba4512c71c7438657cc9323.png

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 :D ! Thanks

Link to comment
Share on other sites

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 by Joe (see edit history)
Link to comment
Share on other sites

$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

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 !! :D

 

14 hours ago, mkinternet said:

 

 

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