Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     // normalize order items if single is passed
     if (!empty($importedRecord['items'])) {
         /** @var array $items */
         $items = $importedRecord['items'];
         foreach ($items as $item) {
             if (!is_array($item)) {
                 $importedRecord['items'] = [$items];
                 break;
             }
         }
     }
     if ($this->context && $this->context->hasOption('channel')) {
         $importedRecord['store:channel:id'] = $this->context->getOption('channel');
         $importedRecord['customer:channel:id'] = $this->context->getOption('channel');
         $importedRecord['cart:channel:id'] = $this->context->getOption('channel');
     }
     $importedRecord = parent::convertToImportFormat($importedRecord, $skipNullValues);
     $importedRecord = AttributesConverterHelper::addUnknownAttributes($importedRecord, $this->context);
     if (!empty($importedRecord['paymentDetails']['method'])) {
         $importedRecord['paymentMethod'] = $importedRecord['paymentDetails']['method'];
     } else {
         $importedRecord['paymentMethod'] = null;
     }
     unset($importedRecord['paymentDetails']['method']);
     return $importedRecord;
 }
 public function testAddUnknownAttributesIdAttributes()
 {
     $context = $this->getMockBuilder('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface')->getMock();
     $context->expects($this->once())->method('hasOption')->with(AttributesConverterHelper::CHANNEL_KEY)->will($this->returnValue(true));
     $context->expects($this->once())->method('getOption')->with(AttributesConverterHelper::CHANNEL_KEY)->will($this->returnValue(1));
     $data = ['test' => '1', AttributesConverterHelper::ATTRIBUTES_KEY => [[AttributesConverterHelper::KEY => 'some_id', AttributesConverterHelper::VALUE => 'val1']]];
     $expected = ['test' => '1', 'someId' => 'val1', 'some' => ['originId' => 'val1', 'channel' => ['id' => 1]]];
     $this->assertEquals($expected, AttributesConverterHelper::addUnknownAttributes($data, $context));
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     if ($this->context && $this->context->hasOption('channel')) {
         $importedRecord['store:channel:id'] = $this->context->getOption('channel');
         $importedRecord['website:channel:id'] = $this->context->getOption('channel');
         $importedRecord['group:channel:id'] = $this->context->getOption('channel');
     }
     $importedRecord = parent::convertToImportFormat($importedRecord, $skipNullValues);
     $importedRecord = AttributesConverterHelper::addUnknownAttributes($importedRecord, $this->context);
     $importedRecord['confirmed'] = false;
     $importedRecord['guest'] = true;
     return $importedRecord;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     if ($this->context && $this->context->hasOption('channel')) {
         $importedRecord['store:channel:id'] = $this->context->getOption('channel');
         $importedRecord['customer:channel:id'] = $this->context->getOption('channel');
         $importedRecord['customer:group:channel:id'] = $this->context->getOption('channel');
     }
     $importedRecord['cart_status'] = CartStatus::STATUS_OPEN;
     if (array_key_exists('is_active', $importedRecord)) {
         $importedRecord['cart_status'] = $importedRecord['is_active'] ? CartStatus::STATUS_OPEN : CartStatus::STATUS_EXPIRED;
     }
     $importedRecord = parent::convertToImportFormat($importedRecord, $skipNullValues);
     return AttributesConverterHelper::addUnknownAttributes($importedRecord, $this->context);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     if ($this->context && $this->context->hasOption('channel')) {
         $importedRecord['owner:channel:id'] = $this->context->getOption('channel');
     }
     $importedRecord = parent::convertToImportFormat($importedRecord, $skipNullValues);
     $importedRecord = AttributesConverterHelper::addUnknownAttributes($importedRecord, $this->context);
     if (!empty($importedRecord['is_default_shipping'])) {
         $importedRecord['types'][] = ['name' => AddressType::TYPE_SHIPPING];
         unset($importedRecord['is_default_shipping']);
     }
     if (!empty($importedRecord['is_default_billing'])) {
         $importedRecord['types'][] = ['name' => AddressType::TYPE_BILLING];
         unset($importedRecord['is_default_billing']);
     }
     return $importedRecord;
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     if ($this->context && $this->context->hasOption('channel')) {
         $importedRecord['store:channel:id'] = $this->context->getOption('channel');
         $importedRecord['website:channel:id'] = $this->context->getOption('channel');
         $importedRecord['group:channel:id'] = $this->context->getOption('channel');
     }
     // extract view from 'website\nstore\view' string
     if (!empty($importedRecord['storeName'])) {
         $createdIn = explode("\n", $importedRecord['storeName']);
         $importedRecord['storeName'] = end($createdIn);
     }
     $importedRecord = parent::convertToImportFormat($importedRecord, $skipNullValues);
     $importedRecord = AttributesConverterHelper::addUnknownAttributes($importedRecord, $this->context);
     $importedRecord['confirmed'] = false;
     $importedRecord['guest'] = true;
     return $importedRecord;
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function convertToImportFormat(array $importedRecord, $skipNullValues = true)
 {
     if ($this->context && $this->context->hasOption('channel')) {
         $importedRecord['store:channel:id'] = $this->context->getOption('channel');
         $importedRecord['website:channel:id'] = $this->context->getOption('channel');
         $importedRecord['group:channel:id'] = $this->context->getOption('channel');
     }
     $importedRecord = parent::convertToImportFormat($importedRecord, $skipNullValues);
     $importedRecord = AttributesConverterHelper::addUnknownAttributes($importedRecord, $this->context);
     $importedRecord['confirmed'] = empty($importedRecord['confirmation']);
     if (!empty($importedRecord['birthday'])) {
         $importedRecord['birthday'] = substr($importedRecord['birthday'], 0, 10);
     }
     if (!empty($importedRecord['gender'])) {
         $importedRecord['gender'] = $this->getOroGender($importedRecord['gender']);
     }
     unset($importedRecord['password']);
     return $importedRecord;
 }