Description
Preconditions and environment
- Magento version:
2.4.6-p6
Steps to reproduce
-
Create a Product in the CMS. Add a SKU (for example
4201503002/size38/bleu fonce
) and assign a stock source against it -
Save the Product
-
Change the Product SKU (for example
4201503002/size38/bleu foncé
) -
Save
-
Navigate to the storefront
-
Add this product to your basket and checkout
-
In the CMS go to Sales/Orders and find the order
-
You should see an order item with the updated
sku
(4201503002/size38/bleu foncé
) -
Click 'Ship'
Expected result
The admin user should be able to click ship and progress through the order journey.
Actual result
The user is presented with the following error
Warning: Undefined array key "4201503002/size38/bleu fonce" in /var/www/website/vendor/magento/module-inventory-source-selection-api/Model/Algorithms/Result/GetDefaultSortedSourcesResult.php on line 140
Additional information
Looking through the execute
function in GetDefaultSortedSourcesResult.php
, it seems that the code retrieves a list of items in the order
foreach ($inventoryRequest->getItems() as $item) {
$normalizedSku = $this->normalizeSku($item->getSku());
$itemsTdDeliver[$normalizedSku] = $item->getQty();
}
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info("Items to Deliver: ");
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info(print_r(array_keys($itemsTdDeliver),true));
I can see the below in my debug.log
[2024-11-06T12:12:46.347503+00:00] main.INFO: Items to Deliver: [] []
[2024-11-06T12:12:46.347769+00:00] main.INFO: Array
(
[0] => 4201503002/size38/bleu foncé
)
After this, the code calls the execute
function in GetInStockSourceItemsBySkusAndSortedSource
I have added the below logging in this function:
$items = $this->sourceItemRepository->getList($searchCriteria)->getItems();
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info("Items after source item repo search");
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info(print_r(array_keys($items), true));
which prints the following to my debug.log
[2024-11-06T13:07:08.591215+00:00] main.INFO: Items after source item repo search [] []
[2024-11-06T13:07:08.591596+00:00] main.INFO: Array
(
[0] => 7161324
)
[] []
The above ID returns the following from the database 7161324
and back inside the execute
function in GetDefaultSortedSourcesResult.php
this ID returns the following from the database when it is looping through the $sourceItems
foreach ($sourceItems as $sourceItem) {
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info("Source Item SKU: ");
\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info(print_r($sourceItem->getSku(),true));
[2024-11-06T13:07:08.592511+00:00] main.INFO: Source Item SKU: [] []
[2024-11-06T13:07:08.592965+00:00] main.INFO: 4201503002/Size38/Bleu Fonce [] []
IMPORTANT
The code uses the inventory_source_item
sku
and searches the the variable $itemsTdDeliver
for this sku
however this array conatins the product sku
and so returns the undefined array key
error.
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”.