magento / magento/inventory

InventoryAPI implementing StockExtensionInterface breaks adding in any other Extension Attribute

Open
#3,362 2 comments 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

### Summary (*)
When \Magento\InventoryApi\Api\Data\StockExtension implements the extension interface it will break adding any other extension attribute because it isn't going to build in generated. Even if you override the class and interface, magento bases on the generated interface, so when Magento\Ui\DataProvider builds the item data through the hydrate interface, it will base the extension attributes on \Magento\InventoryApi\Api\Data\StockExtension not the preference.

note: I do see the TODO but this has been causing issues for 4 years.

### Examples (*)

\Magento\InventoryApi\Api\Data\StockExtension
```
_get('sales_channels');
}

/**
* @inheritdoc
*/
public function setSalesChannels(?array $salesChannels): void
{
$this->setData('sales_channels', $salesChannels);
}
}
```

### Proposed solution
Don't implement the interface.

Contributor guide

Open the contributing guide

Research direction

Start with Magento\InventoryApi\Api\Data\StockExtension and its StockExtensionInterface implementation, then trace how Magento\Ui\DataProvider hydrates extension attributes through generated interfaces. Confirm the effect of removing the interface implementation on adding another extension attribute. Done means StockExtension no longer prevents other extension attributes from being added.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.