Skip to content

Promotions Rule not working with quantity_and_stock_status attribute #35627

Open
@Dhaval410

Description

@Dhaval410

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.
  • 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”.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions