Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still shows Add to cart even if salable quantity is 0 #33819

Closed
5 tasks
chequille opened this issue Aug 17, 2021 · 69 comments
Closed
5 tasks

Still shows Add to cart even if salable quantity is 0 #33819

chequille opened this issue Aug 17, 2021 · 69 comments
Labels
Area: Product Component: Stock Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@chequille
Copy link

chequille commented Aug 17, 2021

Preconditions (*)

  1. Magento 2.4.3

Steps to reproduce (*)

  1. Set "Display out of stock products" to Yes
  2. Place order with a product so salable qty is going to 0

Expected result (*)

  1. After placing order, add to cart should not be displayed anymore for product qith salable quantity 0

Actual result (*)

  1. Add to cart button is still shown

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Aug 17, 2021

Hi @chequille. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@chequille
Copy link
Author

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @chequille. Thank you for your request. I'm working on Magento instance for you.

@engcom-Echo engcom-Echo self-assigned this Aug 17, 2021
@m2-assistant
Copy link

m2-assistant bot commented Aug 17, 2021

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@chequille
Copy link
Author

Unbelievable, products where salable qty is 0 are still showing ADD TO CART button.
I reproduced this in the Magento instance.
Release notes of 2.4.3 says this is fixed, but it looks like it is not fixed.

What are you going to do on this?

@engcom-Echo
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Echo. Thank you for your request. I'm working on Magento instance for you.

@engcom-Echo
Copy link
Contributor

Hi @chequille
We tried to reproduce this issue on 2.4-develop & was unable to do so.
Here are the Steps we followed,

  1. Stores > Configuration > Catalog > Inventory > Stock Options. Display Out of Stock Products: Choose Yes to enable displaying Magento out of stock products in the frontend
  2. Create / Edit a product such that its quantity is 1 & place an order for the product from frontend such that saleable quantity will become 0.

Screenshot 2021-08-17 at 22 07 15

Screenshot 2021-08-17 at 22 08 29

3. Once the order was placed , the product was displayed OUT OF STOCK on Search & Product Page.

Screenshot 2021-08-17 at 22 08 52

So kindly recheck this issue on Magento 2.4-develop branch and if the issue is still reproducible, please provide more details or additional/missing steps regarding the same.
Thank you.

@engcom-Echo engcom-Echo added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response labels Aug 17, 2021
@m2-community-project m2-community-project bot removed the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Aug 17, 2021
@engcom-Echo engcom-Echo added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch and removed Issue: ready for confirmation labels Aug 17, 2021
@chequille
Copy link
Author

chequille commented Aug 17, 2021

Made another try with "Impulse duffle"
grafik
Bought 100 pieces for product going to salable 0

grafik
Going to the product page after order was placed.
And Add to cart button is there as ou see:
grafik
Sorry, but I am not stupid and I did the same as you did. Do not understand why Add to Cart button is not there anymore on your try.

Maybe the only diffrence you made is, that you first changed the available qty to 1 and than you made the order for 1.

I will try this now as well.

@chequille
Copy link
Author

chequille commented Aug 17, 2021

Hi @engcom-Echo,

now I found the problem. As I mentioned before, you changed the inventory from 100 to 1 which I did not. I bought the 100 pieces. I tried now to first edit the prodcut and save it and than making an order for 100 pieces. When I do so, add to cart button is not shown anymore.

But this means, that the saving of a product does change something somewhere in the database.
Of course, I did not do this on my site as I use a copy of my 2.3.x database (of course changing url for the site) and do a magento setup:upgrade which works so far as it should.
If this is really the case as I described it I have to edit and save all products at least once.

I will try this now and will report my results.

Regards,
Jürgen

@chequille
Copy link
Author

Hi @engcom-Echo
unfortunately, on my site even the editing and saving a product again does not change something. On my site add to cart is shown.

but something must be wrong in any case, Try not to change the product and place an order with the quantity which is in the database of a fresh magento instance (I think they are all set to 100) and you will see, that Add to cart is shown.

What else could it be? As I said already in Magento 2.3.x everything worked fine. Therefore, I do not think that some of my extensions causes this behaviour.

