/**
  * @param Resource\Record $destinationRecord
  * @param array $recordData
  * @return Resource\Record
  */
 protected function transformRecord($destinationRecord, $recordData)
 {
     foreach ($destinationRecord->getFields() as $recordField) {
         $destinationRecord->setValue($recordField, $recordData[$recordField]);
     }
     return $destinationRecord;
 }
 /**
  * @expectedException \Migration\Exception
  * @expectedExceptionMessage Record structure does not contain field wrongField
  */
 public function testSetValueWithException()
 {
     $this->record->setStructure($this->structure);
     $this->record->setValue('wrongField', 'itemNew');
 }
示例#3
0
 /**
  * Record transformer
  *
  * @param Record $record
  * @param Record $destRecord
  * @return void
  */
 private function transform(Record $record, Record $destRecord)
 {
     $destRecord->setValue('url_rewrite_id', $record->getValue('url_rewrite_id'));
     $destRecord->setValue('store_id', $record->getValue('store_id'));
     $destRecord->setValue('description', $record->getValue('description'));
     $destRecord->setValue('request_path', $record->getValue('request_path'));
     $destRecord->setValue('target_path', $record->getValue('target_path'));
     $destRecord->setValue('is_autogenerated', $record->getValue('is_system'));
     $destRecord->setValue('entity_type', $this->getRecordEntityType($record));
     $metadata = $this->doRecordSerialization($record) ? serialize(['category_id' => $record->getValue('category_id')]) : null;
     $destRecord->setValue('metadata', $metadata);
     $destRecord->setValue('entity_id', $record->getValue('product_id') ?: $record->getValue('category_id'));
     $destRecord->setValue('redirect_type', $this->redirectTypesMapping[$record->getValue('options')]);
 }
 /**
  * @param Record $from
  * @param Record $to
  * @return void
  */
 protected function copy(Record $from, Record $to)
 {
     foreach ($from->getFields() as $field) {
         if (!$this->mapReader->isFieldIgnored($this->sourceDocument->getName(), $field, MapInterface::TYPE_SOURCE)) {
             $fieldMap = $this->mapReader->getFieldMap($this->sourceDocument->getName(), $field, MapInterface::TYPE_SOURCE);
             $to->setValue($fieldMap, $from->getValue($field));
         }
     }
 }