1: <?php
2: namespace Datadepo\Api\Synchronizers;
3: use Datadepo\Api;
4:
5: class SuppliersSynchronizer extends AbstractSynchronizer
6: {
7:
8: 9: 10:
11: protected function makeSync()
12: {
13: $config = $this->dataStore->getConfig('suppliers_last', 'suppliers_rows');
14: return $this->callSync('suppliers', $config, $this->iniConfiguration->get('limits', 'suppliers'));
15: }
16:
17: 18: 19:
20: protected function wrapLine($line)
21: {
22: return new Api\Structures\SupplierLine($line);
23: }
24:
25: 26: 27:
28: protected function processChunk(Api\Collector $collector)
29: {
30:
31: $actual = $this->dataStore->getChecksums('suppliers', $collector->getPrimaryKeys());
32:
33: $this->dataStore->startChunkProcess();
34:
35:
36: foreach ($collector as $code => $line) {
37: if (!isset($actual[$code])) {
38: $this->dataStore->insertRow($line);
39: }
40: elseif ($actual[$code] != $line->getChecksum()) {
41: $this->dataStore->updateRow($line);
42: }
43: }
44: $this->dataStore->endChunkProcess();
45: }
46:
47: }