Jump to content

Product stock not updated on order edit in BO


Margis

Recommended Posts

Hi,

 

When I edit a client order in BO and change product quantity or add new product to the order very often product stock quantity is not updated in 'Catalog -> Products'.

If I add and then remove one piece of the product via 'Stock -> Stock Management' the stock quantity is recalculated correctly.

 

How can I force recalculation of product stock without adding and removing one piece of a product?

 

What function should I override to get the quantity recalculated automatically?

 

PS 1.5.6.2.

Enable stock management - Yes

Enable advanced-stock management - Yes

I want to use the advanced stock management system for this product. - Yes
Available quantities for current product and its combinations are based on warehouse stock. - Yes

 

Edit: Problem only appears when adding a product to an order. Changing quantity of a product already in the order works fine, stock is correctly updated.

The issue was caused by a buggy function ajaxProcessAddProductOnOrder() in controllers/admin/AdminOrdersController.php.

The bug is fixed in development version 1.7.0.0, see my reply below.

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

It appears, that the solution to this problem is already submitted to PrestaShop github v1.7.0.0 by Ginkosama and Franck Durand on 22 Feb 2016.
 
Here is link to the commit:
[-] BO : Synchronize stock after adding a product via ajax to an order (The product qty wasn't updated correctly after adding a product to an order via ajax.)

 

In short, to fix the issue you need add one line to

controllers/admin/AdminOrdersController.php.

In the function

 ajaxProcessAddProductOnOrder()

after line 

$order->update();

insert line:

StockAvailable::synchronize($product->id);

Latest stable PrestaShop version (1.6.1.8) does not have this fix incorporated, so unless you never need to add a product to a client order via BO, you should add the fix by yourself. To make the fix permanent you should place it not in the original controller but in override:

override/controllers/admin/AdminOrdersController.php
Link to comment
Share on other sites

  • 2 weeks later...

 

It appears, that the solution to this problem is already submitted to PrestaShop github v1.7.0.0 by Ginkosama and Franck Durand on 22 Feb 2016.

 

Here is link to the commit:

[-] BO : Synchronize stock after adding a product via ajax to an order (The product qty wasn't updated correctly after adding a product to an order via ajax.)

 

In short, to fix the issue you need add one line to

controllers/admin/AdminOrdersController.php.

In the function

 ajaxProcessAddProductOnOrder()

after line 

$order->update();

insert line:

StockAvailable::synchronize($product->id);

Latest stable PrestaShop version (1.6.1.8) does not have this fix incorporated, so unless you never need to add a product to a client order via BO, you should add the fix by yourself. To make the fix permanent you should place it not in the original controller but in override:

override/controllers/admin/AdminOrdersController.php

 

 

Works perfect. Thank you so much.

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