Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InventoryAPI implementing StockExtensionInterface breaks adding in any other Extension Attribute #3362

Open
sdouma opened this issue Sep 30, 2022 · 2 comments

Comments

@sdouma
Copy link

sdouma commented Sep 30, 2022

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

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\InventoryApi\Api\Data;

/**
 * TODO: temporal fix of extension classes generation during installation
 * Extension class for @see \Magento\InventoryApi\Api\Data\StockInterface
 */
class StockExtension extends \Magento\Framework\Api\AbstractSimpleObject implements StockExtensionInterface
{
    /**
     * @inheritdoc
     */
    public function getSalesChannels(): ?array
    {
        return $this->_get('sales_channels');
    }

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

Proposed solution

Don't implement the interface.

@m2-assistant
Copy link

m2-assistant bot commented Sep 30, 2022

Hi @sdouma. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


@sdouma
Copy link
Author

sdouma commented Sep 30, 2022

Found this #3275 after checking through m2 issues. Been over a year and it is P1 and low risk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Backlog
  
Ready for Grooming
Development

No branches or pull requests

1 participant