[-] BO : #PSCFV-2562 - Select all categories on creating a new shop
This commit is contained in:
@@ -744,17 +744,17 @@ class CategoryCore extends ObjectModel
|
|||||||
public static function getChildren($id_parent, $id_lang, $active = true, $id_shop = false)
|
public static function getChildren($id_parent, $id_lang, $active = true, $id_shop = false)
|
||||||
{
|
{
|
||||||
if (!Validate::isBool($active))
|
if (!Validate::isBool($active))
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
|
||||||
$query = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, category_shop.`id_shop`
|
$query = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, category_shop.`id_shop`
|
||||||
FROM `'._DB_PREFIX_.'category` c
|
FROM `'._DB_PREFIX_.'category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||||
'.Shop::addSqlAssociation('category', 'c').'
|
'.Shop::addSqlAssociation('category', 'c').'
|
||||||
WHERE `id_lang` = '.(int)$id_lang.'
|
WHERE `id_lang` = '.(int)$id_lang.'
|
||||||
AND c.`id_parent` = '.(int)$id_parent.'
|
AND c.`id_parent` = '.(int)$id_parent.'
|
||||||
'.($active ? 'AND `active` = 1' : '').'
|
'.($active ? 'AND `active` = 1' : '').'
|
||||||
|
GROUP BY c.`id_category`
|
||||||
ORDER BY category_shop.`position` ASC';
|
ORDER BY category_shop.`position` ASC';
|
||||||
|
|
||||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ class AdminShopControllerCore extends AdminController
|
|||||||
$this->errors[] = Tools::displayError('An error occurred while creating object.').
|
$this->errors[] = Tools::displayError('An error occurred while creating object.').
|
||||||
' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
|
' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
|
||||||
}
|
}
|
||||||
/* voluntary do affectation here */
|
/* voluntary do affectation here */
|
||||||
else if (($_POST[$this->identifier] = $object->id) && $this->postImage($object->id) && !count($this->errors) && $this->_redirect)
|
else if (($_POST[$this->identifier] = $object->id) && $this->postImage($object->id) && !count($this->errors) && $this->_redirect)
|
||||||
{
|
{
|
||||||
$parent_id = (int)Tools::getValue('id_parent', 1);
|
$parent_id = (int)Tools::getValue('id_parent', 1);
|
||||||
@@ -569,8 +569,8 @@ class AdminShopControllerCore extends AdminController
|
|||||||
$this->errors = array_unique($this->errors);
|
$this->errors = array_unique($this->errors);
|
||||||
if (count($this->errors) > 0)
|
if (count($this->errors) > 0)
|
||||||
{
|
{
|
||||||
$this->display = 'add';
|
$this->display = 'add';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// datas to import
|
// datas to import
|
||||||
@@ -601,11 +601,13 @@ class AdminShopControllerCore extends AdminController
|
|||||||
if (empty($selected_cat))
|
if (empty($selected_cat))
|
||||||
{
|
{
|
||||||
// get first category root and preselect all these children
|
// get first category root and preselect all these children
|
||||||
$root_category = Category::getRootCategories();
|
$root_categories = Category::getRootCategories();
|
||||||
$children = Category::getChildren($root_category[0]['id_category'], $this->context->language->id);
|
$root_category = new Category($root_categories[0]['id_category']);
|
||||||
$selected_cat[] = $root_category[0]['id_category'];
|
$children = $root_category->getAllChildren($this->context->language->id);
|
||||||
|
$selected_cat[] = $root_categories[0]['id_category'];
|
||||||
|
|
||||||
foreach ($children as $child)
|
foreach ($children as $child)
|
||||||
$selected_cat[] = $child['id_category'];
|
$selected_cat[] = $child->id_category;
|
||||||
}
|
}
|
||||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop'))
|
if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop'))
|
||||||
$root_category = new Category($shop->id_category);
|
$root_category = new Category($shop->id_category);
|
||||||
|
|||||||
Reference in New Issue
Block a user