Skip to content

Commit 8fe512f

Browse files
Indrani SonawaneIndrani Sonawane
authored andcommitted
Removing phpcs ignore and adding the factory class in constructor as mentioned in review
1 parent 597cbaf commit 8fe512f

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

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

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
6969
* @param \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory
7070
* @param \Magento\Catalog\Model\ProductRepository $mediaGalleryProcessor
7171
* @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory
72+
* @param \Magento\ConfigurableProduct\Helper\Product\Options\Factory $optionsFactory
7273
*/
7374
public function __construct(
7475
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
@@ -77,7 +78,8 @@ public function __construct(
7778
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
7879
\Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory = null,
7980
\Magento\Catalog\Model\ProductRepository $mediaGalleryProcessor = null,
80-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory = null
81+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory $myModelFactory = null,
82+
\Magento\ConfigurableProduct\Helper\Product\Options\Factory $optionsFactory = null
8183
) {
8284
$this->productRepository = $productRepository;
8385
$this->productFactory = $productFactory;
@@ -89,6 +91,8 @@ public function __construct(
8991
->get(\Magento\Catalog\Model\ProductRepository::class);
9092
$this->myModelFactory = $myModelFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
9193
->get(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterfaceFactory::class);
94+
$this->optionsFactory = $optionsFactory ?: \Magento\Framework\App\ObjectManager::getInstance()
95+
->get(\Magento\ConfigurableProduct\Helper\Product\Options\Factory::class);
9296
}
9397

9498
/**
@@ -192,7 +196,7 @@ public function addChild($sku, $childSku)
192196
$configurableOptionData = $this->getConfigurableAttributesData($attributeData);
193197

194198
/** @var \Magento\ConfigurableProduct\Helper\Product\Options\Factory $optionFactory */
195-
$optionFactory = $this->getOptionsFactory();
199+
$optionFactory = $this->optionsFactory();
196200
$options = $optionFactory->create($configurableOptionData);
197201
$childrenIds[] = $child->getId();
198202
$product->getExtensionAttributes()->setConfigurableProductOptions($options);
@@ -236,23 +240,6 @@ public function removeChild($sku, $childSku)
236240
return true;
237241
}
238242

239-
/**
240-
* Get Options Factory
241-
*
242-
* @return \Magento\ConfigurableProduct\Helper\Product\Options\Factory
243-
*
244-
* @deprecated 100.2.0
245-
* @see Nothing
246-
*/
247-
private function getOptionsFactory()
248-
{
249-
if (!$this->optionsFactory) {
250-
$this->optionsFactory = \Magento\Framework\App\ObjectManager::getInstance()
251-
->get(\Magento\ConfigurableProduct\Helper\Product\Options\Factory::class);// phpcs:ignore
252-
}
253-
return $this->optionsFactory;
254-
}
255-
256243
/**
257244
* Get Configurable Attribute Data
258245
*

0 commit comments

Comments
 (0)