Description
Preconditions and environment
- Magento version : 2.4.6-p8
- When sending products via asyn bulk api where there are products with missing attributes, they will bypass the validation and empty products are created in Magento.
- This happends when there is a product with a non default attribute set which already exists and after this product a new product with default attribute set is handled. This attribute set Id is not loaded, only the former attributeset. Then when checking if attributes are applicable it is not passed the isInSet and the attribute is not validated. And the product can be created even with missing attributes.
files:
- vendor/magento/module-catalog/Model/ResourceModel/AbstractResource.php line 86
- vendor/magento/module-eav/Model/Entity/Attribute/AbstractAttribute.php line 745
- vendor/magento/module-catalog/Model/ProductRepository.php line 579
- vendor/magento/module-eav/Model/Entity/Attribute/Set.php line 311
Steps to reproduce
Send 2 product via async/bulk/V1/products: for example:
[ { "product": { "sku": "existing sku", "type_id": "simple", "created_at": null, "updated_at": null, "custom_attributes": [ { "attribute_code": "cost", "value": "201.96" } ] } }, { "product": { "sku": "new sku", "type_id": "simple", "created_at": null, "updated_at": null, "custom_attributes": [ { "attribute_code": "cost", "value": "28.65" } ] } } ]
The existing product needs to have an custom attribute set. The second will fallback on the default. When the first is handled the custom attribute set is loaded by $productAttributes = $product->getAttributes(); in the ProductRepository after the validation is done. Then when the 2nd product is handled the attribute set which is diffirent from the first one, is not loaded and when checking if the attribute set id is on the attribute it fails and then the attribute is not applicable and is not handled by the validation.
Expected result
Products with missing data for required attributes are not created
Actual result
products with missing data are being created
Additional information
No response
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”.