Description
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
-
Go to Stores menu -> select Product in Attributes. And search “quantity_and_stock_status” attribute and edit it.
-
Open Storefront Properties tab and Select yes for Use for Promo Rule Conditions.
- 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.
-
After creating above rule Save And Apply the rule.
-
Make cache flush / clean and reindex it.
-
Go to store frontend and open the product which is in stock and check the rule applied or not.
Expected result
- In the store frontend in the product page product should discounted as per the Rule.
Actual result
- In the store frontend in the product page product is not discounted as per the Rule. It seems rule not applied.
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.
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.
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”.