[*] 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

View File

@@ -47,6 +47,9 @@ class CategoryCore extends ObjectModel
/** @var integer Parent category ID */
public $id_parent;
/** @var integer default Category id */
public $id_category_default;
/** @var integer Parents number */
public $level_depth;
@@ -95,6 +98,7 @@ class CategoryCore extends ObjectModel
'level_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'is_root_category' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'position' => array('type' => self::TYPE_INT),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),

View File

@@ -449,9 +449,19 @@ abstract class ObjectModelCore
if ($autodate && property_exists($this, 'date_upd'))
$this->date_upd = date('Y-m-d H:i:s');
if (Shop::isTableAssociated($this->def['table']))
{
$id_shop_list = Shop::getContextListShopID();
if (count($this->id_shop_list) > 0)
$id_shop_list = $this->id_shop_list;
}
// Database insertion
if (isset($this->id))
unset($this->id);
if (Shop::checkIdShopDefault($this->def['table']))
$this->id_shop_default = min($id_shop_list);
if (!$result = ObjectModel::$db->insert($this->def['table'], $this->getFields(), $null_values))
return false;
@@ -461,10 +471,6 @@ abstract class ObjectModelCore
// Database insertion for multishop fields related to the object
if (Shop::isTableAssociated($this->def['table']))
{
$id_shop_list = Shop::getContextListShopID();
if (count($this->id_shop_list) > 0)
$id_shop_list = $this->id_shop_list;
$fields = $this->getFieldsShop();
$fields[$this->def['primary']] = (int)$this->id;
@@ -534,7 +540,13 @@ abstract class ObjectModelCore
// Automatically fill dates
if (array_key_exists('date_upd', $this))
$this->date_upd = date('Y-m-d H:i:s');
$id_shop_list = Shop::getContextListShopID();
if (count($this->id_shop_list) > 0)
$id_shop_list = $this->id_shop_list;
if (Shop::checkIdShopDefault($this->def['table']))
$this->id_shop_default = min($id_shop_list);
// Database update
if (!$result = ObjectModel::$db->update($this->def['table'], $this->getFields(), '`'.pSQL($this->def['primary']).'` = '.(int)$this->id, 0, $null_values))
return false;
@@ -555,9 +567,6 @@ abstract class ObjectModelCore
else
$all_fields = $fields;
$id_shop_list = Shop::getContextListShopID();
if (count($this->id_shop_list) > 0)
$id_shop_list = $this->id_shop_list;
foreach ($id_shop_list as $id_shop)
{

View File

@@ -51,6 +51,9 @@ class ProductCore extends ObjectModel
/** @var integer default Category id */
public $id_category_default;
/** @var integer default Shop id */
public $id_shop_default;
/** @var string Manufacturer name */
public $manufacturer_name;
@@ -237,6 +240,7 @@ class ProductCore extends ObjectModel
'multilang_shop' => true,
'fields' => array(
// Classic fields
'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'reference' => array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 32),
@@ -2451,7 +2455,7 @@ class ProductCore extends ObjectModel
LIMIT 1
) as default_on');
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product` = '.(int)$id_product);
$sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false));
$sql->join(Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.id_shop = p.id_shop_default'));
}
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);

View File

@@ -109,6 +109,9 @@ class AdminControllerCore extends Controller
protected $shopLink;
/** @var string SQL query */
protected $_listsql = '';
/** @var array Cache for query results */
protected $_list = array();
@@ -248,6 +251,7 @@ class AdminControllerCore extends Controller
public $controller_name;
public $multishop_context = -1;
public $multishop_context_group = true;
/**
* Current breadcrumb position as an array of tab names
@@ -1927,6 +1931,9 @@ class AdminControllerCore extends Controller
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
if (!empty($this->_listsql))
return;
/* Manage default params values */
$use_limit = true;
if ($limit === false)
@@ -1997,22 +2004,19 @@ class AdminControllerCore extends Controller
$where_shop = Shop::addSqlRestriction($this->shopShareDatas, 'a', $this->shopLinkType);
}
$filter_shop = '';
if ($this->multishop_context && Shop::isTableAssociated($this->table) && !empty($this->className))
{
if (Shop::getContext() != Shop::CONTEXT_ALL || Shop::isTableAssociated($this->table) || !$this->context->employee->isSuperAdmin())
{
$idenfier_shop = Shop::getContextListShopID();
if (!$this->_group)
$this->_group = ' GROUP BY a.'.pSQL($this->identifier);
elseif (!preg_match('#(\s|,)\s*a\.`?'.pSQL($this->identifier).'`?(\s|,|$)#', $this->_group))
$this->_group .= ', a.'.pSQL($this->identifier);
$identifier_shop = Shop::getContextListShopID();
$test_join = !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_shop').'`? *sa#', $this->_join);
if (Shop::isFeatureActive() && $test_join)
{
$filter_shop = ' JOIN `'._DB_PREFIX_.$this->table.'_shop` sa ';
$filter_shop .= 'ON (sa.'.$this->identifier.' = a.'.$this->identifier.' AND sa.id_shop IN ('.implode(', ', $idenfier_shop).'))';
$this->_where .= ' AND a.'.$this->identifier.' IN (
SELECT sa.'.$this->identifier.'
FROM `'._DB_PREFIX_.$this->table.'_shop` sa
WHERE sa.id_shop IN ('.implode(', ', $identifier_shop).')
)';
}
}
}
@@ -2021,13 +2025,14 @@ class AdminControllerCore extends Controller
$lang_join = '';
if ($this->lang)
{
$lang_join = 'LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` b ON (b.`'.$this->identifier.'` = a.`'.$this->identifier.'`';
$lang_join .= ' AND b.`id_lang` = '.(int)$id_lang;
$lang_join = 'LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` b ON (b.`'.$this->identifier.'` = a.`'.$this->identifier.'` AND b.`id_lang` = '.(int)$id_lang;
if ($id_lang_shop)
{
if (Shop::getContext() == Shop::CONTEXT_SHOP)
$lang_join .= ' AND b.`id_shop`='.(int)$id_lang_shop;
$lang_join .= ' AND b.`id_shop` = '.(int)$id_lang_shop;
else
$lang_join .= ' AND b.`id_shop` IN ('.implode(',', array_map('intval', Shop::getContextListShopID())).')';
$lang_join .= ' AND b.`id_shop` = a.id_shop_default';
}
$lang_join .= ')';
}
@@ -2047,23 +2052,23 @@ class AdminControllerCore extends Controller
$order_by = pSQL($order_by[0]).'.`'.pSQL($order_by[1]).'`';
}
$sql = 'SELECT SQL_CALC_FOUND_ROWS
'.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '').'
'.($this->lang ? 'b.*, ' : '').'a.*'.(isset($this->_select) ? ', '.$this->_select.' ' : '').$select_shop.'
FROM `'._DB_PREFIX_.$sql_table.'` a
'.$filter_shop.'
'.$lang_join.'
'.(isset($this->_join) ? $this->_join.' ' : '').'
'.$join_shop.'
WHERE 1 '.(isset($this->_where) ? $this->_where.' ' : '').($this->deleted ? 'AND a.`deleted` = 0 ' : '').
(isset($this->_filter) ? $this->_filter : '').$where_shop.'
'.(isset($this->_group) ? $this->_group.' ' : '').'
'.$having_clause.'
ORDER BY '.(($order_by == $this->identifier) ? 'a.' : '').pSQL($order_by).' '.pSQL($order_way).
($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').
(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');
$this->_listsql = '
SELECT SQL_CALC_FOUND_ROWS
'.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '').'
'.($this->lang ? 'b.*, ' : '').'a.*'.(isset($this->_select) ? ', '.$this->_select.' ' : '').$select_shop.'
FROM `'._DB_PREFIX_.$sql_table.'` a
'.$lang_join.'
'.(isset($this->_join) ? $this->_join.' ' : '').'
'.$join_shop.'
WHERE 1 '.(isset($this->_where) ? $this->_where.' ' : '').($this->deleted ? 'AND a.`deleted` = 0 ' : '').
(isset($this->_filter) ? $this->_filter : '').$where_shop.'
'.(isset($this->_group) ? $this->_group.' ' : '').'
'.$having_clause.'
ORDER BY '.(($order_by == $this->identifier) ? 'a.' : '').pSQL($order_by).' '.pSQL($order_way).
($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').
(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');
$this->_list = Db::getInstance()->executeS($sql);
$this->_list = Db::getInstance()->executeS($this->_listsql);
$this->_listTotal = Db::getInstance()->getValue('SELECT FOUND_ROWS() AS `'._DB_PREFIX_.$this->table.'`');
}

View File

@@ -361,9 +361,10 @@ class HelperCore
$context = Context::getContext();
// Get default value
if (Shop::getContext() == Shop::CONTEXT_ALL)
$shop_context = Shop::getContext();
if ($shop_context == Shop::CONTEXT_ALL || ($context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP))
$value = '';
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
else if ($shop_context == Shop::CONTEXT_GROUP)
$value = 'g-'.Shop::getContextShopGroupID();
else
$value = 's-'.Shop::getContextShopID();
@@ -376,9 +377,9 @@ class HelperCore
foreach ($tree as $gID => $group_data)
{
if ((!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP))
$html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').'>'.Translate::getAdminTranslation('Group:').' '.htmlspecialchars($group_data['name']).'</option>';
$html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').' '.($context->controller->multishop_context_group == false ? 'disabled="disabled"' : '').'>'.Translate::getAdminTranslation('Group:').' '.htmlspecialchars($group_data['name']).'</option>';
else
$html .= '<optgroup class="group" label="'.Translate::getAdminTranslation('Group:').' '.htmlspecialchars($group_data['name']).'">';
$html .= '<optgroup class="group" label="'.Translate::getAdminTranslation('Group:').' '.htmlspecialchars($group_data['name']).'" '.($context->controller->multishop_context_group == false ? 'disabled="disabled"' : '').'>';
if (!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_SHOP)
foreach ($group_data['shops'] as $sID => $shopData)

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;
}

View File

@@ -163,12 +163,17 @@ class AdminCategoriesControllerCore extends AdminController
$id_parent = $this->context->shop->id_category;
$this->_filter .= ' AND `id_parent` = '.(int)$id_parent.' ';
$this->_select = 'category_shop.`position` ';
$this->_join = Shop::addSqlAssociation('category', 'a');
$this->_group = 'GROUP BY a.id_category';
if (Shop::isFeatureActive())
{
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.') ';
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) ';
}
// we add restriction for shop
if (Shop::getContext() == Shop::CONTEXT_SHOP && $is_multishop)
$this->_where = ' AND category_shop.`id_shop` = '.(int)Context::getContext()->shop->id;
$this->_where = ' AND sa.`id_shop` = '.(int)Context::getContext()->shop->id;
$categories_tree = $this->_category->getParentsCategories();
if (empty($categories_tree)
@@ -196,7 +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)
{
parent::getList($id_lang, 'category_shop.position', $order_way, $start, $limit, Context::getContext()->shop->id);
parent::getList($id_lang, 'sa.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
$nb_items = count($this->_list);
@@ -499,6 +504,9 @@ class AdminCategoriesControllerCore extends AdminController
public function postProcess()
{
if (!in_array($this->display, array('edit', 'add')))
$this->multishop_context_group = false;
if (Tools::isSubmit('forcedeleteImage'))
{
$this->processForceDeleteImage();

View File

@@ -78,6 +78,9 @@ class AdminProductsControllerCore extends AdminController
$this->lang = true;
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
if (!Tools::getValue('id_product'))
$this->multishop_context_group = false;
parent::__construct();
$this->imageType = 'jpg';
@@ -85,75 +88,82 @@ class AdminProductsControllerCore extends AdminController
$this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
$this->fields_list = array(
'id_product' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 20
),
'image' => array(
'title' => $this->l('Photo'),
'align' => 'center',
'image' => 'p',
'width' => 70,
'orderby' => false,
'filter' => false,
'search' => false
),
'name' => array(
'title' => $this->l('Name'),
'filter_key' => 'b!name'
),
'reference' => array(
'title' => $this->l('Reference'),
'align' => 'left',
'width' => 80
),
'name_category' => array(
$this->fields_list = array();
$this->fields_list['id_product'] = array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 20
);
$this->fields_list['image'] = array(
'title' => $this->l('Photo'),
'align' => 'center',
'image' => 'p',
'width' => 70,
'orderby' => false,
'filter' => false,
'search' => false
);
$this->fields_list['name'] = array(
'title' => $this->l('Name'),
'filter_key' => 'b!name'
);
$this->fields_list['reference'] = array(
'title' => $this->l('Reference'),
'align' => 'left',
'width' => 80
);
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
$this->fields_list['shopname'] = array(
'title' => $this->l('Default Shop'),
'width' => 230,
'filter_key' => 'shop!name',
);
else
$this->fields_list['name_category'] = array(
'title' => $this->l('Category'),
'width' => 230,
'filter_key' => 'cl!name',
),
'price' => array(
'title' => $this->l('Base price'),
'width' => 90,
'type' => 'price',
'align' => 'right',
'filter_key' => 'a!price'
),
'price_final' => array(
'title' => $this->l('Final price'),
'width' => 90,
'type' => 'price',
'align' => 'right',
'havingFilter' => true,
'orderby' => false
),
'sav_quantity' => array(
'title' => $this->l('Quantity'),
'width' => 90,
'align' => 'right',
'filter_key' => 'sav!quantity',
'orderby' => true,
'hint' => $this->l('This is the quantity available in the current shop/group'),
),
'active' => array(
'title' => $this->l('Displayed'),
'width' => 70,
'active' => 'status',
'filter_key' => 'a!active',
'align' => 'center',
'type' => 'bool',
'orderby' => false
),
'position' => array(
'title' => $this->l('Position'),
'width' => 70,
'filter_key' => 'cp!position',
'align' => 'center',
'position' => 'position'
)
);
$this->fields_list['price'] = array(
'title' => $this->l('Base price'),
'width' => 90,
'type' => 'price',
'align' => 'right',
'filter_key' => 'a!price'
);
$this->fields_list['price_final'] = array(
'title' => $this->l('Final price'),
'width' => 90,
'type' => 'price',
'align' => 'right',
'havingFilter' => true,
'orderby' => false
);
$this->fields_list['sav_quantity'] = array(
'title' => $this->l('Quantity'),
'width' => 90,
'align' => 'right',
'filter_key' => 'sav!quantity',
'orderby' => true,
'hint' => $this->l('This is the quantity available in the current shop/group'),
);
$this->fields_list['active'] = array(
'title' => $this->l('Displayed'),
'width' => 70,
'active' => 'status',
'filter_key' => 'a!active',
'align' => 'center',
'type' => 'bool',
'orderby' => false
);
$this->fields_list['position'] = array(
'title' => $this->l('Position'),
'width' => 70,
'filter_key' => 'cp!position',
'align' => 'center',
'position' => 'position'
);
// @since 1.5 : translations for tabs
$this->available_tabs_lang = array (
@@ -195,22 +205,39 @@ class AdminProductsControllerCore extends AdminController
$this->_category = new Category((int)$id_category);
else
$this->_category = new Category();
$alias = Shop::isFeatureActive() ? 'sa' : 'a';
$this->_join =
'LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang`)
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON ('.$alias.'.`id_tax_rules_group` = tr.`id_tax_rules_group`
AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0
'.StockAvailable::addSqlShopRestriction(null, null, 'sav').')';
// if no category selected, display all products
$join_category = false;
if (Validate::isLoadedObject($this->_category) && empty($this->_filter))
$this->_filter = 'AND cp.`id_category` = '.(int)$this->_category->id;
$join_category = true;
$this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, '.$alias.'.`price`, ('.$alias.'.`price` * ((100 + (t.`rate`))/100)) AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
if (Shop::isFeatureActive())
{
$alias = 'sa';
if (Shop::getContext() == Shop::CONTEXT_SHOP)
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.(int)$this->context->shop->id.') ';
else
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default) ';
$this->_select .= 'shop.name as shopname, ';
}
else
{
$alias = 'a';
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = 1)';
}
$this->_join .= '
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1)
'.($join_category ? 'LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.')' : '').'
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON ('.$alias.'.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0)
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0
'.StockAvailable::addSqlShopRestriction(null, null, 'sav').') ';
$this->_select .= 'cl.name `name_category` '.($join_category ? ', cp.`position`' : '').', i.`id_image`, '.$alias.'.`price`, ('.$alias.'.`price` * ((100 + (t.`rate`))/100)) AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
}
protected function _cleanMetaKeywords($keywords)