Does somebody have any idea?
Regards
Jürgen

@engcom-Echo
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Echo. Thank you for your request. I'm working on Magento instance for you.

@KM-HM
Copy link

KM-HM commented Aug 18, 2021

I have a magento 2.4.2 now updated to Magento 2.4.3 affected by the same issue.

Got a simple product with
qty 1
salable qty 0
reservation for qty 1 form an order

Add to cart button still showing after reindex, cache.

All salabe check functions report the product is salable and in stock which is not correct.
This happens in a production Magento instance where all order come in via checkout.

@chequille
Copy link
Author

Oh, somebody else also has this problem. In some point of view I am very happy about this :-) I am not the only one.

In the meantime I disabled all third party modules which I am using in my setup, but still wrong!!!!

@KM-HM
Copy link

KM-HM commented Aug 18, 2021

@chequille Did you do a data migration from m1 ?

This issue does not happen with all of the products for me.

@chequille
Copy link
Author

chequille commented Aug 18, 2021

@kemexyz
No, I did not data migration.
I am using database dump from my working 2.3.x installation and change of course the urls in core_config_data table and run magento setup:upgrade

This works pretty good, but maybe not regarding this issue.
What I tried is to make a new product and did have a look with this new product. On my site, it still have the same behaviour.

So, no idea whats happening here.

In the meantime, I made my own block class which is using GetSalableQuantityDataBySku $getSalableQuantityDataBySku class to check if salable quantity is 0 or not.
The only disadvantage doing this is, that I have to make my own block not cachable, because otherwise my function to get the value for salable qty is not the correct one.
I do not see a real performance change, so if the guys here at magento will not find a solution, I will use it.
Unfortunately, there is another problem with swatches of configurable products, which are not crossed if salable qty is 0. There is as well another ticket from my site regarding this.
DId not find a solution for that yet on my own.
Regards
Jürgen

@chequille
Copy link
Author

@kemexyz
By the way, I remember now, that I did a data migration when I switch from M1 to M2 last year in June.
Do you think this can be a problem?

@tgreeve
Copy link

tgreeve commented Dec 21, 2021

@engcom-Echo @engcom-November @chequille

I found a reliable way to reproduce this issue in a fresh installed magento version 2.4.3-p1.

There should be a magento process listening to queue "inventory.reservations.updateSalabilityStatus" to mark the product out-of-stock in storefront (storefront-out-of-stock). When the process is running, the product will be marked as out-of-stock automatically when salable quantity reached zero.

You can find the process by top or ps command, the command is

/usr/local/bin/php /var/www/html/bin/magento queue:consumers:start inventory.reservations.updateSalabilityStatus --single-thread --max-messages=10000

Killing the process or the process isn't running, the product will not be marked as out-of-stock.

Hope this help.

@tgreeve
Copy link

tgreeve commented Jan 6, 2022

After code review, storefront product Out of Stock status depends on 2 database columns when using Default Stock.

  1. cataloginventory_stock_item => is_in_stock
  2. cataloginventory_stock_status => stock_status

Number 2 defines the storefront behavior, so whenever this value is set to 0, the storefront will show the product as out of stock.
Number 1 is the DB representation of the product "Stock Status" everyone see on the CMS product configuration page.

So consider the following situation:

When the last item of the product is sold, MQ consumer process the message in queue "inventory.reservations.updateSalabilityStatus" and set Number 2 to 0, thus storefront of the product will show Out of Stock.

(This should be expected scenario in the development team so far.)

But, when Stock indexer is triggered and Number 1 should be 1, Stock indexer will sync the 1 value in Number 1 to Number 2, thus the storefront Out of Stock status will be removed and the product page will show Add to cart icon.

The source code where Stock indexer determines the stock status can be found here.

The Stock indexer can be triggered by Schedule or by a Save action. When the indexer is set to be triggered on Save, there are numerous possibilities that it will roll back the Out of Stock status done by the queue consumer, including a CMS user modifying the product, an extension observer modifying custom attributes......

So basically, the Default Stock indexer ruined the MSI Out of Stock mechanism in a real production Magento setup.

@gjportegies
Copy link

