[*] BO : Changed the default list view for products and categories when multistore is activated

This commit is contained in:
dMetzger
2012-08-23 14:36:52 +00:00
parent 42291e1095
commit bdc79aeb65
10 changed files with 210 additions and 129 deletions
+20 -3
View File
@@ -86,6 +86,7 @@ class ShopCore extends ObjectModel
protected static $shops;
protected static $asso_tables = array();
protected static $id_shop_default_tables = array();
protected static $initialized = false;
protected $webserviceParameters = array(
@@ -139,6 +140,7 @@ class ShopCore extends ObjectModel
*/
protected static function init()
{
Shop::$id_shop_default_tables = array('product', 'category');
Shop::$asso_tables = array(
'carrier' => array('type' => 'shop'),
'carrier_lang' => array('type' => 'fk_shop'),
@@ -503,6 +505,18 @@ class ShopCore extends ObjectModel
Shop::init();
return (isset(Shop::$asso_tables[$table]) ? Shop::$asso_tables[$table] : false);
}
/**
* check if the table has an id_shop_default
*
* @return boolean
*/
public static function checkIdShopDefault($table)
{
if (!Shop::$initialized)
Shop::init();
return in_array($table, self::$id_shop_default_tables);
}
/**
* Get list of associated tables to shop
@@ -888,9 +902,12 @@ class ShopCore extends ObjectModel
return;
$sql = (($inner_join) ? ' INNER' : ' LEFT').' JOIN '._DB_PREFIX_.$table.'_shop '.$table_alias.'
ON '.$table_alias.'.id_'.$table.' = '.$alias.'.id_'.$table.'
AND '.$table_alias.'.id_shop IN ('.implode(', ', Shop::getContextListShopID()).')
'.(($on) ? ' AND '.$on : '');
ON ('.$table_alias.'.id_'.$table.' = '.$alias.'.id_'.$table;
if ((int)self::$context_id_shop)
$sql .= ' AND '.$table_alias.'.id_shop = '.(int)self::$context_id_shop;
elseif (Shop::checkIdShopDefault($table))
$sql .= ' AND '.$table_alias.'.id_shop = '.$alias.'.id_shop_default';
$sql .= (($on) ? ' AND '.$on : '').')';
return $sql;
}