Skip to content

Commit

Permalink
Merge pull request #12039 from OPEN-DSI/new-import-product-country-code
Browse files Browse the repository at this point in the history
NEW add country code in import product model
  • Loading branch information
eldy committed Oct 7, 2019
2 parents ae2d92a + b85c4f0 commit 0484b10
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions htdocs/core/modules/import/import_csv.modules.php
Expand Up @@ -509,12 +509,12 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji
}
$classinstance=new $class($this->db);
// Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, $newval));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code;
call_user_func_array(array($classinstance, $method), array('', '', $newval, $units));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
if ($classinstance->code != '') // id may be 0, it is a found value
if ($classinstance->id != '') // id may be 0, it is a found value
{
$newval=$classinstance->code;
$newval=$classinstance->id;
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/modules/import/import_xlsx.modules.php
Expand Up @@ -536,12 +536,12 @@ public function import_insert($arrayrecord, $array_match_file_to_database, $obji
}
$classinstance=new $class($this->db);
// Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, '', $newval));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code;
call_user_func_array(array($classinstance, $method), array('', '', $newval, $units));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->id;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
if ($classinstance->code != '') // id may be 0, it is a found value
if ($classinstance->id != '') // id may be 0, it is a found value
{
$newval=$classinstance->code;
$newval=$classinstance->id;
}
else
{
Expand Down
13 changes: 11 additions & 2 deletions htdocs/core/modules/modProduct.class.php
Expand Up @@ -354,6 +354,7 @@ public function __construct($db)
'p.note_public' => "PublicNote",//public note
'p.note' => "PrivateNote",//private note
'p.customcode' => 'CustomCode',
'p.fk_country' => 'CountryCode',
'p.price' => "SellingPriceHT",//without
'p.price_min' => "MinPrice",
'p.price_ttc' => "SellingPriceTTC",//with tax
Expand Down Expand Up @@ -441,8 +442,15 @@ public function __construct($db)
'method' => 'fetch',
'units' => 'volume',
'dict' => 'DictionaryMeasuringUnits'
)
);*/
),
'p.fk_country' => array(
'rule' => 'fetchidfromcodeid',
'classfile' => '/core/class/ccountry.class.php',
'class' => 'Ccountry',
'method' => 'fetch',
'dict' => 'DictionaryCountry'
)
);
if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));
Expand Down Expand Up @@ -486,6 +494,7 @@ public function __construct($db)
'p.note_public' => "a public note (free text)",
'p.note' => "a private note (free text)",
'p.customcode' => 'customs code',
'p.fk_country' => 'FR',
'p.price' => "price ex-vat eg. 100",
'p.price_min' => "price ex-vat eg. 100",
'p.price_ttc' => "price inc-vat eg. 110",
Expand Down

0 comments on commit 0484b10

Please sign in to comment.