Merge branch 'ticket-11279-CategoryTestImport' into develop

This commit is contained in:
Marion Muszynski 2016-11-08 13:07:32 +01:00
commit c9dd7475bc

View File

@ -50,6 +50,7 @@ class AdminImport extends AdminTab
public static $default_values = array();
public $_warnings = array();
public $_categories = array();
public static $validators = array(
'active' => array('AdminImport', 'getBoolean'),
@ -605,11 +606,6 @@ class AdminImport extends AdminTab
self::setEntityDefaultValues($product);
self::array_walk($info, array('AdminImport', 'fillInfo'), $product);
// Override Antadis / Weight by default
// if (empty($info['weight'])
// && $info['weight'] != "0") {
// $product->weight = 0.2;
// }
$iso_lang = trim(Tools::getValue('iso_lang'));
if ($iso_lang == 'fr') {
if (empty($info['weight']) && $info['weight'] != "0") {
@ -685,16 +681,30 @@ class AdminImport extends AdminTab
{
if (is_numeric($value))
{
// @Override Antadis
if(!isset($this->_categories[(int)$value])){
$this->_categories[(int)$value] = 0;
} elseif ($this->_categories[(int)$value] == 0) {
continue 2;
}
if($value > ($max_id_category + 1000)){
echo "<div class='module_error error error'>";
echo "Le numéro de catégorie ". $value." est supérieur de +1000 par rapport au dernier numéro connu " . $max_id_category;
echo "</div>";
die();
}
if (Category::categoryExists((int)($value)))
if (Category::categoryExists((int)($value))) {
// @Override Antadis
$this->_categories[(int)$value] = 1;
$product->id_category[] = (int)($value);
}
else
{
// @Override Antadis
$this->_categories[(int)$value] = 0;
continue 2;
$categoryToCreate= new Category();
$categoryToCreate->id = (int)($value);
$categoryToCreate->name = self::createMultiLangField($value);
@ -1783,6 +1793,13 @@ class AdminImport extends AdminTab
default:
$this->_errors[] = $this->l('no entity selected');
}
if(!empty($this->_categories)){
foreach ($this->_categories as $key => $value) {
if ($value == 0) {
$this->_warnings[] = Tools::displayError('Products associated to this category have not been added because the category does not exist: ').$key;
}
}
}
}