Merge branch 'master' of https://github.com/DarkHack/PrestaShop into contrib/master

Conflicts:
	controllers/admin/AdminImportController.php
This commit is contained in:
gRoussac
2013-10-10 17:06:13 +02:00
parent 789911184b
commit 286084c42d
2 changed files with 52 additions and 2 deletions
+30 -2
View File
@@ -316,6 +316,34 @@ class GroupCore extends ObjectModel
return $groups[$id_group];
}
}
/**
* Light back office search for Group
*
* @param integer $id_lang Language ID
* @param string $query Searched string
* @param boolean $unrestricted allows search without lang and includes first group and exact match
* @return array Corresponding groupes
*/
public static function searchByName($id_lang, $query, $unrestricted = false)
{
if ($unrestricted === true)
return Db::getInstance()->getRow('
SELECT g.*, gl.*
FROM `'._DB_PREFIX_.'group` g
LEFT JOIN `'._DB_PREFIX_.'group_lang` gl
ON (g.`id_group` = gl.`id_group`)
WHERE `name` LIKE \''.pSQL($query).'\'
');
else
return Db::getInstance()->executeS('
SELECT g.*, gl.*
FROM `'._DB_PREFIX_.'group` g
LEFT JOIN `'._DB_PREFIX_.'group_lang` gl
ON (g.`id_group` = gl.`id_group`
AND `id_lang` = '.(int)$id_lang.')
WHERE `name` LIKE \'%'.pSQL($query).'%\'
AND g.`id_group` != '.(int)Configuration::get('PS_HOME_CATEGORY')
);
}
}
@@ -278,6 +278,7 @@ class AdminImportControllerCore extends AdminController
'firstname' => array('label' => $this->l('First Name *')),
'newsletter' => array('label' => $this->l('Newsletter (0/1)')),
'optin' => array('label' => $this->l('Opt-in (0/1)')),
'group' => array('label' => $this->l('Groupe Name')),
'id_shop' => array(
'label' => $this->l('ID / Name of shop'),
'help' => $this->l('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.'),
@@ -1891,6 +1892,7 @@ class AdminImportControllerCore extends AdminController
$customer_exist = false;
$this->receiveTab();
$handle = $this->openCsvFile();
$default_language_id = (int)Configuration::get('PS_LANG_DEFAULT');
AdminImportController::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++)
{
@@ -1923,6 +1925,26 @@ class AdminImportControllerCore extends AdminController
unset($customer_groups[$key]);
}
// Group Importation
if (isset($info['group']) && !empty($info['group']))
{
if (!isset($customer_groups))
$customer_groups = array();
$myGroup = Group::searchByName($default_language_id, $info['group']);
if (!$myGroup)
{
$myGroup = new Group();
$myGroup->name = Array($default_language_id => $info['group']);
$myGroup->price_display_method = 1;
$myGroup->add();
$myGroup = Group::searchByName($default_language_id, $info['group']);
}
if (isset($myGroup['0']['id_group']))
$customer_groups[] = $myGroup['0']['id_group'];
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
if ($customer->passwd)