Пример #1
0
 public function testConvert()
 {
     $input = array('foo' => 'bar', 'baz' => array('another' => 'thing'));
     $converter = new MappingItemConverter();
     $converter->addMapping('foo', 'bazinga')->addMapping('baz', array('another' => 'somethingelse'));
     $output = $converter->convert($input);
     $expected = array('bazinga' => 'bar', 'baz' => array('somethingelse' => 'thing'));
     $this->assertEquals($expected, $output);
 }
Пример #2
0
 public function testRightColumnsHeadersNamesAfterItemConverter()
 {
     $data = array(array('first' => 'John', 'lastname' => 'Doe'), array('first' => 'Ivan', 'lastname' => 'Sidorov'));
     $reader = new ArrayReader($data);
     $converter = new MappingItemConverter();
     $converter->addMapping('first', 'firstname');
     $output = new BufferedOutput();
     $table = new Table($output);
     $table->setStyle('compact');
     $workflow = new Workflow($reader);
     $workflow->addItemConverter($converter)->addWriter(new ConsoleTableWriter($output, $table))->process();
     $this->assertRegExp('/\\s+lastname\\s+firstname\\s+Doe\\s+John\\s+Sidorov\\s+Ivan\\s+/', $output->fetch());
 }
Пример #3
0
 /**
  * @param array $item
  * @param string $from
  * @param string $to
  * @return array
  */
 protected function applyMapping(array $item, $from, $to)
 {
     if ($from !== $this->nestKey) {
         return parent::applyMapping($item, $from, $to);
     }
     foreach ($item[$this->nestKey] as $key => $nestedItem) {
         foreach ($to as $nestedFrom => $nestedTo) {
             $nestedItem = parent::applyMapping($nestedItem, $nestedFrom, $nestedTo);
         }
         $item[$this->nestKey][$key] = $nestedItem;
     }
     return $item;
 }
