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

[Backport] Turn on edit mode for product repository when adding children #22295

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
Expand All @@ -10,6 +9,11 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\StateException;

/**
* Configurable product link management.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Could you explain, please, why do we need @SuppressWarnings directive here? I understand that we have it in the original PR. However, we don't introduce a new dependency here and using this directive is a bit doubtful.

*/
class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementInterface
{
/**
Expand Down Expand Up @@ -67,7 +71,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getChildren($sku)
{
Expand Down Expand Up @@ -106,11 +110,15 @@ public function getChildren($sku)
}

/**
* {@inheritdoc}
* @inheritdoc
* @throws InputException
* @throws NoSuchEntityException
* @throws StateException
* @throws \Magento\Framework\Exception\CouldNotSaveException
*/
public function addChild($sku, $childSku)
{
$product = $this->productRepository->get($sku);
$product = $this->productRepository->get($sku, true);
$child = $this->productRepository->get($childSku);

$childrenIds = array_values($this->configurableType->getChildrenIds($product->getId())[0]);
Expand Down Expand Up @@ -144,7 +152,11 @@ public function addChild($sku, $childSku)
}

/**
* {@inheritdoc}
* @inheritdoc
* @throws InputException
* @throws NoSuchEntityException
* @throws StateException
* @throws \Magento\Framework\Exception\CouldNotSaveException
*/
public function removeChild($sku, $childSku)
{
Expand Down