magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Promotions Rule not working with quantity_and_stock_status attribute

Open Dhaval410 opened this issue 2 years ago • 6 comments

Preconditions and environment

  • Magento version: 2.4.3-p1
  • Create simple products manually with stock status is in stock and qty greater than 0 from the admin. Don't use sample data. If we use sample data by using this command bin/magento sampledata:deploy, then it will insert the records in the catalog_product_entity_int table with the attribute Quantity (attribute id 115). And we wouldn't be able to reproduced this issue.

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_entity_int” 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_entity_int” 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

  • [ ] 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.
  • [X] 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”.

Dhaval410 avatar Jun 16 '22 13:06 Dhaval410

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

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

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.


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

: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] avatar Jun 16 '22 13:06 m2-assistant[bot]

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:

  • [ ] 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.

m2-assistant[bot] avatar Jun 17 '22 09:06 m2-assistant[bot]

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.

engcom-November avatar Jun 20 '22 15:06 engcom-November

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

github-jira-sync-bot avatar Jul 15 '22 06:07 github-jira-sync-bot

: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.

m2-assistant[bot] avatar Jul 15 '22 06:07 m2-assistant[bot]

Internal team is working on the issue

glanujnehra avatar Feb 23 '24 06:02 glanujnehra