// little fix sql categories and product
This commit is contained in:
@@ -1444,15 +1444,32 @@ class CategoryCore extends ObjectModel
|
||||
|
||||
public function addPosition($position, $id_shop = null)
|
||||
{
|
||||
$return = true;
|
||||
if (is_null($id_shop))
|
||||
{
|
||||
$id = Context::getContext()->shop->id;
|
||||
$id_shop = $id ? $id : Configuration::get('PS_SHOP_DEFAULT');
|
||||
if (Shop::getContext() != Shop::CONTEXT_SHOP)
|
||||
foreach (Shop::getContextListShopID() as $id_shop)
|
||||
$return &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'category_shop` (`id_category`, `id_shop`, `position`) VALUES
|
||||
('.(int)$this->id.', '.(int)$id_shop.', '.(int)$position.')
|
||||
ON DUPLICATE KEY UPDATE `position` = '.(int)$position);
|
||||
else
|
||||
{
|
||||
$id = Context::getContext()->shop->id;
|
||||
$id_shop = $id ? $id : Configuration::get('PS_SHOP_DEFAULT');
|
||||
$return &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'category_shop` (`id_category`, `id_shop`, `position`) VALUES
|
||||
('.(int)$this->id.', '.(int)$id_shop.', '.(int)$position.')
|
||||
ON DUPLICATE KEY UPDATE `position` = '.(int)$position);
|
||||
}
|
||||
}
|
||||
return Db::getInstance()->execute('
|
||||
else
|
||||
$return &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'category_shop` (`id_category`, `id_shop`, `position`) VALUES
|
||||
('.(int)$this->id.', '.(int)$id_shop.', '.(int)$position.')
|
||||
ON DUPLICATE KEY UPDATE `position` = '.(int)$position);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getShopsByCategory($id_category)
|
||||
|
||||
@@ -1986,7 +1986,7 @@ class AdminControllerCore extends Controller
|
||||
$this->_group .= ', a.'.pSQL($this->identifier);
|
||||
|
||||
$test_join = !preg_match('#`?'.preg_quote(_DB_PREFIX_.$this->table.'_shop').'`? *sa#', $this->_join);
|
||||
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $test_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).'))';
|
||||
|
||||
@@ -158,7 +158,7 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$this->_join = Shop::addSqlAssociation('category', 'a');
|
||||
// we add restriction for shop
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && $is_multishop)
|
||||
$this->_where = ' AND cs.`id_shop` = '.(int)Context::getContext()->shop->id;
|
||||
$this->_where = ' AND category_shop.`id_shop` = '.(int)Context::getContext()->shop->id;
|
||||
|
||||
$categories_tree = $this->_category->getParentsCategories();
|
||||
if (empty($categories_tree)
|
||||
|
||||
@@ -271,8 +271,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$orderWay = 'ASC';
|
||||
}
|
||||
|
||||
$alias = (Shop::getContext() != Shop::CONTEXT_SHOP) ? 'product_shop': 'sa';
|
||||
$this->_select .= ', '.$alias.'.`active`';
|
||||
$this->_select .= ', sa.`active`';
|
||||
if (!Tools::isSubmit('productFilter_active'))
|
||||
$this->_filter = '';
|
||||
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, $this->context->shop->id);
|
||||
|
||||
Reference in New Issue
Block a user