Skip to content

Commit 337c4da

Browse files
committed
ACP2E-1347: Bundle product save slow
1 parent dd7516c commit 337c4da

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

app/code/Magento/Bundle/Api/ProductAddChildrenInterface.php renamed to app/code/Magento/Bundle/Api/ProductLinkManagementAddChildrenInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Interface for Bulk children addition
1313
*/
14-
interface ProductAddChildrenInterface
14+
interface ProductLinkManagementAddChildrenInterface
1515
{
1616
/**
1717
* Bulk add children operation

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Bundle\Api\Data\LinkInterface;
1111
use Magento\Bundle\Api\Data\LinkInterfaceFactory;
1212
use Magento\Bundle\Api\Data\OptionInterface;
13-
use Magento\Bundle\Api\ProductAddChildrenInterface;
13+
use Magento\Bundle\Api\ProductLinkManagementAddChildrenInterface;
1414
use Magento\Bundle\Api\ProductLinkManagementInterface;
1515
use Magento\Bundle\Model\Product\Type;
1616
use Magento\Bundle\Model\ResourceModel\Bundle;
@@ -31,7 +31,7 @@
3131
*
3232
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3333
*/
34-
class LinkManagement implements ProductLinkManagementInterface, ProductAddChildrenInterface
34+
class LinkManagement implements ProductLinkManagementInterface, ProductLinkManagementAddChildrenInterface
3535
{
3636
/**
3737
* @var ProductRepositoryInterface

app/code/Magento/Bundle/Model/Option/SaveAction.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Bundle\Api\Data\LinkInterface;
1212
use Magento\Bundle\Api\Data\OptionInterface;
1313
use Magento\Bundle\Api\ProductLinkManagementInterface;
14-
use Magento\Bundle\Api\ProductAddChildrenInterface;
14+
use Magento\Bundle\Api\ProductLinkManagementAddChildrenInterface;
1515
use Magento\Bundle\Model\Product\Type;
1616
use Magento\Bundle\Model\ResourceModel\Option;
1717
use Magento\Bundle\Model\ResourceModel\Option\Collection;
@@ -51,7 +51,7 @@ class SaveAction
5151
private $linkManagement;
5252

5353
/**
54-
* @var ProductAddChildrenInterface
54+
* @var ProductLinkManagementAddChildrenInterface
5555
*/
5656
private $addChildren;
5757

@@ -61,7 +61,7 @@ class SaveAction
6161
* @param Type $type
6262
* @param ProductLinkManagementInterface $linkManagement
6363
* @param StoreManagerInterface|null $storeManager
64-
* @param ProductAddChildrenInterface|null $addChildren
64+
* @param ProductLinkManagementAddChildrenInterface|null $addChildren
6565
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6666
*/
6767
public function __construct(
@@ -70,14 +70,14 @@ public function __construct(
7070
Type $type,
7171
ProductLinkManagementInterface $linkManagement,
7272
?StoreManagerInterface $storeManager = null,
73-
?ProductAddChildrenInterface $addChildren = null
73+
?ProductLinkManagementAddChildrenInterface $addChildren = null
7474
) {
7575
$this->optionResource = $optionResource;
7676
$this->metadataPool = $metadataPool;
7777
$this->type = $type;
7878
$this->linkManagement = $linkManagement;
7979
$this->addChildren = $addChildren ?:
80-
ObjectManager::getInstance()->get(ProductAddChildrenInterface::class);
80+
ObjectManager::getInstance()->get(ProductLinkManagementAddChildrenInterface::class);
8181
}
8282

8383
/**
@@ -153,10 +153,7 @@ private function saveOptionItem(
153153
throw new CouldNotSaveException(__("The option couldn't be saved."), $e);
154154
}
155155

156-
/** @var LinkInterface $linkedProduct */
157-
foreach ($linksToAdd as $linkedProduct) {
158-
$this->linkManagement->addChild($bundleProduct, $option->getOptionId(), $linkedProduct);
159-
}
156+
$this->addChildren->addChildren($bundleProduct, (int)$option->getOptionId(), $linksToAdd);
160157
}
161158

162159
/**

app/code/Magento/Bundle/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<preference for="Magento\Bundle\Api\ProductOptionTypeListInterface" type="Magento\Bundle\Model\OptionTypeList" />
1010
<preference for="Magento\Bundle\Api\Data\OptionTypeInterface" type="Magento\Bundle\Model\Source\Option\Type" />
1111
<preference for="Magento\Bundle\Api\ProductLinkManagementInterface" type="Magento\Bundle\Model\LinkManagement" />
12-
<preference for="Magento\Bundle\Api\ProductAddChildrenInterface" type="Magento\Bundle\Model\LinkManagement" />
12+
<preference for="Magento\Bundle\Api\ProductLinkManagementAddChildrenInterface" type="Magento\Bundle\Model\LinkManagement" />
1313
<preference for="Magento\Bundle\Api\Data\LinkInterface" type="Magento\Bundle\Model\Link" />
1414
<preference for="Magento\Bundle\Api\ProductOptionRepositoryInterface" type="Magento\Bundle\Model\OptionRepository" />
1515
<preference for="Magento\Bundle\Api\ProductOptionManagementInterface" type="Magento\Bundle\Model\OptionManagement" />

0 commit comments

Comments
 (0)