Skip to content

Commit

Permalink
Fix #1018
Browse files Browse the repository at this point in the history
  • Loading branch information
dfanchon committed Mar 18, 2015
1 parent b5f2330 commit d75ed2a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions module/Rubedo/src/Rubedo/Mongo/DataImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -437,20 +435,27 @@ 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);

// If the content to update exists

if ($contentToUpdate) {

// Process fields

$fields = [];
Expand Down Expand Up @@ -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);

Expand All @@ -588,7 +593,6 @@ protected function updateData() {

}
}

}

return $counter;
Expand Down

0 comments on commit d75ed2a

Please sign in to comment.