Conditions | 5 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | public function write(array $items) |
||
14 | { |
||
15 | parent::write($items); |
||
16 | |||
17 | $count = count($items); |
||
18 | if (!$count) { |
||
19 | return; |
||
20 | } |
||
21 | // Save minimum originId received by initial sync for further filtering in case of failure |
||
22 | $lastSubscriber = $items[$count - 1]; |
||
23 | $transport = $lastSubscriber->getChannel()->getTransport(); |
||
24 | if ($transport instanceof MagentoSoapTransport) { |
||
25 | /** @var MagentoSoapTransport $transport */ |
||
26 | $transport = $this->databaseHelper->getEntityReference($transport); |
||
27 | $syncedToId = $transport->getNewsletterSubscriberSyncedToId(); |
||
28 | if (!$syncedToId || $syncedToId > $lastSubscriber->getOriginId()) { |
||
29 | $transport->setNewsletterSubscriberSyncedToId($lastSubscriber->getOriginId()); |
||
30 | $this->writer->write([$transport]); |
||
31 | } |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 |