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.48k stars 9.29k forks source link

Promotions Rule not working with quantity_and_stock_status attribute #35627

Open Dhaval410 opened 2 years ago

Dhaval410 commented 2 years ago

Preconditions and environment

Steps to reproduce

  1. Go to Stores menu -> select Product in Attributes. And search “quantity_and_stock_status” attribute and edit it.

  2. Open Storefront Properties tab and Select yes for Use for Promo Rule Conditions.

quantity_and_stock_status _ Product Attributes _ Attributes _ Stores _ Magento Admin

  1. Go to Marketing menu -> select Catalog Price Rule in Promotions. And create one rule by adding condition Quantity is in stock as in the below image.

Test 01 _ Catalog Price Rule _ Promotions _ Marketing _ Magento Admin

  1. After creating above rule Save And Apply the rule.

  2. Make cache flush / clean and reindex it.

  3. Go to store frontend and open the product which is in stock and check the rule applied or not.

Expected result

  1. In the store frontend in the product page product should discounted as per the Rule.

Normal price

Actual result

  1. In the store frontend in the product page product is not discounted as per the Rule. It seems rule not applied.

Normal price with out discount

Additional information

As we found that, magento is uses different way to use for the attribute Quantity (quantity_and_stock_status) as compared to the other attributes.

For the Quantity attribute magento use the after load plugin. Here is the class where that plugin exists. vendor/magento/module-catalog/Model/Product/Attribute/Backend/Stock.php In this class, There is one function afterLoad() on line 44. In this function, they set data in the array form with the is_in_stock and qty key from the stockItem object. And magento uses this data.

stock-data-after_load

But, when we use this Quantity attribute in Rules, Sorting and Search etc. Then, it is not using that array. But, it use the default magento attribute way as same as other attributes. Like, they use the value of the Quantity attribute for the products from the the “_catalog_product_entityint” table. But, in that table for that attribute (attribute code: quantity_and_stock_status and attribute id: 115) there are no records.

catalog_product_entity_int-table

For example, I have created one product, but for the "quantity_and_stock_status" attribute, there is no record in the table as in the above image.

It bit strange that when we use sample data and the API for the products import, then it insert the records in the “_catalog_product_entityint” table for Quantity attribute. But when we create manually then it doesn't insert the records in that table.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @Dhaval410. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

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:

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

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

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

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

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. 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-November commented 2 years ago

Verified the issue on Magento 2.4-develop branch and the issue is reproducible when condition "Quantity is in stock" is added to the catalog price rule. Catalog Price rule is not getting applied on any of the products in stock. Issue is not reproducible if the condition "Quantity is in stock" is removed from catalog Price Rule. Promo rule is applied as expected.

github-jira-sync-bot commented 2 years ago

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

m2-assistant[bot] commented 2 years ago

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

glanujnehra commented 7 months ago

Internal team is working on the issue