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

quantity_and_stock_status display result is wrong in product listing(Grid). #16209

Closed
karangar opened this issue Jun 18, 2018 · 13 comments
Closed
Labels
Area: Catalog Component: Catalog Event: squashtoberfest 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 Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@karangar
Copy link

Preconditions

I have added product attribute(quantity_and_stock_status) column in catalog product admin grid for the filtering the "In Stock" and "Out of Stock" products list.

1.Magento 2.2.4

Steps to reproduce

  1. Go to Magento 2 admin => Stores => Attributes => Product => Search attribute code "quantity_and_stock_status".
  2. Change "Advanced Attribute Properties" settings Scope => "Store view/Global", "Add to Column Options" to "Yes" and set "Use in Filter Options" to "Yes".
  3. Now product attribute Quantity(quantity_and_stock_status) will be visible in to the catalog product settings Columns section and checked it to yes.
  4. Make Product "Out of Stock" and Save it Flush/Refresh the Cache And also re-indexing it.
  5. Check quantity_and_stock_status display result in product Grid and edit this product and check stock status.

Expected result

  1. quantity_and_stock_status display result "Out of stock" if product is Stock status "Out of stock" in product Grid.

Actual result

  1. Check product grid Screen shot.
    screenshot-192 168 10 217-2018 06 18-15-48-30
  2. check same product edit page into product is out stock
    screenshot-192 168 10 217-2018 06 18-15-50-12
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 18, 2018
@karangar
Copy link
Author

This issue is already generated in #15201

@karangar karangar changed the title quantity_and_stock_status display result is not wrong on product listing(Grid). quantity_and_stock_status display result is wrong on product listing(Grid). Jun 18, 2018
@karangar karangar changed the title quantity_and_stock_status display result is wrong on product listing(Grid). quantity_and_stock_status display result is wrong in product listing(Grid). Jun 18, 2018
@kkrieger85 kkrieger85 added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Jun 19, 2018
@karangar
Copy link
Author

Any update ?

@ghost ghost self-assigned this Jul 5, 2018
@ghost ghost added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Jul 5, 2018
@ghost
Copy link

ghost commented Jul 5, 2018

Hello @karangar, thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost removed their assignment Jul 6, 2018
@sylvainraye
Copy link
Contributor

I confirm the issue. We have the same by a merchant. Investigation in progress on our side for a fix

@sylvainraye
Copy link
Contributor

Here is a statement of my first analyzes regarding "quantity_and_stock_status" attribute:

  1. the attribute is not supposed to be used in grid, however that's the only way to have the column "Quantity" (in fact "Stock") and view "In Stock"/"Out of Stock" in grid view
  2. the attribute is in fact used internally to set an array of "is_in_stock" and "qty" to be used in product edit form. That's why it's not supposed to be used in grid. Why ? No clue at the moment
  3. in Standard in can't be used as a filter because the value "1" is always saved in the database because that's the default value when the attribute is missing while saving a product due to an observer which remove it before save event \Magento\CatalogInventory\Observer\ProcessInventoryDataObserver
  4. The only way to fix that easily looks like to change the logic of the observer "\Magento\CatalogInventory\Observer\ProcessInventoryDataObserver" and set a 0 or 1 value to the attribute if the product is in stock

I give a try to see if it's working

@vteofilo
Copy link

vteofilo commented Sep 1, 2018

This worked for me:

As I have a specific function to update inventory that extends \Magento\CatalogInventory\Model\StockRegistry, I called inside it, but if you use Magento itself you should create a plugin to be called after you have run the function Magento\CatalogInventory\Model\StockRegistry::updateStockItemBySku(). At each inventory update, this function updates the is_in_stock status of the parent product by adding the items of the child products:

`

public function syncProductStock(int $productId)
{
    $product = $this->productFactory->create();
    $product->load($productId);

    $productParent= $this->productFactory->create();
    $productParent->load(
        $this->objectManager->get(\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::class)
            ->getParentIdsByChild($productId)
    );

    $childrenIds = array_values(
        $this->objectManager->get(\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::class)
            ->getChildrenIds($productParent->getId())[0]
    );
    $sumQuantity = 0;
    foreach ($childrenIds as $childrenId) {
        $productChildren = $this->productFactory->create();
        $productChildren->load($childrenId);
        $sumQuantity += $this->objectManager->get(\Magento\CatalogInventory\Model\StockRegistry::class)
            ->getStockItem($childrenId)->getQty();
    }

    $isInStock = $sumQuantity > 0 ? 1 : 0;
    $product->addAttributeUpdate('quantity_and_stock_status', $this->getStockItem($productId)->getIsInStock(), $product->getStoreId());
    $productParent->addAttributeUpdate('quantity_and_stock_status', $isInStock, $product->getStoreId());

    $parentStockItem = $this->getStockItem($productParent->getId());
    $parentStockItem->setIsInStock($isInStock);
    $this->stockItemRepository->save($parentStockItem);
}`

Hope this helps! Thank you!

@krotus
Copy link

krotus commented Oct 8, 2018

#SQUASHTOBERFEST

@magento-engcom-team
Copy link
Contributor

@krotus thank you for joining. Please accept team invitation here and self-assign the issue.

@magento-engcom-team
Copy link
Contributor

Hi @krotus. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

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

  • 2. Verify that the issue is reproducible on 2.3-develop branch

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

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@XxXgeoXxX XxXgeoXxX self-assigned this Nov 2, 2018
@magento-engcom-team
Copy link
Contributor

Hi @XxXgeoXxX. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

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

  • 2. Verify that the issue is reproducible on 2.3-develop branch

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

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@magento-engcom-team magento-engcom-team added this to Ready for Dev in Community Backlog Mar 24, 2020
@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@sidolov sidolov added this to Ready for Development in Low Priority Backlog Sep 24, 2020
@ghost ghost removed this from Ready for Dev in Community Backlog Oct 20, 2020
@ghost ghost removed this from Ready for Development in Low Priority Backlog Oct 20, 2020
@ghost ghost removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@magento-engcom-team magento-engcom-team added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Nov 30, 2020
@m2-community-project m2-community-project bot added this to Ready for Development in High Priority Backlog Nov 30, 2020
@engcom-Alfa engcom-Alfa added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Catalog Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 25, 2021
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-1031 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 25, 2021

✅ Confirmed by @engcom-Alfa. Thank you for verifying the issue.
Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Bravo
Copy link
Contributor

HI @karangar,

Thanks for your reporting and collaboration.

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

Screenshot 2024-05-06 at 12 11 13 Screenshot 2024-05-06 at 12 11 46

Hence We are closing this issue.

Thanks.

@m2-community-project m2-community-project bot moved this from Ready for Development to Done in High Priority Backlog May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Component: Catalog Event: squashtoberfest 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 Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Development

No branches or pull requests