magento / magento/inventory

Notice: Undefined offset: 0 in vendor/magento/module-inventory-configurable-product-admin-ui/Observer/ProcessSourceItemsObserver.php on line 83

Open
#3,365 1 comment 0 reactions 0 assignees View on GitHub
Progress: ready for grooming
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

### Preconditions (*)

1. 2.4.1
2. One configurable product and children with sources assigned
3. Multiple websites and store views
E.g.

![image](https://user-images.githubusercontent.com/20220341/201510467-2b2e4cc6-2c87-44fe-af2b-c597862a3cfe.png)

### Steps to reproduce (*)

1. Try to save the configurable product in a different store view than the Default

![image](https://user-images.githubusercontent.com/20220341/201510561-1f0ea31c-caca-406e-87bd-f190b42032cd.png)

### Expected result (*)
1. Product is saved correctly

### Actual result (*)

1. The product is saved but a notice appears

![image](https://user-images.githubusercontent.com/20220341/201510503-59965a5f-4f6b-4c67-a9bc-9c8ad0acd555.png)

I've tried debugging this a bit and it seems that in line
`vendor/magento/module-inventory-configurable-product-admin-ui/Observer/ProcessSourceItemsObserver.php:75`

The productsData array is indexed by 0...N

![image](https://user-images.githubusercontent.com/20220341/201510590-5dc9c5d6-5e7c-4bb5-a9bf-5826b34964bf.png)

But later on the function `$product->getExtensionAttributes()->getConfigurableProductLinks()`

Will return an array indexed by the productId and not with a number 0...N

![image](https://user-images.githubusercontent.com/20220341/201510621-ba873be4-884d-4f73-853a-c31a58318708.png)

However when repeating this on the default store view the case is different and everything works fine.

![image](https://user-images.githubusercontent.com/20220341/201510681-46d3d875-20c6-4ac2-bc3b-0df3f74587ce.png)

Any ideas why it's loading the product links differently per store?

Contributor guide

Open the contributing guide

Research direction

Start with vendor/magento/module-inventory-configurable-product-admin-ui/Observer/ProcessSourceItemsObserver.php, especially the logic around lines 75 and 83. Reproduce saving a configurable product in a non-default store view, then compare the productsData indexes with getConfigurableProductLinks(). Done means the product saves without an undefined-offset notice.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.