Description
Preconditions and environment
- Magento version: 2.4.6-p4
Steps to reproduce
- Create at least one additional custom stock source
Source Name | Source Code |
---|---|
Warehouse Alpha | warehouse_alpha |
Warehouse Bravo | warehouse_bravo |
- Create a new stock associated to the website
- Associate the custom sources to the new stock
- Utilizing the API, create an inventory source item
curl 'https://magento-opensource.test/rest/default/V1/inventory/source-items' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <auth_token>' \
--data '{
"sourceItems": [
{
"sku": "24-MB01",
"source_code": "Warehouse_Bravo",
"quantity": 5000,
"status": 1
}
]
}
'
- Log in to the admin panel
- Navigate to the catalog products grid
Expected result
The product grid renders
Actual result
An error is displayed:
Warning: Undefined array key "Warehouse_Bravo" in /var/www/html/vendor/magento/module-inventory-catalog-admin-ui/Ui/DataProvider/Product/Listing/Modifier/QuantityPerSource.php on line 142
Additional information
This appears to be because the data in the source_code
column is collated to be case insensitive (utf8mb3_general_ci
). The data provider for the admin grid loads the source items for the product into an array, keyed by the source_code
value. While iterating over the product's source items it looks for the key in the array; however, the source item's source_code
value doesn't match the source_code
for the inventory source.
The workaround to this is to either delete the offending records, or override the private function to force the comparison to be done in a case-insensitive manner.
Release note
Fixes an issue where using the inventory/source-items API an incorrectly cased source_code value can cause the admin grid to fail to render with error Warning: Undefined array key "<source code>"
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”.