Пример #4
0
 public function createAction(Request $request = null)
 {
     // the key used to lookup the template
     $templateKey = 'edit';
     if (false === $this->admin->isGranted('CREATE')) {
         throw new AccessDeniedException();
     }
     $object = $this->admin->getNewInstance();
     $this->admin->setSubject($object);
     /** @var $form \Symfony\Component\Form\Form */
     $form = $this->admin->getForm();
     $form->setData($object);
     if ($this->getRestMethod() == 'POST') {
         $form->submit($this->get('request'));
         $isFormValid = $form->isValid();
         // persist if the form was valid and if in preview mode the preview was approved
         if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
             if (false === $this->admin->isGranted('CREATE', $object)) {
                 throw new AccessDeniedException();
             }
             try {
                 $dummyImport = getcwd() . "/dummyImport";
                 $fname = "directly.csv";
                 $filename = $dummyImport . "/" . $fname;
                 @mkdir($dummyImport);
                 @unlink($filename);
                 // move file to dummy filename
                 $form['file']->getData()->move($dummyImport, $fname);
                 // Create and configure the reader
                 $file = new \SplFileObject('dummyImport/directly.csv', "r");
                 // $file->setFlags(SplFileObject::READ_CSV);
                 $csvReader = new CsvReader($file, ";");
                 $csvReader->setHeaderRowNumber(0);
                 // Create the workflow from the reader
                 $workflow = new Workflow($csvReader);
                 // Create a writer: you need Doctrine’s EntityManager.
                 $em = $this->getDoctrine()->getManager();
                 $doctrineWriter = new DoctrineWriter($em, 'SuppliercheckAdminBundle:Import');
                 $workflow->addWriter($doctrineWriter);
                 $converter = new MappingItemConverter();
                 $converter->addMapping('id_catalog_simple', 'idCatalogSimple')->addMapping('created_at_external', 'createdAtExternal')->addMapping('updated_at_external', 'updatedAtExternal')->addMapping('created_at', 'createdAt')->addMapping('updated_at', 'updatedAt')->addMapping('special_price', 'specialPrice')->addMapping('special_from_date', 'specialFromDate')->addMapping('special_to_date', 'specialToDate')->addMapping('tax_class', 'taxClass')->addMapping('tax_class_2', 'taxClass2')->addMapping('original_price', 'originalPrice')->addMapping('base_price', 'basePrice')->addMapping('barcode_ean', 'barcodeEan')->addMapping('sku_supplier_simple', 'skuSupplierSimple')->addMapping('supplier_simple_name', 'supplierSimpleName')->addMapping('shipment_type', 'shipmentType')->addMapping('transport_type', 'transportType')->addMapping('is_global', 'isGlobal')->addMapping('shipment_cost', 'shipmentCost')->addMapping('shipment_cost_comment', 'shipmentCostComment')->addMapping('dreamroom_show_in_image_map', 'dreamroomShowInImageMap')->addMapping('dreamroom_image_map_x', 'dreamroomImageMapX')->addMapping('dreamroom_image_map_y', 'dreamroomImageMapY')->addMapping('xcart_sku', 'xcartSku')->addMapping('delivery_date_start', 'deliveryDateStart')->addMapping('delivery_date_end', 'deliveryDateEnd')->addMapping('docdata_ean', 'docdataEan')->addMapping('docdata_description', 'docdataDescription')->addMapping('docdata_weight', 'docdataWeight')->addMapping('custom_identifier', 'customIdentifier')->addMapping('expected_delivery_date_start', 'expectedDeliveryDateStart')->addMapping('expected_delivery_date_end', 'expectedDeliveryDateEnd')->addMapping('navision_flag', 'navisionFlag')->addMapping('delivery_day_min', 'deliveryDayMin')->addMapping('delivery_day_max', 'deliveryDayMax')->addMapping('additional_inbound_info', 'additionalInboundInfo')->addMapping('expected_gm1', 'expectedGm1')->addMapping('expected_gm2', 'expectedGm2')->addMapping('expected_gm3', 'expectedGm3')->addMapping('sum_gross_weight', 'sumGrossWeight')->addMapping('number_separate_packages', 'numberSeparatePackages')->addMapping('delay_reasons', 'delayReasons')->addMapping('hide_original_price', 'hideOriginalPrice')->addMapping('producer_name', 'producerName')->addMapping('producer_address', 'producerAddress')->addMapping('additional_2mh_service', 'additional2mhService')->addMapping('additional_2mh_service_price', 'additional2mhServicePrice')->addMapping('is_bundle', 'isBundle')->addMapping('id_catalog_config_westwing', 'idCatalogConfigWestwing')->addMapping('design_scout', 'designScout')->addMapping('logistic_lead', 'logisticLead')->addMapping('id_catalog_simple_westwing', 'idCatalogSimpleWestwing')->addMapping('supplier_identifier', 'supplierIdentifier')->addMapping('config_group', 'configGroup')->addMapping('attribute_set', 'attributeSet')->addMapping('id_catalog_config', 'idCatalogConfig')->addMapping('sku_config', 'skuConfig')->addMapping('status_config', 'statusConfig')->addMapping('name_other', 'nameOther')->addMapping('editor_opinion', 'editorOpinion')->addMapping('choice_of_description', 'choiceOfDescription')->addMapping('display_as_out_of_stock', 'displayAsOutOfStock')->addMapping('pet_status', 'petStatus')->addMapping('pet_approved', 'petApproved')->addMapping('activated_at', 'activatedAt')->addMapping('sku_supplier_config', 'skuSupplierConfig')->addMapping('name_supplier', 'nameSupplier')->addMapping('delivery_period', 'deliveryPeriod')->addMapping('main_material', 'mainMaterial')->addMapping('package_height', 'packageHeight')->addMapping('package_length', 'packageLength')->addMapping('package_width', 'packageWidth')->addMapping('package_weight', 'packageWeight')->addMapping('short_description', 'shortDescription')->addMapping('care_label', 'careLabel')->addMapping('next_simple_nr', 'nextSimpleNr')->addMapping('brand_name_for_theme_campaigns', 'brandNameForThemeCampaigns')->addMapping('advent_day', 'adventDay')->addMapping('advent_url', 'adventUrl')->addMapping('advent_path', 'adventPath')->addMapping('overwrite_delivery_period', 'overwriteDeliveryPeriod')->addMapping('is_seo_relevant', 'isSeoRelevant')->addMapping('export_static', 'exportStatic')->addMapping('is_hybris_product', 'isHybrisProduct')->addMapping('has_delivery_guarantee', 'hasDeliveryGuarantee')->addMapping('net_purchase_price', 'netPurchasePrice')->addMapping('net_purchase_price_discounted', 'netPurchasePriceDiscounted')->addMapping('supplier_product_number', 'supplierProductNumber')->addMapping('supplier_product_name', 'supplierProductName')->addMapping('local_stock', 'localStock')->addMapping('global_stock', 'globalStock')->addMapping('package1_length', 'package1Length')->addMapping('package1_height', 'package1Height')->addMapping('package1_width', 'package1Width')->addMapping('package1_weight', 'package1Weight')->addMapping('package2_length', 'package2Length')->addMapping('package2_height', 'package2Height')->addMapping('package2_width', 'package2Width')->addMapping('package2_weight', 'package2Weight')->addMapping('package3_length', 'package3Length')->addMapping('package3_height', 'package3Height')->addMapping('package3_width', 'package3Width')->addMapping('package3_weight', 'package3Weight')->addMapping('color_1', 'color1')->addMapping('color_2', 'color2')->addMapping('color_3', 'color3')->addMapping('color_characteristic', 'colorCharacteristic')->addMapping('additional_campaigns', 'additionalCampaigns')->addMapping('status_simple', 'statusSimple')->addMapping('expected_logistics_cost', 'expectedLogisticsCost')->addMapping('discount_level', 'discountLevel')->addMapping('blowout_round', 'blowoutRound')->addMapping('allow_multiple_po', 'allowMultiplePo');
                 $workflow->addItemConverter($converter)->process();
                 //fin de l'import dans la table virtuelle IMPORT
                 //copie des données avec mise en place des relations One TO Many
                 $em1 = $this->getDoctrine()->getManager();
                 $getData = new ArrayCollection();
                 $getData = $em1->getRepository('SuppliercheckAdminBundle:Import');
                 $listData = $getData->findAll();
                 foreach ($listData as $value) {
                     $newProduct = new Product();
                     $newProduct->setCampaign($object);
                     $newProduct->createFromImport($value);
                     $sku = $newProduct->getSku();
                     $newProduct->setLink($sku);
                     $newProduct->setValidated(false);
                     $newProduct->setComments(null);
                     $object->getProducts()->add($newProduct);
                     $newProduct = $value;
                 }
                 //                    $object1 = $this->admin->create($object);
                 //                    $id = $this->admin->getNormalizedIdentifier($object);
                 //                    $o = $object1->getId();
                 //                    $idencode = md5($o);
                 //                    $object1->setUrlencode($idencode);
                 //                    $this->admin->create($object);
                 $object = $this->admin->create($object);
                 $id = $object->getId();
                 $idencode = md5($id);
                 $object->setUrlencode($idencode);
                 $this->admin->create($object);
                 if ($this->isXmlHttpRequest()) {
                     return $this->renderJson(array('result' => 'ok', 'objectId' => $this->admin->getNormalizedIdentifier($object)));
                 }
                 $this->addFlash('sonata_flash_success', $this->admin->trans('flash_create_success', array('%name%' => $this->escapeHtml($this->admin->toString($object))), 'SonataAdminBundle'));
                 // redirect to edit mode
                 return $this->redirectTo($object);
             } catch (ModelManagerException $e) {
                 $this->logModelManagerException($e);
                 $isFormValid = false;
             }
         }
         // show an error message if the form failed validation
         if (!$isFormValid) {
             if (!$this->isXmlHttpRequest()) {
                 $this->addFlash('sonata_flash_error', $this->admin->trans('flash_create_error', array('%name%' => $this->escapeHtml($this->admin->toString($object))), 'SonataAdminBundle'));
             }
         } elseif ($this->isPreviewRequested()) {
             // pick the preview template if the form was valid and preview was requested
             $templateKey = 'preview';
             $this->admin->getShow();
         }
     }
     $view = $form->createView();
     // set the theme for the current Admin Form
     $this->get('twig')->getExtension('form')->renderer->setTheme($view, $this->admin->getFormTheme());
     return $this->render($this->admin->getTemplate($templateKey), array('action' => 'create', 'form' => $view, 'object' => $object));
 }
