// Fix bugs with category positions

This commit is contained in:
rGaillard
2012-09-11 16:33:21 +00:00
parent 9f768e6b61
commit 479861bcc7
4 changed files with 24 additions and 17 deletions
+4 -4
View File
@@ -460,7 +460,7 @@ class CategoryCore extends ObjectModel
WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').' WHERE 1 '.$sql_filter.' '.($id_lang ? 'AND `id_lang` = '.(int)$id_lang : '').'
'.($active ? 'AND `active` = 1' : '').' '.($active ? 'AND `active` = 1' : '').'
'.(!$id_lang ? 'GROUP BY c.id_category' : '').' '.(!$id_lang ? 'GROUP BY c.id_category' : '').'
'.($sql_sort != '' ? $sql_sort : 'ORDER BY c.`level_depth` ASC, c.`position` ASC').' '.($sql_sort != '' ? $sql_sort : 'ORDER BY c.`level_depth` ASC, category_shop.`position` ASC').'
'.($sql_limit != '' ? $sql_limit : '') '.($sql_limit != '' ? $sql_limit : '')
); );
@@ -567,14 +567,14 @@ class CategoryCore extends ObjectModel
$order_way = 'ASC'; $order_way = 'ASC';
if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd') if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd')
$order_by_prefix = 'p'; $order_by_prefix = 'p';
else if ($order_by == 'name') elseif ($order_by == 'name')
$order_by_prefix = 'pl'; $order_by_prefix = 'pl';
else if ($order_by == 'manufacturer') elseif ($order_by == 'manufacturer')
{ {
$order_by_prefix = 'm'; $order_by_prefix = 'm';
$order_by = 'name'; $order_by = 'name';
} }
else if ($order_by == 'position') elseif ($order_by == 'position')
$order_by_prefix = 'cp'; $order_by_prefix = 'cp';
if ($order_by == 'price') if ($order_by == 'price')
@@ -162,14 +162,14 @@ class AdminCategoriesControllerCore extends AdminController
else else
$id_parent = $this->context->shop->id_category; $id_parent = $this->context->shop->id_category;
$this->_select = 'sa.position position';
$this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' '; $this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
if (Shop::isFeatureActive())
{ if (Shop::getContext() == Shop::CONTEXT_SHOP)
if (Shop::getContext() == Shop::CONTEXT_SHOP) $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = '.(int)$this->context->shop->id.') ';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = '.(int)$this->context->shop->id.') '; else
else
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = a.id_shop_default) '; $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'category_shop` sa ON (a.`id_category` = sa.`id_category` AND sa.id_shop = a.id_shop_default) ';
}
// we add restriction for shop // we add restriction for shop
if (Shop::getContext() == Shop::CONTEXT_SHOP && $is_multishop) if (Shop::getContext() == Shop::CONTEXT_SHOP && $is_multishop)
@@ -201,9 +201,7 @@ class AdminCategoriesControllerCore extends AdminController
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false) public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{ {
$alias = 'a'; $alias = 'sa';
if (Shop::isFeatureActive())
$alias = 'sa';
parent::getList($id_lang, $alias.'.position', $order_way, $start, $limit, Context::getContext()->shop->id); parent::getList($id_lang, $alias.'.position', $order_way, $start, $limit, Context::getContext()->shop->id);
// Check each row to see if there are combinations and get the correct action in consequence // Check each row to see if there are combinations and get the correct action in consequence
+6 -3
View File
@@ -158,7 +158,6 @@ class AdminImportControllerCore extends AdminController
'minimal_quantity' => 1, 'minimal_quantity' => 1,
'weight' => 0, 'weight' => 0,
'default_on' => 0, 'default_on' => 0,
'shop' => Configuration::get('PS_SHOP_DEFAULT'),
); );
break; break;
@@ -258,7 +257,6 @@ class AdminImportControllerCore extends AdminController
'link_rewrite' => array((int)Configuration::get('PS_LANG_DEFAULT') => ''), 'link_rewrite' => array((int)Configuration::get('PS_LANG_DEFAULT') => ''),
'online_only' => 0, 'online_only' => 0,
'condition' => 'new', 'condition' => 'new',
'shop' => Configuration::get('PS_SHOP_DEFAULT'),
'date_add' => date('Y-m-d H:i:s'), 'date_add' => date('Y-m-d H:i:s'),
'condition' => 'new', 'condition' => 'new',
); );
@@ -1012,8 +1010,10 @@ class AdminImportControllerCore extends AdminController
AdminImportController::setEntityDefaultValues($product); AdminImportController::setEntityDefaultValues($product);
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product); AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product);
if (!Shop::isFeatureActive() || !isset($product->shop) || empty($product->shop)) if (!Shop::isFeatureActive())
$product->shop = 1; $product->shop = 1;
elseif (!isset($product->shop) || empty($product->shop))
$product->shop = implode($this->multiple_value_separator, Shop::getContextListShopID());
if (!Shop::isFeatureActive()) if (!Shop::isFeatureActive())
$product->id_shop_default = 1; $product->id_shop_default = 1;
@@ -1457,6 +1457,9 @@ class AdminImportControllerCore extends AdminController
// Get shops for each attributes // Get shops for each attributes
$info['shop'] = explode($this->multiple_value_separator, $info['shop']); $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
if (!isset($info['shop']) || !count($info['shop']))
$info['shop'] = Shop::getContextListShopID();
$id_shop_list = array(); $id_shop_list = array();
foreach ($info['shop'] as $shop) foreach ($info['shop'] as $shop)
if (!is_numeric($shop)) if (!is_numeric($shop))
+7 -1
View File
@@ -78,6 +78,7 @@ class Blocktopmenu extends Module
!$this->registerHook('actionObjectManufacturerDeleteAfter') || !$this->registerHook('actionObjectManufacturerDeleteAfter') ||
!$this->registerHook('actionObjectProductUpdateAfter') || !$this->registerHook('actionObjectProductUpdateAfter') ||
!$this->registerHook('actionObjectProductDeleteAfter') || !$this->registerHook('actionObjectProductDeleteAfter') ||
!$this->registerHook('categoryUpdate') ||
!$this->installDB()) !$this->installDB())
return false; return false;
return true; return true;
@@ -805,7 +806,7 @@ class Blocktopmenu extends Module
$this->clearMenuCache(); $this->clearMenuCache();
} }
public function hookActionObjectCmsUpdateUpdate($params) public function hookActionObjectCmsUpdateAfter($params)
{ {
$this->clearMenuCache(); $this->clearMenuCache();
} }
@@ -845,6 +846,11 @@ class Blocktopmenu extends Module
$this->clearMenuCache(); $this->clearMenuCache();
} }
public function hookCategoryUpdate($params)
{
$this->clearMenuCache();
}
private function clearMenuCache() private function clearMenuCache()
{ {
$this->_clearCache('blocktopmenu.tpl'); $this->_clearCache('blocktopmenu.tpl');