8000 inventory_source_item sku not updating when user updates product SKU · Issue #39335 · magento/magento2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
inventory_source_item sku not updating when user updates product SKU #39335
Closed
@Swannyj

Description

@Swannyj

Preconditions and environment

  • Magento version: 2.4.6-p6

Steps to reproduce

  1. Create a Product in the CMS. Add a SKU (for example 4201503002/size38/bleu fonce) and assign a stock source against it

  2. Save the Product

  3. Change the Product SKU (for example 4201503002/size38/bleu foncé)

  4. Save

  5. Navigate to the storefront

  6. Add this product to your basket and checkout

  7. In the CMS go to Sales/Orders and find the order

  8. You should see an order item with the updated sku (4201503002/size38/bleu foncé)

  9. 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 [] []

inventory_source_item table
image

catalog_product_entity table
image


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

Metadata

Metadata

Assignees

Labels

Area: OrderComponent: ShippingIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.6-p6Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0