/**
  * @dataProvider inputDataProvider
  * @param array $input
  * @param array $expected
  * @param ContextInterface $context
  */
 public function testConvertToImportFormat(array $input, array $expected, ContextInterface $context = null)
 {
     $this->dataConverter->expects($this->once())->method('getHeaderConversionRules')->will($this->returnValue(['key' => 'cKey']));
     if ($context) {
         $this->dataConverter->setImportExportContext($context);
     }
     $this->assertEquals($expected, $this->dataConverter->convertToImportFormat($input));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function convertToExportFormat(array $exportedRecord, $skipNullValues = true)
 {
     $exportedRecord = parent::convertToExportFormat($exportedRecord, $skipNullValues);
     $streets = [];
     if (!empty($exportedRecord['street'])) {
         $streets[] = $exportedRecord['street'];
         unset($exportedRecord['street']);
     }
     if (!empty($exportedRecord['street2'])) {
         $streets[] = $exportedRecord['street2'];
         unset($exportedRecord['street2']);
     }
     if ($streets) {
         $exportedRecord['street'] = $streets;
     }
     return $exportedRecord;
 }
 /**
  * {@inheritdoc}
  */
 public function convertToExportFormat(array $exportedRecord, $skipNullValues = true)
 {
     $rules = $this->getHeaderConversionRules();
     $nodeData = [];
     foreach ($this->nodeDataConverters as $nodeKey => $dataConverter) {
         if (array_key_exists($nodeKey, $rules)) {
             $dataKey = $rules[$nodeKey];
         } else {
             $dataKey = $nodeKey;
         }
         if (!empty($exportedRecord[$dataKey]) && is_array($exportedRecord[$dataKey])) {
             if (empty($this->toManyDataConverters[$nodeKey])) {
                 $nodeData[$nodeKey] = $dataConverter->convertToExportFormat($exportedRecord[$dataKey], $skipNullValues);
             } else {
                 foreach ($exportedRecord[$dataKey] as $key => $record) {
                     $nodeData[$nodeKey][$key] = $dataConverter->convertToExportFormat($record, $skipNullValues);
                 }
             }
         }
         unset($exportedRecord[$dataKey]);
     }
     return array_merge(parent::convertToExportFormat($exportedRecord, $skipNullValues), $nodeData);
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     $importedRecord['website:channel:id'] = $this->context->getOption('channel');
     return parent::convertToImportFormat($importedRecord, $skipNullValues);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 protected function fillEmptyColumns(array $header, array $data)
 {
     $dataDiff = array_diff(array_keys($data), $header);
     $data = array_diff_key($data, array_flip($dataDiff));
     return parent::fillEmptyColumns($header, $data);
 }