@chequille we're experiencing exactly the same issue on a Magento 2.4.3 instance which is originally migrated from a Magento 1.9.4.3 instance.

@nkajic
Copy link
Member

nkajic commented Feb 15, 2022

Hi @tgreeve thank you for your time describing problem.

I have same problem and see at least 5+ duplicate tickets closed without solution.
How did you manage to solve this? Do you have some patch you can share with rest of us?

Thanks, N

@chequille
Copy link
Author

Hi @nkajic
see my comment above from #33819 (comment)
This helps on my site to get it almost working except of the fact, that I have to make catalog and product page not cachable.

@nkajic
Copy link
Member

nkajic commented Feb 17, 2022

Hi @chequille

I have managed to get it working on 2.3.4-p1 by properly configuring consumers. #35105

But on earlier version there was definetly some other problem involved. Upgrading to 2.4.3-p1 and configuring consumers solved my problem.

I hope it hepls.

Thanks,
N

@chequille
Copy link
Author

Hi @nkajic,
first, thanks for this info.
Ok, I will try this on my local Ubuntu VM.

But if this is the only solution, somebody who does not have ssh acces to the server will never get it working, right?
So far , I am in lucky, as my production site is on a VServer and I have ssh access.

As well I have a question regaring the consumers. You mentioned "properly configuring consumers", but what does it mean properly configured? Which consumers I have to run? Do I have to configure something else somewhere?

Do you have a description of everything you did? If yes, can you share it here?

Would be great.
Best regards,
Chequille

@dphilipps
Copy link

Hi @tgreeve
I agree with your assessment about the indexer ruining the stock status. I raised this very issue in September 2021 #34127 and it was eventually closed as a duplicate issue when it isn't - frustrating! With properly configured consumers products are correctly listed as out of stock when the saleable quantity hits 0 (there was an issue previously preventing this working properly). The separate issues as you mentioned is is the stock status is then reverted when a re-index is run (I would reproduce this by running a CLI reindex).

@shomiadarshlt
Copy link
Contributor

@magento I am working on this.

@shomiadarshlt
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @shomiadarshlt. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@shomiadarshlt
Copy link
Contributor

Hi @chequille ,

I tried replicating the issue in magento 2.4 develop instance but could not replicate .
The steps followed were :

  • Set "Display out of stock products" to Yes in Stores->Configuration->Catalog->Inventory
  • Placed an order with a product so that salable quantity becomes 0
    image
  • There is no "Add to cart" button displayed for the product
    image

Are there any steps that have been missed in replicating the issue ?
Request you to help in this regard .

Thanks
Shomi

@JonathanHelvey
Copy link

JonathanHelvey commented Aug 29, 2023

This is still happening on our store with Magento2.4.4-p5 with simple products. See the images below. I have not reproduced on a Vanilla Magento2 instance, only on my store. Steps to reproduce.

  1. Display out-of-stock items to - YES.
  2. Manage Stock to YES.
  3. No backordes.
  4. Add All inventory of product to Cart.
  5. Checkout with Free Shipping enabled.
  6. Reindex

The Product now shows in admin Quantity of 1 Salable Quantity 0. With the Product/order being in processing and waiting to be shipped. However on the frontend the product is still showing the 'ADD TO CART' button and showing in stock in both frontend and admin.

Screenshot 2023-08-29 at 6 24 00 PM Screenshot 2023-08-29 at 6 24 08 PM

@JonathanHelvey
Copy link

JonathanHelvey commented Sep 12, 2023

I do want to say we added this patch ACSD-47803 - Fixes the issue where out-of-stock configurable product swatches are displayed as available. After adding this patch it seems to have fixed our issue with add to cart button. So not sure if our store is experiencing the same issues as everyone else on this thread, but this patch did fix our issue even with simple products add to cart button when quantity is 0.

@engcom-Bravo
Copy link
Contributor

Hi @chequille,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is no more reproducible.Kindly refer the screenshots.

Screenshot 2024-07-25 at 14 27 41 Screenshot 2024-07-25 at 14 28 01

There is no Add to Cart button for the products having salable quantity 0.

Hence we are closing this issue.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Product Component: Stock Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

No branches or pull requests