[-] Bo : Fix warnings #PSCFV-6648
This commit is contained in:
1 parent
1d37c98201
commit
84005fea26
1 file changed
+28
-13
@@ -644,10 +644,14 @@ class AdminImportControllerCore extends AdminController
|
|||||||
|
|
||||||
do $uniqid_path = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid_path));
|
do $uniqid_path = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid_path));
|
||||||
file_put_contents($uniqid_path, $field);
|
file_put_contents($uniqid_path, $field);
|
||||||
|
$tab = '';
|
||||||
|
if(!empty($uniqid_path))
|
||||||
|
{
|
||||||
$fd = fopen($uniqid_path, 'r');
|
$fd = fopen($uniqid_path, 'r');
|
||||||
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
|
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
unlink($uniqid_path);
|
unlink($uniqid_path);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($tab) || (!is_array($tab)))
|
if (empty($tab) || (!is_array($tab)))
|
||||||
return array();
|
return array();
|
||||||
@@ -727,6 +731,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
public static function getMaskedRow($row)
|
public static function getMaskedRow($row)
|
||||||
{
|
{
|
||||||
$res = array();
|
$res = array();
|
||||||
|
if (is_array(self::$column_mask))
|
||||||
foreach (self::$column_mask as $type => $nb)
|
foreach (self::$column_mask as $type => $nb)
|
||||||
$res[$type] = isset($row[$nb]) ? $row[$nb] : null;
|
$res[$type] = isset($row[$nb]) ? $row[$nb] : null;
|
||||||
|
|
||||||
@@ -972,8 +977,8 @@ class AdminImportControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = sprintf(
|
||||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||||
$info['name'],
|
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||||
(isset($info['id']) ? $info['id'] : 'null')
|
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||||
);
|
);
|
||||||
$error_tmp = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError();
|
$error_tmp = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError();
|
||||||
if ($error_tmp != '')
|
if ($error_tmp != '')
|
||||||
@@ -1303,8 +1308,8 @@ class AdminImportControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = sprintf(
|
||||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||||
$info['name'],
|
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||||
(isset($info['id']) ? $info['id'] : 'null')
|
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||||
);
|
);
|
||||||
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
|
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
|
||||||
Db::getInstance()->getMsgError();
|
Db::getInstance()->getMsgError();
|
||||||
@@ -1347,7 +1352,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
$specific_price->from = (isset($info['reduction_from']) && Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00';
|
||||||
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
$specific_price->to = (isset($info['reduction_to']) && Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00';
|
||||||
if (!$specific_price->add())
|
if (!$specific_price->add())
|
||||||
$this->addProductWarning($info['name'], $product->id, $this->l('Discount is invalid'));
|
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($product->tags) && !empty($product->tags))
|
if (isset($product->tags) && !empty($product->tags))
|
||||||
@@ -1363,7 +1368,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
|
$is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
|
||||||
if (!$is_tag_added)
|
if (!$is_tag_added)
|
||||||
{
|
{
|
||||||
$this->addProductWarning($info['name'], $product->id, $this->l('Tags list is invalid'));
|
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1380,7 +1385,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
|
$is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
|
||||||
if (!$is_tag_added)
|
if (!$is_tag_added)
|
||||||
{
|
{
|
||||||
$this->addProductWarning($info['name'], $product->id, 'Invalid tag(s) ('.$str.')');
|
$this->addProductWarning(Tools::safeOutput($info['name']), (int)$product->id, 'Invalid tag(s) ('.$str.')');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1445,10 +1450,13 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$feature_name = trim($tab_feature[0]);
|
$feature_name = trim($tab_feature[0]);
|
||||||
$feature_value = trim($tab_feature[1]);
|
$feature_value = trim($tab_feature[1]);
|
||||||
$position = isset($tab_feature[2]) ? $tab_feature[2]: false;
|
$position = isset($tab_feature[2]) ? $tab_feature[2]: false;
|
||||||
|
if(!empty($feature_name) && !empty($feature_value))
|
||||||
|
{
|
||||||
$id_feature = Feature::addFeatureImport($feature_name, $position);
|
$id_feature = Feature::addFeatureImport($feature_name, $position);
|
||||||
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
|
$id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $feature_value);
|
||||||
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
|
Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// clean feature positions to avoid conflict
|
// clean feature positions to avoid conflict
|
||||||
Feature::cleanPositions();
|
Feature::cleanPositions();
|
||||||
}
|
}
|
||||||
@@ -1512,7 +1520,11 @@ class AdminImportControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
$id_shop_list[] = $shop;
|
$id_shop_list[] = $shop;
|
||||||
|
|
||||||
|
if(isset($info['id_product']))
|
||||||
$product = new Product((int)$info['id_product'], false, $default_language);
|
$product = new Product((int)$info['id_product'], false, $default_language);
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
$id_image = null;
|
$id_image = null;
|
||||||
|
|
||||||
//delete existing images if "delete_existing_images" is set to 1
|
//delete existing images if "delete_existing_images" is set to 1
|
||||||
@@ -1577,6 +1589,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$id_attribute_group = 0;
|
$id_attribute_group = 0;
|
||||||
// groups
|
// groups
|
||||||
$groups_attributes = array();
|
$groups_attributes = array();
|
||||||
|
if(isset($info['group']))
|
||||||
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
|
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
|
||||||
{
|
{
|
||||||
$tab_group = explode(':', $group);
|
$tab_group = explode(':', $group);
|
||||||
@@ -1631,6 +1644,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$attributes_to_add = array();
|
$attributes_to_add = array();
|
||||||
|
|
||||||
// for each attribute
|
// for each attribute
|
||||||
|
if(isset($info['attribute']))
|
||||||
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute)
|
foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute)
|
||||||
{
|
{
|
||||||
$tab_attribute = explode(':', $attribute);
|
$tab_attribute = explode(':', $attribute);
|
||||||
@@ -1651,7 +1665,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
// sets the proper id (corresponding to the right key)
|
// sets the proper id (corresponding to the right key)
|
||||||
$obj->id_attribute_group = $groups_attributes[$key]['id'];
|
$obj->id_attribute_group = $groups_attributes[$key]['id'];
|
||||||
$obj->name[$default_language] = str_replace('\n', '', str_replace('\r', '', $attribute));
|
$obj->name[$default_language] = str_replace('\n', '', str_replace('\r', '', $attribute));
|
||||||
$obj->position = (!$position) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
|
$obj->position = (!$position && isset($groups[$group])) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position;
|
||||||
|
|
||||||
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||||
($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
|
($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
|
||||||
@@ -1733,6 +1747,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fills our attributes array, in order to add the attributes to the product_attribute afterwards
|
// fills our attributes array, in order to add the attributes to the product_attribute afterwards
|
||||||
|
if(isset($attributes[$group.'_'.$attribute]))
|
||||||
$attributes_to_add[] = (int)$attributes[$group.'_'.$attribute];
|
$attributes_to_add[] = (int)$attributes[$group.'_'.$attribute];
|
||||||
|
|
||||||
// after insertion, we clean attribute position and group attribute position
|
// after insertion, we clean attribute position and group attribute position
|
||||||
@@ -2188,10 +2203,10 @@ class AdminImportControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||||
$info['name'],
|
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||||
(isset($info['id']) ? $info['id'] : 'null')
|
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||||
);
|
);
|
||||||
$this->errors[] = ($field_error !== true ? $field_error : '').($lang_field_error !== true ? $lang_field_error : '').
|
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
|
||||||
Db::getInstance()->getMsgError();
|
Db::getInstance()->getMsgError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2235,8 +2250,8 @@ class AdminImportControllerCore extends AdminController
|
|||||||
if (!$res)
|
if (!$res)
|
||||||
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
$this->errors[] = Db::getInstance()->getMsgError().' '.sprintf(
|
||||||
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
Tools::displayError('%1$s (ID: %2$s) cannot be saved'),
|
||||||
$info['name'],
|
(isset($info['name']) ? Tools::safeOutput($info['name']) : 'No Name'),
|
||||||
(isset($info['id']) ? $info['id'] : 'null')
|
(isset($info['id']) ? Tools::safeOutput($info['id']) : 'No ID')
|
||||||
);
|
);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user