|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Spryker\Zed\AkeneoPim\Business\Syncer; |
|
4
|
|
|
|
|
5
|
|
|
use Generated\Shared\Transfer\AkeneoSyncResultTransfer; |
|
|
|
|
|
|
6
|
|
|
use Generated\Shared\Transfer\AkeneoSyncValidateResultTransfer; |
|
|
|
|
|
|
7
|
|
|
use Generated\Shared\Transfer\AkeneoSyncWriteResultTransfer; |
|
|
|
|
|
|
8
|
|
|
use Spryker\Shared\Kernel\Transfer\AbstractTransfer; |
|
9
|
|
|
|
|
10
|
|
|
abstract class AbstractSyncer |
|
11
|
|
|
{ |
|
12
|
|
|
protected $resultHandler; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @param AbstractTransfer $syncConfig |
|
16
|
|
|
* |
|
17
|
|
|
* @return AkeneoSyncResultTransfer |
|
18
|
|
|
*/ |
|
19
|
|
|
public final function sync($syncConfig): AkeneoSyncResultTransfer |
|
20
|
|
|
{ |
|
21
|
|
|
$akeneoEntities = $this->read($syncConfig); |
|
22
|
|
|
|
|
23
|
|
|
foreach($akeneoEntities as $akeneoEntity) { |
|
24
|
|
|
$validationResult = $this->validate($akeneoEntity, $syncConfig); |
|
25
|
|
|
if ($validationResult->getIsSuccess() === false) { |
|
26
|
|
|
$this->resultHandler->addError($akeneoEntity, $validationResult, $syncConfig); |
|
27
|
|
|
|
|
28
|
|
|
if ($validationResult->getIsTerminate() === true) { |
|
29
|
|
|
break; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
continue; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$akeneoEntity = $this->translate($akeneoEntity, $syncConfig); |
|
36
|
|
|
$sprykerEntity = $this->map($akeneoEntity, $syncConfig); |
|
37
|
|
|
$this->write($sprykerEntity, $syncConfig); |
|
38
|
|
|
|
|
39
|
|
|
$this->resultHandler->addSuccess($sprykerEntity, $akeneoEntity, $syncConfig); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return $this->resultHandler->getResults(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Read all "to be processed" akeneo entities |
|
47
|
|
|
* |
|
48
|
|
|
* @param AbstractTransfer $syncConfig |
|
49
|
|
|
* |
|
50
|
|
|
* @return array |
|
51
|
|
|
*/ |
|
52
|
|
|
protected abstract function read($syncConfig): array; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Validates if the data is eligable for processing for workflow requirements |
|
56
|
|
|
* |
|
57
|
|
|
* @param array $akeneoEntity |
|
58
|
|
|
* @param AbstractTransfer $syncConfig |
|
59
|
|
|
* |
|
60
|
|
|
* @return AkeneoSyncValidateResultTransfer |
|
61
|
|
|
*/ |
|
62
|
|
|
protected abstract function validate(array $akeneoEntity, $syncConfig): AkeneoSyncValidateResultTransfer; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Translates Akeneo values into Spryker values (eg: akeneo stores prices in float major currency units, and spryker stores int minor currency units) |
|
66
|
|
|
* |
|
67
|
|
|
* @param array $akeneoEntity |
|
68
|
|
|
* @param AbstractTransfer $syncConfig |
|
69
|
|
|
* |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
protected abstract function translate(array $akeneoEntity, $syncConfig): array; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Maps the Akeneo entity with already translated values into Spryker entity. |
|
76
|
|
|
* |
|
77
|
|
|
* @param array $akeneoEntity |
|
78
|
|
|
* @param AbstractTransfer $syncConfig |
|
79
|
|
|
* |
|
80
|
|
|
* @return array |
|
81
|
|
|
*/ |
|
82
|
|
|
protected abstract function map(array $akeneoEntity, $syncConfig): array; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @param array $sprykerEntity |
|
86
|
|
|
* @param AbstractTransfer $syncConfig |
|
87
|
|
|
* |
|
88
|
|
|
* @return AkeneoSyncWriteResultTransfer |
|
89
|
|
|
*/ |
|
90
|
|
|
protected abstract function write(array $sprykerEntity, $syncConfig): AkeneoSyncWriteResultTransfer; |
|
91
|
|
|
} |
|
92
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths