magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.45k stars 9.29k forks source link

catalog_product_price is not populated with products when back in stock #37795

Open sebfie opened 1 year ago

sebfie commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Create a Magento 2.4.6-p1 instance
  2. Install sample data
  3. Check core_config_data cataloginventory/options/show_out_of_stock is set to 0 (default value)
  4. Take a product without related/crosssell/upsell products (no catalog_product_link). !!!! IMPORTANT !!!! because this products will trigger an insert in catalog_product_price_cl
  5. Set indexer as scheduled bin/magento indexer:set-mode schedule
  6. Set product from Adminhtml as out_of_stock with a stock of 0 and save => the product is not removed from catalog_product_index_price and catalog_product_price_cl is not populated
  7. Run n98-magerun2 sys:cron:run indexer_update_all_views => catalog_product_index_price are not removed for this product
  8. Remove lines from catalog_product_index_price for this product
  9. Set product with in_stock and a stock of 8 then save it => catalog_product_price_cl is not populated so partial reindex will not fill catalog_product_index_price table
  10. Run n98-magerun2 sys:cron:run indexer_update_all_views => catalog_product_index_price is not filled by this product

Expected result

We expect to fill/remove from catalog_product_index_price when a product switch from out_of_stock and in_stock. The main issue is that there is not trigger to insert the concerning product in catalog_product_price_cl when the cataloginventory_stock_item change

Actual result

Product data are missing/disappear from catalog_product_index_price

Additional information

The issue comes from this commit :

https://github.com/magento/magento2/commit/b3969936251e1a03427cd24c209abb6af3a0ce1b

Triggers are not well created on cataloginventory_stock_item to fill the table catalog_product_price_cl when stock change.

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @sebfie. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

sebfie commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

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

magento-deployment-service[bot] commented 1 year ago

Hi @sebfie, here is your Magento Instance: https://28563f023e0a53d166d47241ae85e176.instances-prod.magento-community.engineering Admin access: https://28563f023e0a53d166d47241ae85e176.instances-prod.magento-community.engineering/admin_e1ca Login: a6d378c2 Password: 80d102304c24

sebfie commented 1 year ago

Hello, can I have a feedback? It seems critical, it's about prices...

alitopaloglu commented 1 year ago

Any update?

m2-assistant[bot] commented 12 months ago

Hi @engcom-Bravo. 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: :point_down:

engcom-Bravo commented 12 months ago

Hi @sebfie,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance.Kindly refer the screenshots.

Steps to reproduce

product out of stock product removed from table product is in stock product is added to the table running default reindex command when product is out of stock

bin/magento indexer:reindex" is doing the work as per expectations(removing product from the table "catalogrule_product_price" when product is out of stock and adding the product in the table when it's in stock again) is there any specific reason to use the "n98-magerun2 sys:cron:run indexer_update_all_views" command.

Could you please let us know if we are missing anything.

Thanks.

sebfie commented 12 months ago

Hello,

thank you for your answer.

!!! I made a terrible mistake writing my issue, the issue is on table catalog_product_index_price and not catalogrule_product_price !!!!

I updated my initial post

engcom-Bravo commented 12 months ago

Hi @sebfie,

Thanks for your update.

We have verified the issue for the table catalog_product_index_price and the issue is not reproducible.

product stock to 0

Screenshot 2023-09-08 at 4 21 07 PM

product removed from table

Screenshot 2023-09-08 at 4 28 02 PM

product in stock

Screenshot 2023-09-08 at 4 37 15 PM

executed n90.magerun2 , product not added

Screenshot 2023-09-08 at 5 31 00 PM

executed default command, it worked

Screenshot 2023-09-08 at 5 32 17 PM

Could you please let us know the default "bin/magento indexer:reindex" is doing the work as per expectations(removing product from the table "catalog_product_index_price" when product is out of stock and adding the product in the table when it's in stock again) .is there any specific reason to use the "n98-magerun2 sys:cron:run indexer_update_all_views" command?

Thanks.

sebfie commented 12 months ago

Hello,

Is your product id 5?

You should not run bin/magento indexer:reindex beetween checks. Just let cron reindex.

So it heppens when :

engcom-Bravo commented 11 months ago

Hi @sebfie,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.The issue is reproducible with partial reindexing,

Screenshot 2023-09-11 at 6 52 42 PM Screenshot 2023-09-11 at 6 54 29 PM Screenshot 2023-09-11 at 7 44 28 PM

Here product id is 2 not disappearing after doing Partial Reindexing.

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 11 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9496 is successfully created for this GitHub issue.

m2-assistant[bot] commented 11 months ago

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

sebfie commented 11 months ago

Thx a lot. I refered the commit I think responsible of that. Take a look :

https://github.com/magento/magento2/commit/b3969936251e1a03427cd24c209abb6af3a0ce1b

nkajic commented 8 months ago

Duplicate of #35616 which was closed unresolved ❤️ with some incredible information about how to reproduce and comment how to fix it https://github.com/magento/magento2/issues/35616#issuecomment-1196320526

sebfie commented 8 months ago

Ok but it should be revolted in develop branch no?

Thank you