Пример #5
0
 public function importFileAction(Request $request)
 {
     /*
      * $import = new Import();
      *
      *
      * $em2 = $this->getDoctrine()->getManager();
      * $em2->persist($import);
      * $em2->flush();
      * $i = $import->getId();
      * var_dump($i);
      */
     // Get FileId to "import"
     $param = $request->request;
     $fileId = (int) trim($param->get("fileId"));
     $curType = trim($param->get("fileType"));
     $uploadedFile = $request->files->get("csvFile");
     // if upload was not ok, just redirect to "AdminStatWrongPArameters"
     if (!CSVTypes::existsType($curType) || $uploadedFile == null) {
         return 0;
     }
     // generate dummy dir
     $dummyImport = getcwd() . "/dummyImport";
     $fname = "directly.csv";
     $filename = $dummyImport . "/" . $fname;
     @mkdir($dummyImport);
     @unlink($filename);
     // move file to dummy filename
     $uploadedFile->move($dummyImport, $fname);
     // Create and configure the reader
     $file = new \SplFileObject('dummyImport/directly.csv', "r");
     // $file->setFlags(SplFileObject::READ_CSV);
     $csvReader = new CsvReader($file, ";");
     // var_dump($csvReader);
     // Tell the reader that the first row in the CSV file contains column headers
     $csvReader->setHeaderRowNumber(0);
     // 		foreach ($csvReader as $row => $value) {
     // 			$value['sku'] = '1' ;
     // 		}
     // Create the workflow from the reader
     $workflow = new Workflow($csvReader);
     // Create a writer: you need Doctrine’s EntityManager.
     $em = $this->getDoctrine()->getManager();
     $doctrineWriter = new DoctrineWriter($em, 'SuppliercheckAdminBundle:Data');
     // $doctrineWriter->writeItem(array ('import', 'test'));
     /*
      * $em = $this->getDoctrine()->getManager();
      * $query = $em->createQuery(
      * 'SELECT p
      * FROM AcmeStoreBundle:Product p
      * WHERE p.price > :price
      * ORDER BY p.price ASC'
      * )->setParameter('price', '19.99');
      *
      * $products = $query->getResult();
      */
     // $doctrineWriter->setTruncate(false);
     /*
      * $doctrineWriter
      * ->prepare()
      * ->writeItem(
      * array(
      * 'voila' => $i,
      *
      * )
      * );
      */
     // $doctrineWriter->setTruncate(false);
     $workflow->addWriter($doctrineWriter);
     // $em3=$this->getDoctrine()->getManager();
     // $doctrineR = new DoctrineReader($em3, 'AdminAdminBundle:Data');
     // $fields =$doctrineR->getFields();
     // $workflow2 = new Workflow($doctrineR);
     // $entityMetadata=$em->getClassMetadata('AdminAdminBundle:Product');
     // $entityMetadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_AUTO);
     // $converter = new StringToDateTimeValueConverter();
     $converter = new MappingItemConverter();
     $converter->addMapping('id_catalog_simple', 'idCatalogSimple')->addMapping('created_at_external', 'createdAtExternal')->addMapping('updated_at_external', 'updatedAtExternal')->addMapping('created_at', 'createdAt')->addMapping('updated_at', 'updatedAt')->addMapping('special_price', 'specialPrice')->addMapping('special_from_date', 'specialFromDate')->addMapping('special_to_date', 'specialToDate')->addMapping('tax_class', 'taxClass')->addMapping('tax_class_2', 'taxClass2')->addMapping('original_price', 'originalPrice')->addMapping('base_price', 'basePrice')->addMapping('barcode_ean', 'barcodeEan')->addMapping('sku_supplier_simple', 'skuSupplierSimple')->addMapping('supplier_simple_name', 'supplierSimpleName')->addMapping('shipment_type', 'shipmentType')->addMapping('transport_type', 'transportType')->addMapping('is_global', 'isGlobal')->addMapping('shipment_cost', 'shipmentCost')->addMapping('shipment_cost_comment', 'shipmentCostComment')->addMapping('dreamroom_show_in_image_map', 'dreamroomShowInImageMap')->addMapping('dreamroom_image_map_x', 'dreamroomImageMapX')->addMapping('dreamroom_image_map_y', 'dreamroomImageMapY')->addMapping('xcart_sku', 'xcartSku')->addMapping('delivery_date_start', 'deliveryDateStart')->addMapping('delivery_date_end', 'deliveryDateEnd')->addMapping('docdata_ean', 'docdataEan')->addMapping('docdata_description', 'docdataDescription')->addMapping('docdata_weight', 'docdataWeight')->addMapping('custom_identifier', 'customIdentifier')->addMapping('expected_delivery_date_start', 'expectedDeliveryDateStart')->addMapping('expected_delivery_date_end', 'expectedDeliveryDateEnd')->addMapping('navision_flag', 'navisionFlag')->addMapping('delivery_day_min', 'deliveryDayMin')->addMapping('delivery_day_max', 'deliveryDayMax')->addMapping('additional_inbound_info', 'additionalInboundInfo')->addMapping('expected_gm1', 'expectedGm1')->addMapping('expected_gm2', 'expectedGm2')->addMapping('expected_gm3', 'expectedGm3')->addMapping('sum_gross_weight', 'sumGrossWeight')->addMapping('number_separate_packages', 'numberSeparatePackages')->addMapping('delay_reasons', 'delayReasons')->addMapping('hide_original_price', 'hideOriginalPrice')->addMapping('producer_name', 'producerName')->addMapping('producer_address', 'producerAddress')->addMapping('additional_2mh_service', 'additional2mhService')->addMapping('additional_2mh_service_price', 'additional2mhServicePrice')->addMapping('is_bundle', 'isBundle')->addMapping('id_catalog_config_westwing', 'idCatalogConfigWestwing')->addMapping('design_scout', 'designScout')->addMapping('logistic_lead', 'logisticLead')->addMapping('id_catalog_simple_westwing', 'idCatalogSimpleWestwing')->addMapping('supplier_identifier', 'supplierIdentifier')->addMapping('config_group', 'configGroup')->addMapping('attribute_set', 'attributeSet')->addMapping('id_catalog_config', 'idCatalogConfig')->addMapping('sku_config', 'skuConfig')->addMapping('status_config', 'statusConfig')->addMapping('name_other', 'nameOther')->addMapping('editor_opinion', 'editorOpinion')->addMapping('choice_of_description', 'choiceOfDescription')->addMapping('display_as_out_of_stock', 'displayAsOutOfStock')->addMapping('pet_status', 'petStatus')->addMapping('pet_approved', 'petApproved')->addMapping('activated_at', 'activatedAt')->addMapping('sku_supplier_config', 'skuSupplierConfig')->addMapping('name_supplier', 'nameSupplier')->addMapping('delivery_period', 'deliveryPeriod')->addMapping('main_material', 'mainMaterial')->addMapping('package_height', 'packageHeight')->addMapping('package_length', 'packageLength')->addMapping('package_width', 'packageWidth')->addMapping('package_weight', 'packageWeight')->addMapping('short_description', 'shortDescription')->addMapping('care_label', 'careLabel')->addMapping('next_simple_nr', 'nextSimpleNr')->addMapping('brand_name_for_theme_campaigns', 'brandNameForThemeCampaigns')->addMapping('advent_day', 'adventDay')->addMapping('advent_url', 'adventUrl')->addMapping('advent_path', 'adventPath')->addMapping('overwrite_delivery_period', 'overwriteDeliveryPeriod')->addMapping('is_seo_relevant', 'isSeoRelevant')->addMapping('export_static', 'exportStatic')->addMapping('is_hybris_product', 'isHybrisProduct')->addMapping('has_delivery_guarantee', 'hasDeliveryGuarantee')->addMapping('net_purchase_price', 'netPurchasePrice')->addMapping('net_purchase_price_discounted', 'netPurchasePriceDiscounted')->addMapping('supplier_product_number', 'supplierProductNumber')->addMapping('supplier_product_name', 'supplierProductName')->addMapping('local_stock', 'localStock')->addMapping('global_stock', 'globalStock')->addMapping('package1_length', 'package1Length')->addMapping('package1_height', 'package1Height')->addMapping('package1_width', 'package1Width')->addMapping('package1_weight', 'package1Weight')->addMapping('package2_length', 'package2Length')->addMapping('package2_height', 'package2Height')->addMapping('package2_width', 'package2Width')->addMapping('package2_weight', 'package2Weight')->addMapping('package3_length', 'package3Length')->addMapping('package3_height', 'package3Height')->addMapping('package3_width', 'package3Width')->addMapping('package3_weight', 'package3Weight')->addMapping('color_1', 'color1')->addMapping('color_2', 'color2')->addMapping('color_3', 'color3')->addMapping('color_characteristic', 'colorCharacteristic')->addMapping('additional_campaigns', 'additionalCampaigns')->addMapping('status_simple', 'statusSimple')->addMapping('expected_logistics_cost', 'expectedLogisticsCost')->addMapping('discount_level', 'discountLevel')->addMapping('blowout_round', 'blowoutRound')->addMapping('allow_multiple_po', 'allowMultiplePo');
     // Process the workflow
     // $workflow->addValueConverter('import', $i);
     $workflow->addItemConverter($converter)->process();
     //$workflow2->process();
     /*  	
         	$doctrineWriterId = new DoctrineWriter($em3, 'AdminAdminBundle:Data');
         	$doctrineWriterId
         	->prepare()
         	->writeItem(
         			array(
         					'importId' => '$i',
         	
         			)
         	)
         	->finish();*/
     //$reader =$doctrineWriterId = new DoctrineWriter($em3, 'AdminAdminBundle:Data');
     /*	$em3=$this->getDoctrine()->getManager();
         	$doctrineWriterId = new DoctrineWriter($em3, 'AdminAdminBundle:Data');
         	$doctrineWriterId
         	->prepare()
         	->writeItem(
         			array(
         					'importId' => '$i',
         	
         			)
         	)
         	->finish();
         	$workflow2 = new Workflow($doctrineWriterId);
         	$workflow2->process();
     		//var_dump($workflow);
     		//$b = new csv() ;
     		$em2 = $this->getDoctrine()->getManager();
     		
     		$em3 = $this->getDoctrine()->getManager();
     		
     		//$em2->persist($import);
     		//$em2->flush();
     		//$i = $import->getId();
     		$A = $em2->getRepository('AdminAdminBundle:Data');
     		//$B = new csv() ;
     		$B = clone $A;
     		//$B->setId(null);
     		//$B = new csv() ;
     
     		//$B->setIdCatalogConfig('11');
     		//$em3->persist($B);
     		$em3->flush();
     		$em2->flush();
     		var_dump($B);
     		*/
     return $this->render('SuppliercheckAdminBundle:Default:csv_import.html.twig');
 }
