Notice: Undefined offset: 0 in vendor/magento/module-inventory-configurable-product-admin-ui/Observer/ProcessSourceItemsObserver.php on line 83
- 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.

### Steps to reproduce (*)
1. Try to save the configurable product in a different store view than the Default

### Expected result (*)
1. Product is saved correctly
### Actual result (*)
1. The product is saved but a notice appears

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

But later on the function `$product->getExtensionAttributes()->getConfigurableProductLinks()`
Will return an array indexed by the productId and not with a number 0...N

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

Any ideas why it's loading the product links differently per store?
Contributor 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