6 declare(strict_types=1);
47 private $commands = [];
62 ResourceHelper $resourceHelper,
63 DataHelper $dataHelper,
64 ImportData $importData,
70 $this->_resourceHelper = $resourceHelper;
71 $this->_importExportData = $dataHelper;
72 $this->_dataSourceModel = $importData;
73 $this->validator = $validator;
75 foreach ($commands as $command) {
78 __(
'Source Import Commands must implement %interface.', [
'interface' => CommandInterface::class])
82 $this->commands = $commands;
92 $command = $this->getCommandByBehavior($this->
getBehavior());
93 while ($bunch = $this->_dataSourceModel->getNextBunch()) {
94 $command->execute($bunch);
105 private function getCommandByBehavior($behavior)
107 if (!isset($this->commands[$behavior])) {
109 __(
'There is no command registered for behavior "%behavior".', [
'behavior' => $behavior])
113 return $this->commands[$behavior];
123 return 'stock_sources';
135 $result = $this->validator->validate($rowData, $rowNum);
140 foreach (
$result->getErrors() as $error) {
__construct(Json $jsonHelper, ProcessingErrorAggregatorInterface $errorAggregator, ResourceHelper $resourceHelper, DataHelper $dataHelper, ImportData $importData, ValidatorInterface $validator, array $commands=[])
validateRow(array $rowData, $rowNum)
addRowError( $errorCode, $errorRowNum, $colName=null, $errorMessage=null, $errorLevel=ProcessingError::ERROR_LEVEL_CRITICAL, $errorDescription=null)