Пример #6
0
 /**
  * Creates a new Campaign entity.
  *
  */
 public function createAction(Request $request)
 {
     $entity = new Campaign();
     //         $product = new \Suppliercheck\SupplierBundle\Entity\Product();
     //         $product->setName('tag1');
     //         $product->setCampaignId(1);
     //         $entity->getProducts()->add($product);
     //         $em1 = $this->getDoctrine()->getManager();
     //         $em1->persist($product);
     //         $em1->flush();
     // Original create form
     // $form = $this->createCreateForm($entity);
     $request = $this->getRequest();
     $form = $this->createCreateForm($entity);
     //        	 $form->handleRequest($request);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             //         	$form['file']->getData()->move($dir, $someNewFilename);
             $dummyImport = getcwd() . "/dummyImport";
             $fname = "directly.csv";
             $filename = $dummyImport . "/" . $fname;
             @mkdir($dummyImport);
             @unlink($filename);
             // move file to dummy filename
             $form['file']->getData()->move($dummyImport, $fname);
             // Create and configure the reader
             $file = new \SplFileObject('dummyImport/directly.csv', "r");
             // $file->setFlags(SplFileObject::READ_CSV);
             $csvReader = new CsvReader($file, ";");
             $csvReader->setHeaderRowNumber(0);
             // Create the workflow from the reader
             $workflow = new Workflow($csvReader);
             // Create a writer: you need Doctrine’s EntityManager.
             $em = $this->getDoctrine()->getManager();
             $doctrineWriter = new DoctrineWriter($em, 'SuppliercheckSupplierBundle:Import');
             $workflow->addWriter($doctrineWriter);
             $converter = new MappingItemConverter();
             $converter->addMapping('id_catalog_simple', 'idCatalogSimple')->addMapping('created_at_external', 'createdAtExternal')->addMapping('updated_at_external', 'updatedAtExternal')->addMapping('created_at', 'createdAt')->addMapping('updated_at', 'updatedAt')->addMapping('special_price', 'specialPrice')->addMapping('special_from_date', 'specialFromDate')->addMapping('special_to_date', 'specialToDate')->addMapping('tax_class', 'taxClass')->addMapping('tax_class_2', 'taxClass2')->addMapping('original_price', 'originalPrice')->addMapping('base_price', 'basePrice')->addMapping('barcode_ean', 'barcodeEan')->addMapping('sku_supplier_simple', 'skuSupplierSimple')->addMapping('supplier_simple_name', 'supplierSimpleName')->addMapping('shipment_type', 'shipmentType')->addMapping('transport_type', 'transportType')->addMapping('is_global', 'isGlobal')->addMapping('shipment_cost', 'shipmentCost')->addMapping('shipment_cost_comment', 'shipmentCostComment')->addMapping('dreamroom_show_in_image_map', 'dreamroomShowInImageMap')->addMapping('dreamroom_image_map_x', 'dreamroomImageMapX')->addMapping('dreamroom_image_map_y', 'dreamroomImageMapY')->addMapping('xcart_sku', 'xcartSku')->addMapping('delivery_date_start', 'deliveryDateStart')->addMapping('delivery_date_end', 'deliveryDateEnd')->addMapping('docdata_ean', 'docdataEan')->addMapping('docdata_description', 'docdataDescription')->addMapping('docdata_weight', 'docdataWeight')->addMapping('custom_identifier', 'customIdentifier')->addMapping('expected_delivery_date_start', 'expectedDeliveryDateStart')->addMapping('expected_delivery_date_end', 'expectedDeliveryDateEnd')->addMapping('navision_flag', 'navisionFlag')->addMapping('delivery_day_min', 'deliveryDayMin')->addMapping('delivery_day_max', 'deliveryDayMax')->addMapping('additional_inbound_info', 'additionalInboundInfo')->addMapping('expected_gm1', 'expectedGm1')->addMapping('expected_gm2', 'expectedGm2')->addMapping('expected_gm3', 'expectedGm3')->addMapping('sum_gross_weight', 'sumGrossWeight')->addMapping('number_separate_packages', 'numberSeparatePackages')->addMapping('delay_reasons', 'delayReasons')->addMapping('hide_original_price', 'hideOriginalPrice')->addMapping('producer_name', 'producerName')->addMapping('producer_address', 'producerAddress')->addMapping('additional_2mh_service', 'additional2mhService')->addMapping('additional_2mh_service_price', 'additional2mhServicePrice')->addMapping('is_bundle', 'isBundle')->addMapping('id_catalog_config_westwing', 'idCatalogConfigWestwing')->addMapping('design_scout', 'designScout')->addMapping('logistic_lead', 'logisticLead')->addMapping('id_catalog_simple_westwing', 'idCatalogSimpleWestwing')->addMapping('supplier_identifier', 'supplierIdentifier')->addMapping('config_group', 'configGroup')->addMapping('attribute_set', 'attributeSet')->addMapping('id_catalog_config', 'idCatalogConfig')->addMapping('sku_config', 'skuConfig')->addMapping('status_config', 'statusConfig')->addMapping('name_other', 'nameOther')->addMapping('editor_opinion', 'editorOpinion')->addMapping('choice_of_description', 'choiceOfDescription')->addMapping('display_as_out_of_stock', 'displayAsOutOfStock')->addMapping('pet_status', 'petStatus')->addMapping('pet_approved', 'petApproved')->addMapping('activated_at', 'activatedAt')->addMapping('sku_supplier_config', 'skuSupplierConfig')->addMapping('name_supplier', 'nameSupplier')->addMapping('delivery_period', 'deliveryPeriod')->addMapping('main_material', 'mainMaterial')->addMapping('package_height', 'packageHeight')->addMapping('package_length', 'packageLength')->addMapping('package_width', 'packageWidth')->addMapping('package_weight', 'packageWeight')->addMapping('short_description', 'shortDescription')->addMapping('care_label', 'careLabel')->addMapping('next_simple_nr', 'nextSimpleNr')->addMapping('brand_name_for_theme_campaigns', 'brandNameForThemeCampaigns')->addMapping('advent_day', 'adventDay')->addMapping('advent_url', 'adventUrl')->addMapping('advent_path', 'adventPath')->addMapping('overwrite_delivery_period', 'overwriteDeliveryPeriod')->addMapping('is_seo_relevant', 'isSeoRelevant')->addMapping('export_static', 'exportStatic')->addMapping('is_hybris_product', 'isHybrisProduct')->addMapping('has_delivery_guarantee', 'hasDeliveryGuarantee')->addMapping('net_purchase_price', 'netPurchasePrice')->addMapping('net_purchase_price_discounted', 'netPurchasePriceDiscounted')->addMapping('supplier_product_number', 'supplierProductNumber')->addMapping('supplier_product_name', 'supplierProductName')->addMapping('local_stock', 'localStock')->addMapping('global_stock', 'globalStock')->addMapping('package1_length', 'package1Length')->addMapping('package1_height', 'package1Height')->addMapping('package1_width', 'package1Width')->addMapping('package1_weight', 'package1Weight')->addMapping('package2_length', 'package2Length')->addMapping('package2_height', 'package2Height')->addMapping('package2_width', 'package2Width')->addMapping('package2_weight', 'package2Weight')->addMapping('package3_length', 'package3Length')->addMapping('package3_height', 'package3Height')->addMapping('package3_width', 'package3Width')->addMapping('package3_weight', 'package3Weight')->addMapping('color_1', 'color1')->addMapping('color_2', 'color2')->addMapping('color_3', 'color3')->addMapping('color_characteristic', 'colorCharacteristic')->addMapping('additional_campaigns', 'additionalCampaigns')->addMapping('status_simple', 'statusSimple')->addMapping('expected_logistics_cost', 'expectedLogisticsCost')->addMapping('discount_level', 'discountLevel')->addMapping('blowout_round', 'blowoutRound')->addMapping('allow_multiple_po', 'allowMultiplePo');
             $workflow->addItemConverter($converter)->process();
             //fin de l'import dans la table virtuelle IMPORT
             //copie des données avec mise en place des relations One TO Many
             $em1 = $this->getDoctrine()->getManager();
             $getData = new ArrayCollection();
             $getData = $em1->getRepository('SuppliercheckSupplierBundle:Import');
             $listData = $getData->findAll();
             foreach ($listData as $value) {
                 $newProduct = new Product();
                 $newProduct->setCampaign($entity);
                 $newProduct->createFromImport($value);
                 $sku = $newProduct->getSku();
                 $newProduct->setLink($sku);
                 $entity->getProducts()->add($newProduct);
                 $newProduct = $value;
             }
             //         	$entity->addProducts($value);
             //var_dump($entity);
             //         	$user->getAuthoredComments()->add($newComment);
             //         	$newComment->setAuthor($user);
             $em = $this->getDoctrine()->getManager();
             $em->persist($entity);
             $em->flush();
             return $this->redirect($this->generateUrl('supplier_campaign_show', array('id' => $entity->getId())));
         }
     }
     //         if ($form->isValid()) {
     //             $em = $this->getDoctrine()->getManager();
     //             $em->persist($entity);
     //             $em->flush();
     //             return $this->redirect($this->generateUrl('supplier_campaign_show', array('id' => $entity->getId())));
     //         }
     return $this->render('SuppliercheckSupplierBundle:Campaign:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
 }