View File

@@ -310,6 +310,7 @@ CREATE TABLE `PREFIX_cart_product` (
CREATE TABLE `PREFIX_category` (
`id_category` int(10) unsigned NOT NULL auto_increment,
`id_parent` int(10) unsigned NOT NULL,
`id_shop_default` int(10) unsigned NOT NULL default 1,
`level_depth` tinyint(3) unsigned NOT NULL default '0',
`nleft` int(10) unsigned NOT NULL default '0',
`nright` int(10) unsigned NOT NULL default '0',
@@ -1343,6 +1344,7 @@ CREATE TABLE `PREFIX_product` (
`id_supplier` int(10) unsigned default NULL,
`id_manufacturer` int(10) unsigned default NULL,
`id_category_default` int(10) unsigned default NULL,
`id_shop_default` int(10) unsigned NOT NULL default 1,
`id_tax_rules_group` INT(11) UNSIGNED NOT NULL,
`on_sale` tinyint(1) unsigned NOT NULL default '0',
`online_only` tinyint(1) unsigned NOT NULL default '0',
@@ -2403,7 +2405,6 @@ CREATE TABLE `PREFIX_category_shop` (
`id_shop` int(11) NOT NULL,
`position` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id_category`, `id_shop`),
UNIQUE KEY `id_category_shop` (`id_category`,`id_shop`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_module_preference` (

View File

@@ -14,3 +14,8 @@ UPDATE `PREFIX_employee` SET bo_theme = 'default';
ALTER TABLE `PREFIX_tax_rule` ADD INDEX `category_getproducts` ( `id_tax_rules_group` , `id_country` , `id_state` , `zipcode_from` );
ALTER TABLE `PREFIX_stock_available` ADD INDEX `product_sqlstock` ( `id_product` , `id_product_attribute` , `id_shop` );
ALTER TABLE `PREFIX_product` ADD `id_shop_default` int(10) unsigned NOT NULL default 1 AFTER `id_category_default`;
UPDATE `PREFIX_product` p SET `id_shop_default` = IFNULL((SELECT MIN(id_shop) FROM `PREFIX_product_shop` ps WHERE ps.`id_product` = p.`id_product`), 1);
ALTER TABLE `PREFIX_category` ADD `id_shop_default` int(10) unsigned NOT NULL default 1 AFTER `id_parent`;
UPDATE `PREFIX_category` c SET `id_shop_default` = IFNULL((SELECT MIN(id_shop) FROM `PREFIX_category_shop` cs WHERE cs.`id_category` = c.`id_category`), 1);