Prestashop: Stock unstable when editing a product and having a sale in the meantime

Created on 29 May 2020  路  15Comments  路  Source: PrestaShop/PrestaShop

Describe the bug

Stock is updated when product is modified and active

Expected behavior

Product description and combinations should be in different tabs

Specs

A warning will be displayed on the top of the input:
"We advise you to modify the quantity directly in the [1]Catalog > Stocks[/1] section of the back office to avoid stock imbalance." in Admin.Notifications.Warning.
The link redirects to the stock page on another tab with the product displayed/loaded.

In the basic tab, change the input into a text (semibold) to only display the quantity

Steps to Reproduce

Steps to reproduce the behavior:

1.Create a product and activate it, add combinations and stock to the product(For instance, 10 units). Save and leave page open

  1. Go to shop and create an order with the product. (-1)
  2. Keep doing modifications and click save
    Now the stock is broken since it's still 10, to see it more clearly go to stock movement where the flow is as following - > +10 -> -1 -> +1

A solution to avoid this would be to turn off the product while making modifications, such as SEO, images, descriptions...etc but that would make the product unavailable while you are working and losing sales.
Keep in mind that this scenario only happens when you are having a strong flow of sales.

Additional information

  • PrestaShop version: 1.7.6.5
  • PHP version: 7.2
1.7.6.5 BO Improvement Order PM 鉁旓笍 Products Stocks To Do

All 15 comments

Thanks for opening this issue! We will help you to keep its state consistent

Hi @ChineseNorris ,
I managed to reproduce the issue in both PS 1.7.6.5 and PS 1.7.7.0 following your steps.

I will ping our product team to get their point of view on your request.
Please stay tuned !
Thanks!

Hi @PrestaShop/prestashop-product-team ,

@ChineseNorris is having stock issues when editing a product and having a sale during the same time. His request is to turn off the product while doing changes.

Is this something that can be done ?

Thanks!

Hello @florine2623 and thank you for taking the time to replicate the issue, let's see if we can add a solution or merge for this issue.

@khouloudbelguith can you please take a look and see if someone from the core team can take a look?

Thanks

Thank you very much @ChineseNorris @florine2623

The form for editing a product comes with the current values from database.
When merchant is on this form, a customer might purchase in that moment of time, changing values in the database. To keep the form and database in sync, maybe a periodic automatic refresh of the stale form can fix the issue.

Or maybe a whole feature of real-time (or pseudo- realtime) communication. AFAIK, HTML5 Websockets or AJAX polling/long polling can dot it. IMHO, the first one is overkill, the second is over engineering, and the best one is not to implement it at all.

Instead, clearly tell merchants in a red notice to refresh the product edit page whenever it stays stale for a period of time, before they save a new edit.

If a merchant have a lot of sales that he can't even have a moment of peace for editing his product, then I think he should invest some time creating a module just for stock update and remove this latter from product form completely ( I think very possible now with a Twig override under 1.7).

As you said, Product team and Dev team insights will make it more clear.

ping @MatShir this is an interesting insight from @ChineseNorris and @arouiadib.
Could we think about something to improve this system while working on the product page ?

Thanks for your time @arouiadib for contributing on the community.

In my honest opinion, I think the first option you mentioned is just too overkill, the second one is over engineering too but think that in this way, the stock feature is something that a lot of merchants are interested, not to mention that this is crucial for their business if they want it to grow.

The approach of telling merchants a red notice is not a bad idea but I think that's a quickfix and you'll end up with bigger problems in the future.

This scenario is possible not even in a high workflow shop, since this issue can be produced with no flow of sales at all. In the worst scenario case, you can make just one sale while you are editing the same product, and you will face this stock issue as well. I think this matter is really sensitive and it's being overlooked.

A real solution should be a separate tab for stock, since there is a new tab of stocks in the newer versions.
In this case the best approach at this moment would be:

  1. Remove stock quantities from product page
  2. Edit stock directly from catalog-> stock

A nicer solution and no issue causer with stocks would be creating "supplier orders" system, since every merchant is purchasing their stock from their supplier.
This way the stock managing would be easier and the steps would be:
1.Create product with attributes

  1. Create "supplier order" with stocks

This way the following re-stocks won't interfere with the current stock.
Most of the merchants would love the second solution, since it's the normal workflow.

Regards

For the product page migration,@zuk3975 correct me if I'm wrong, the field will only be updated if the value has been changed.
We won't be able to make a whole system for the 1.7.8, but you definitely make a point.

@MatShir as long as it's implemented, I don't think there is a problem. The problem would be if this matter is ignored and prestashop keeps developing.

Thanks

For the product page migration,@zuk3975 correct me if I'm wrong, the field will only be updated if the value has been changed.

yes, in theory we are making commands, which can work as partial update, however we should take a note to check this when implementing forms (by following previous implemetations it will not work by default).

Since the field could be used by modules, we will put a warning message on the top of the field with a link redirecting to the stock page. We might remove the short ut input in the basic tab.

The core problem will be solved since the quantity value won't be saved if the merchant does not touch it. But a nice warning, we bring awareness to the merchant. @Junebyun Let's find the perfect wording!

Thanks @MatShir , I think this is a nice solution and can work as well

@MatShir What do you think of the following wording? "Be careful : quantities should be modified directly from the [1]Catalog > Stocks[/1] section of the back office rather than from this Product page in order to avoid stock imbalance. "

@LouiseBonnard

@MatShir I modified a bit the wording following @LouiseBonnard 's good advice 馃憤

"We advise you to modify the quantity directly in the [1]Catalog > Stocks[/1] section of the back office to avoid stock imbalance." in Admin.Notifications.Warning.
The link redirects to the stock page on another tab with the product displayed/loaded.

Thanks @Julievrz, looks good!

Was this page helpful?
0 / 5 - 0 ratings