Skip to content

Commit 3b2a4fe

Browse files
committed
Fix initialisation of linkNameToId, unused variable, run phpcbf
1 parent 84ccd7f commit 3b2a4fe

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/LinkProcessor.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,37 @@
1616

1717
/**
1818
* Class LinkProcessor
19-
*
2019
*/
2120
class LinkProcessor
2221
{
2322
/**
2423
* @var array
2524
*/
26-
private $_linkNameToId;
25+
private $_linkNameToId = [];
2726

2827
/**
2928
* @var array
3029
*/
3130
private $linkNameToId;
3231

33-
/** @var LinkFactory */
32+
/**
33+
* @var LinkFactory
34+
*/
3435
private $linkFactory;
3536

36-
/** @var Helper */
37+
/**
38+
* @var Helper
39+
*/
3740
private $resourceHelper;
3841

39-
/** @var SkuProcessor */
42+
/**
43+
* @var SkuProcessor
44+
*/
4045
private $skuProcessor;
4146

42-
/** @var LoggerInterface */
47+
/**
48+
* @var LoggerInterface
49+
*/
4350
private $logger;
4451

4552
public function __construct(
@@ -70,7 +77,9 @@ public function saveLinks(
7077
Data $dataSourceModel,
7178
string $linkField
7279
) {
73-
/** @var Link $resource */
80+
/**
81+
* @var Link $resource
82+
*/
7483
$resource = $this->linkFactory->create();
7584
$mainTable = $resource->getMainTable();
7685
$positionAttrId = [];
@@ -88,7 +97,7 @@ public function saveLinks(
8897
$positionAttrId[$linkId] = $importEntity->getConnection()->fetchOne($select, $bind);
8998
}
9099
while ($bunch = $dataSourceModel->getNextBunch()) {
91-
$this->processLinkBunches($importEntity, $dataSourceModel, $linkField, $bunch, $resource, $nextLinkId, $positionAttrId);
100+
$this->processLinkBunches($importEntity, $linkField, $bunch, $resource, $nextLinkId, $positionAttrId);
92101
}
93102

94103
return $this;
@@ -103,16 +112,15 @@ public function addNameToIds($nameToIds)
103112
* Processes link bunches
104113
*
105114
* @param array $bunch
106-
* @param Link $resource
107-
* @param int $nextLinkId
115+
* @param Link $resource
116+
* @param int $nextLinkId
108117
* @param array $positionAttrId
109118
*
110119
* @return void
111120
* @throws LocalizedException
112121
*/
113122
private function processLinkBunches(
114123
Product $importEntity,
115-
Data $dataSourceModel,
116124
string $linkField,
117125
array $bunch,
118126
Link $resource,
@@ -191,7 +199,7 @@ function ($linkedSku) use ($sku, $importEntity) {
191199
/**
192200
* Check if product exists for specified SKU
193201
*
194-
* @param string $sku
202+
* @param string $sku
195203
* @return bool
196204
*/
197205
private function isSkuExist(Product $importEntity, $sku)
@@ -204,7 +212,7 @@ private function isSkuExist(Product $importEntity, $sku)
204212
* Fetches Product Links
205213
*
206214
* @param Link $resource
207-
* @param int $productId
215+
* @param int $productId
208216
*
209217
* @return array
210218
*/
@@ -245,7 +253,7 @@ private function getProductLinkedId(string $linkedSku): ?int
245253
/**
246254
* Saves information about product links
247255
*
248-
* @param Link $resource
256+
* @param Link $resource
249257
* @param array $productIds
250258
* @param array $linkRows
251259
* @param array $positionRows

0 commit comments

Comments
 (0)