[-] BO : Fix bug #PSCFV-10790, Customer group names not exploded
This commit is contained in:
1 parent
554ab9414f
commit
03ad842697
1 file changed
+41
-28
@@ -958,7 +958,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
elseif (isset($category->parent) && is_string($category->parent))
|
elseif (isset($category->parent) && is_string($category->parent))
|
||||||
{
|
{
|
||||||
$category_parent = Category::searchByName($default_language_id, $category->parent, true);
|
$category_parent = Category::searchByName($id_lang, $category->parent, true);
|
||||||
if ($category_parent['id_category'])
|
if ($category_parent['id_category'])
|
||||||
{
|
{
|
||||||
$category->id_parent = (int)$category_parent['id_category'];
|
$category->id_parent = (int)$category_parent['id_category'];
|
||||||
@@ -979,7 +979,7 @@ 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'),
|
||||||
$category_to_create->name[$default_language_id],
|
$category_to_create->name[$id_lang],
|
||||||
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
|
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
|
||||||
);
|
);
|
||||||
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_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 : '').
|
||||||
@@ -1021,8 +1021,8 @@ class AdminImportControllerCore extends AdminController
|
|||||||
($lang_field_error = $category->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && empty($this->errors))
|
($lang_field_error = $category->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && empty($this->errors))
|
||||||
{
|
{
|
||||||
$category_already_created = Category::searchByNameAndParentCategoryId(
|
$category_already_created = Category::searchByNameAndParentCategoryId(
|
||||||
$default_language_id,
|
$id_lang,
|
||||||
$category->name[$default_language_id],
|
$category->name[$id_lang],
|
||||||
$category->id_parent
|
$category->id_parent
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1286,7 +1286,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else if (is_string($value) && !empty($value))
|
else if (is_string($value) && !empty($value))
|
||||||
{
|
{
|
||||||
$category = Category::searchByName($default_language_id, trim($value), true);
|
$category = Category::searchByName($id_lang, trim($value), true);
|
||||||
if ($category['id_category'])
|
if ($category['id_category'])
|
||||||
$product->id_category[] = (int)$category['id_category'];
|
$product->id_category[] = (int)$category['id_category'];
|
||||||
else
|
else
|
||||||
@@ -1949,6 +1949,9 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$this->receiveTab();
|
$this->receiveTab();
|
||||||
$handle = $this->openCsvFile();
|
$handle = $this->openCsvFile();
|
||||||
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
|
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||||
|
$id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
|
||||||
|
if (!Validate::isUnsignedId($id_lang))
|
||||||
|
$id_lang = $default_language_id;
|
||||||
AdminImportController::setLocale();
|
AdminImportController::setLocale();
|
||||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
|
||||||
{
|
{
|
||||||
@@ -1976,31 +1979,40 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$customer_exist = true;
|
$customer_exist = true;
|
||||||
$customer_groups = $customer->getGroups();
|
$customer_groups = $customer->getGroups();
|
||||||
$addresses = $customer->getAddresses((int)Configuration::get('PS_LANG_DEFAULT'));
|
$addresses = $customer->getAddresses((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||||
foreach ($customer_groups as $key => $group)
|
|
||||||
if ($group == $customer->id_default_group)
|
|
||||||
unset($customer_groups[$key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($customer_groups) || count($customer_groups) == 0)
|
||||||
|
$customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
|
||||||
|
|
||||||
// Group Importation
|
// Group Importation
|
||||||
if (isset($info['group']) && !empty($info['group']))
|
if (isset($info['group']) && !empty($info['group']))
|
||||||
{
|
{
|
||||||
if (!isset($customer_groups))
|
foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group)
|
||||||
$customer_groups = array();
|
|
||||||
|
|
||||||
$myGroup = Group::searchByName($default_language_id, $info['group']);
|
|
||||||
|
|
||||||
if (!$myGroup)
|
|
||||||
{
|
{
|
||||||
$myGroup = new Group();
|
if(empty($group))
|
||||||
$myGroup->name = Array($default_language_id => $info['group']);
|
continue;
|
||||||
$myGroup->price_display_method = 1;
|
$id_group = false;
|
||||||
$myGroup->add();
|
$myGroup = Group::searchByName($id_lang, $group);
|
||||||
$myGroup = Group::searchByName($default_language_id, $info['group']);
|
if (isset($myGroup['id_group']) && $myGroup['id_group'])
|
||||||
|
$id_group = (int)$myGroup['id_group'];
|
||||||
|
if (!$id_group)
|
||||||
|
{
|
||||||
|
$myGroup = new Group();
|
||||||
|
$myGroup->name = Array($id_lang => $group);
|
||||||
|
if ($id_lang != $default_language_id)
|
||||||
|
$myGroup->name = array_merge($myGroup->name, array($default_language_id => $group));
|
||||||
|
$myGroup->price_display_method = 1;
|
||||||
|
$myGroup->add();
|
||||||
|
if (Validate::isLoadedObject($myGroup))
|
||||||
|
$id_group = (int)$myGroup->id;
|
||||||
|
}
|
||||||
|
if ($id_group)
|
||||||
|
$customer_groups[] = (int)$id_group;
|
||||||
}
|
}
|
||||||
if (isset($myGroup['0']['id_group']))
|
|
||||||
$customer_groups[] = $myGroup['0']['id_group'];
|
|
||||||
}
|
}
|
||||||
|
elseif(empty($info['group']) && isset($customer->id) && $customer->id)
|
||||||
|
$customer_groups = array(0 => Configuration::get('PS_CUSTOMER_GROUP'));
|
||||||
|
|
||||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
|
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
|
||||||
|
|
||||||
if ($customer->passwd)
|
if ($customer->passwd)
|
||||||
@@ -2037,7 +2049,7 @@ class AdminImportControllerCore extends AdminController
|
|||||||
//set temporally for validate field
|
//set temporally for validate field
|
||||||
$customer->id_shop = $default_shop->id;
|
$customer->id_shop = $default_shop->id;
|
||||||
$customer->id_shop_group = $default_shop->getGroup()->id;
|
$customer->id_shop_group = $default_shop->getGroup()->id;
|
||||||
|
$customer_groups = array_flip(array_flip($customer_groups));
|
||||||
$res = true;
|
$res = true;
|
||||||
if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true &&
|
||||||
($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
|
($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true)
|
||||||
@@ -2055,12 +2067,9 @@ class AdminImportControllerCore extends AdminController
|
|||||||
$customer->id = $current_id_customer;
|
$customer->id = $current_id_customer;
|
||||||
$res &= $customer->update();
|
$res &= $customer->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$res &= $customer->add();
|
$res &= $customer->add();
|
||||||
if (isset($customer_groups))
|
|
||||||
$customer->addGroups($customer_groups);
|
|
||||||
if (isset($addresses))
|
if (isset($addresses))
|
||||||
foreach ($addresses as $address)
|
foreach ($addresses as $address)
|
||||||
{
|
{
|
||||||
@@ -2069,6 +2078,8 @@ class AdminImportControllerCore extends AdminController
|
|||||||
Db::getInstance()->insert('address', $address);
|
Db::getInstance()->insert('address', $address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($res && isset($customer_groups))
|
||||||
|
$customer->updateGroup($customer_groups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2083,8 +2094,6 @@ class AdminImportControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$res &= $customer->add();
|
$res &= $customer->add();
|
||||||
if (isset($customer_groups))
|
|
||||||
$customer->addGroups($customer_groups);
|
|
||||||
if (isset($addresses))
|
if (isset($addresses))
|
||||||
foreach ($addresses as $address)
|
foreach ($addresses as $address)
|
||||||
{
|
{
|
||||||
@@ -2093,9 +2102,12 @@ class AdminImportControllerCore extends AdminController
|
|||||||
Db::getInstance()->insert('address', $address);
|
Db::getInstance()->insert('address', $address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($res && isset($customer_groups))
|
||||||
|
$customer->updateGroup($customer_groups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($customer_groups);
|
||||||
$customer_exist = false;
|
$customer_exist = false;
|
||||||
if (!$res)
|
if (!$res)
|
||||||
{
|
{
|
||||||
@@ -3088,3 +3100,4 @@ class AdminImportControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
Reference in new issue
Block a user