16
16
17
17
/**
18
18
* Class LinkProcessor
19
- *
20
19
*/
21
20
class LinkProcessor
22
21
{
23
22
/**
24
23
* @var array
25
24
*/
26
- private $ _linkNameToId ;
25
+ private $ _linkNameToId = [] ;
27
26
28
27
/**
29
28
* @var array
30
29
*/
31
30
private $ linkNameToId ;
32
31
33
- /** @var LinkFactory */
32
+ /**
33
+ * @var LinkFactory
34
+ */
34
35
private $ linkFactory ;
35
36
36
- /** @var Helper */
37
+ /**
38
+ * @var Helper
39
+ */
37
40
private $ resourceHelper ;
38
41
39
- /** @var SkuProcessor */
42
+ /**
43
+ * @var SkuProcessor
44
+ */
40
45
private $ skuProcessor ;
41
46
42
- /** @var LoggerInterface */
47
+ /**
48
+ * @var LoggerInterface
49
+ */
43
50
private $ logger ;
44
51
45
52
public function __construct (
@@ -70,7 +77,9 @@ public function saveLinks(
70
77
Data $ dataSourceModel ,
71
78
string $ linkField
72
79
) {
73
- /** @var Link $resource */
80
+ /**
81
+ * @var Link $resource
82
+ */
74
83
$ resource = $ this ->linkFactory ->create ();
75
84
$ mainTable = $ resource ->getMainTable ();
76
85
$ positionAttrId = [];
@@ -88,7 +97,7 @@ public function saveLinks(
88
97
$ positionAttrId [$ linkId ] = $ importEntity ->getConnection ()->fetchOne ($ select , $ bind );
89
98
}
90
99
while ($ bunch = $ dataSourceModel ->getNextBunch ()) {
91
- $ this ->processLinkBunches ($ importEntity , $ dataSourceModel , $ linkField , $ bunch , $ resource , $ nextLinkId , $ positionAttrId );
100
+ $ this ->processLinkBunches ($ importEntity , $ linkField , $ bunch , $ resource , $ nextLinkId , $ positionAttrId );
92
101
}
93
102
94
103
return $ this ;
@@ -103,16 +112,15 @@ public function addNameToIds($nameToIds)
103
112
* Processes link bunches
104
113
*
105
114
* @param array $bunch
106
- * @param Link $resource
107
- * @param int $nextLinkId
115
+ * @param Link $resource
116
+ * @param int $nextLinkId
108
117
* @param array $positionAttrId
109
118
*
110
119
* @return void
111
120
* @throws LocalizedException
112
121
*/
113
122
private function processLinkBunches (
114
123
Product $ importEntity ,
115
- Data $ dataSourceModel ,
116
124
string $ linkField ,
117
125
array $ bunch ,
118
126
Link $ resource ,
@@ -191,7 +199,7 @@ function ($linkedSku) use ($sku, $importEntity) {
191
199
/**
192
200
* Check if product exists for specified SKU
193
201
*
194
- * @param string $sku
202
+ * @param string $sku
195
203
* @return bool
196
204
*/
197
205
private function isSkuExist (Product $ importEntity , $ sku )
@@ -204,7 +212,7 @@ private function isSkuExist(Product $importEntity, $sku)
204
212
* Fetches Product Links
205
213
*
206
214
* @param Link $resource
207
- * @param int $productId
215
+ * @param int $productId
208
216
*
209
217
* @return array
210
218
*/
@@ -245,7 +253,7 @@ private function getProductLinkedId(string $linkedSku): ?int
245
253
/**
246
254
* Saves information about product links
247
255
*
248
- * @param Link $resource
256
+ * @param Link $resource
249
257
* @param array $productIds
250
258
* @param array $linkRows
251
259
* @param array $positionRows
0 commit comments