From d75ed2a1e7e932b77628dad0c88e621673530801 Mon Sep 17 00:00:00 2001 From: Didier Fanchon Date: Wed, 18 Mar 2015 15:27:52 +0100 Subject: [PATCH] Fix #1018 --- module/Rubedo/src/Rubedo/Mongo/DataImport.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/module/Rubedo/src/Rubedo/Mongo/DataImport.php b/module/Rubedo/src/Rubedo/Mongo/DataImport.php index 30425bb47..55f3ff5dd 100644 --- a/module/Rubedo/src/Rubedo/Mongo/DataImport.php +++ b/module/Rubedo/src/Rubedo/Mongo/DataImport.php @@ -180,14 +180,12 @@ public function run($fileName, $options) $this->_target = ''; // Add system fields text and summary if (isset($options['text']) && is_int($options['text'])) { - echo "ok"; $this->_importAsField[] = array( 'csvIndex' => $options['text'], 'protoId' => 'text' ); } if (isset($options['summary']) && is_int($options['summary'])) { - echo "ok"; $this->_importAsField[] = array( 'csvIndex' => $options['summary'], 'protoId' => 'summary' @@ -437,12 +435,19 @@ protected function updateData() { $filter = Filter::factory('Value')->setName('typeId')->setValue($this->_typeId); $findFilter->addFilter($filter); - - if ($this->_uniqueKeyField != 'sku') { - $filter = Filter::factory('Value')->setName($this->_uniqueKeyField)->setValue($record['col'.$this->_uniqueKeyIndex]); - } else { - $filter = Filter::factory('Value')->setName('productProperties.sku')->setValue($record['col'.$this->_productOptions['baseSkuFieldIndex']]); + + switch ($this->_uniqueKeyField) { + case 'sku': + $filterName = 'productProperties.sku'; + $filterValue = $record['col'.$this->_productOptions['baseSkuFieldIndex']]; + break; + default: + $filterName = "live.i18n.".$this->_workingLanguage.".fields.".$this->_uniqueKeyField; + $filterValue = $record['col'.$this->_uniqueKeyIndex]; + break; } + + $filter = Filter::factory('Value')->setName($filterName)->setValue($filterValue); $findFilter->addFilter($filter); $contentToUpdate = Manager::getService('Contents')->findOne($findFilter,true,false); @@ -450,7 +455,7 @@ protected function updateData() { // If the content to update exists if ($contentToUpdate) { - + // Process fields $fields = []; @@ -567,7 +572,7 @@ protected function updateData() { $contentToUpdate['fields'] = array_replace_recursive($contentToUpdate['fields'],$fields); $contentToUpdate['i18n'][$this->_workingLanguage]['fields'] = array_replace_recursive($contentToUpdate['i18n'][$this->_workingLanguage]['fields'],$fields); - + // Finally update content $result = Manager::getService('Contents')->update($contentToUpdate, array(), false); @@ -588,7 +593,6 @@ protected function updateData() { } } - } return $counter;