Magento2: Stock status not coming back after qty update

Created on 20 Feb 2017  路  15Comments  路  Source: magento/magento2

Preconditions

  1. Magento Version: 2.1.3
  2. PHP: 7.0.14-2a
  3. MySQL: 5.6.33
  4. Automatically Return Credit Memo Item to Stock (this is what I try to achieve) - ON (Stores - Configuration - Catalog - Inventory)

Steps to reproduce

  1. Set simple product qty to zero (and you will see it will turns to Out of Stock) & hit Save
  2. Set same product qty to 1 and save

Expected result

After insert qty more than zero - changed new stock status In Stock

Actual result

Still Out of Stock

Fixed in 2.2.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x bug report

Most helpful comment

It looks like the specific code is right here:

https://github.com/magento/magento2/blob/9c14af7a97bcf338662de365d2613c7ca9dbf8c6/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php#L165-L167

I think the easiest way to fix is if we added another if statement below like:

if ($stockItem->getManageStock() && $isInStock && !$stockItem->getIsInStock()) { 
    $stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
}

All 15 comments

Same issue when with a credit memo you return to stock a product correclty went out of stock with qty 0.
It increases its qty, but it remains in out of stock state, so i have to cron a script all night that put in stock all products out of stock with qty > 0.
Absolutly crazy.

@oroskodias Thanks for reporting this issue, internal ticket was created MAGETWO-70370.

It looks like the specific code is right here:

https://github.com/magento/magento2/blob/9c14af7a97bcf338662de365d2613c7ca9dbf8c6/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php#L165-L167

I think the easiest way to fix is if we added another if statement below like:

if ($stockItem->getManageStock() && $isInStock && !$stockItem->getIsInStock()) { 
    $stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
}

Willing to submit a PR, but curious if anyone has any better ideas.

@oroskodias, thank you for your report.
We've created internal ticket(s) MAGETWO-70370 to track progress on the issue.

In this way, are you never going to have a product with qty positive and out of stock?

Working on this.

Hi @oroskodias. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#955 by @RomaKis in 2.2-develop branch
Related commit(s):

  • 15928fbd8c42590187f0613f889cc27d6afabe0d
  • 188ecb36ed86fbd7df58a4826040078eefaad2c6
  • 546a0bb015e977d5ca9d3505d2bcba4a413d3c15
  • 4b585d48857f89abfb9bc4d6fe381ea6dbe3ac85
  • a9a3c197cbdb4d2e8f602b50e6ba3c147a8be061

The fix will be available with the upcoming patch release.

Hi @magento-team
This issue was really fixed, but in the 2.3 the fix has gone, and now it doesn't work again.
When will this issue fix?

Hi @magento-team,

I am using Magento 2.2.4, but still, the issue is no fixed

Same issue in 2.3.2

I have the same issue in 2.3.2 are you going to provide a fix?

Hi
I am using Magento 2.3.4
Details Issues :

When changing the quantity of a product from any number to 0, the state is automatically changed to Out of Stock upon saving. However, when changing an out of stock product to any number and saving, the product is still listed as Out of Stock.

Steps to reproduce

Access an active, out of stock product through Products > Catalog
Change Quantity to any number and save
Expected result

The product鈥檚 state is automatically changed to In Stock

Actual result

The product is still listed as Out of Stock despite the quantity change.

One must manually remember to also set In Stock which is a inconvenient step and not working as one would expect because the other way the state is changed

any info about this issue?? I have the same problem in Magento ver. 2.3.3

I am also facing the same issue in Magento 2.3.4. Please let me know if there is any solution.

Was this page helpful?
0 / 5 - 0 ratings