Skip to content

Undefined array key "simple_sku" in GetSkuFromOrderItem plugin when order item options are incomplete #40040

Open
@fvlasie

Description

@fvlasie

Preconditions and environment

Magento ver. 2.4.7-p6

The plugin Magento\InventoryConfigurableProduct\Plugin\Sales\GetSkuFromOrderItem assumes that the 'simple_sku' key is always present in the $orderItem->getProductOptions() array. In some cases (e.g. custom order creation, API orders, or legacy data), this key may be missing, resulting in a PHP warning.

Steps to reproduce

  1. Place or import an order for a configurable product where simple_sku is not set in the order item options.
  2. Trigger any process that calls GetSkuFromOrderItem::aroundExecute() (e.g. indexing, order view, or POS sync).
  3. Observe the PHP warning in logs or frontend.

Expected result

Magento should safely fall back to $orderItem->getSku() if simple_sku is not set.

Actual result

Error message "Undefined array key "simple_sku" in vendor/magento/module-inventory-configurable-product/Plugin/Sales/GetSkuFromOrderItem.php on line 36"

Additional information

Suggested Fix
Replace:

$sku = $orderItemOptions['simple_sku'];

With:
$sku = $orderItemOptions['simple_sku'] ?? $orderItem->getSku();

This ensures compatibility with orders that may not include the simple_sku key.

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

Issue: needs updateAdditional information is require, waiting for responseReported on 2.4.7-p6Indicates original Magento version for the Issue report.

Type

No type

Projects

Status

Needs Update

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions