Code Duplication    Length = 21-21 lines in 2 locations

Subscribers/ProductStreams.php 1 location

@@ 196-216 (lines=21) @@
193
        $sourceIds = $this->getHelper()->getArticleSourceIds($articleIds);
194
        $items = $this->connectExport->fetchConnectItems($sourceIds, false);
195
196
        foreach ($items as $item) {
197
            if ($productStreamService->allowToRemove($assignments, $streamId, $item['articleId'])) {
198
                $this->getSDK()->recordDelete($item['sourceId']);
199
                $removedRecords[] = $item['sourceId'];
200
            } else {
201
                //updates items with the new streams
202
                $streamCollection = $assignments->getStreamsByArticleId($item['articleId']);
203
                if (!$this->getHelper()->isMainVariant($item['sourceId']) || !$streamCollection) {
204
                    continue;
205
                }
206
207
                //removes current stream from the collection
208
                unset($streamCollection[$streamId]);
209
210
                $this->getSDK()->recordStreamAssignment(
211
                    $item['sourceId'],
212
                    $streamCollection,
213
                    $item['groupId']
214
                );
215
            }
216
        }
217
218
        $this->connectExport->updateConnectItemsStatus($removedRecords, Attribute::STATUS_DELETE);
219
    }

Controllers/Backend/Connect.php 1 location

@@ 1574-1594 (lines=21) @@
1571
                $sourceIds = $this->getHelper()->getArticleSourceIds($assignments->getArticleIds());
1572
                $items = $connectExport->fetchConnectItems($sourceIds, false);
1573
1574
                foreach ($items as $item) {
1575
                    if ($productStreamService->allowToRemove($assignments, $streamId, $item['articleId'])) {
1576
                        $this->getSDK()->recordDelete($item['sourceId']);
1577
                        $removedRecords[] = $item['sourceId'];
1578
                    } else {
1579
                        //updates items with the new streams
1580
                        $streamCollection = $assignments->getStreamsByArticleId($item['articleId']);
1581
                        if (!$this->getHelper()->isMainVariant($item['sourceId']) || !$streamCollection) {
1582
                            continue;
1583
                        }
1584
1585
                        //removes current stream from the collection
1586
                        unset($streamCollection[$streamId]);
1587
1588
                        $this->getSDK()->recordStreamAssignment(
1589
                            $item['sourceId'],
1590
                            $streamCollection,
1591
                            $item['groupId']
1592
                        );
1593
                    }
1594
                }
1595
1596
                $connectExport->updateConnectItemsStatus($removedRecords, Attribute::STATUS_DELETE);
1597
                $this->getSDK()->recordStreamDelete($streamId);