Merge branch 'alexandre-braderie' into develop
This commit is contained in:
commit
5c9f1e5d29
@ -257,38 +257,36 @@ class AdminProducts extends AdminTab
|
||||
|
||||
// Récupération de tous les produits de la catégorie ordonée
|
||||
// selon la position de la sous-catégorie puis de la position dans la sous catégorie et sinon par id_product
|
||||
$products = Db::getInstance()->ExecuteS('
|
||||
$first_products = Db::getInstance()->ExecuteS('
|
||||
SELECT cp.*
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.id_parent = cp.id_category)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp2 ON (cp2.id_category = c.id_category AND cp2.id_product=cp.id_product)
|
||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
||||
AND cp2.id_product IS NOT NULL
|
||||
ORDER BY c.position, cp2.position
|
||||
');
|
||||
$second_products = Db::getInstance()->ExecuteS('
|
||||
SELECT cp.*
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
||||
AND cp.id_product NOT IN
|
||||
(
|
||||
SELECT cp.*
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.id_parent = cp.id_category)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp2 ON (cp2.id_category = c.id_category AND cp2.id_product=cp.id_product)
|
||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
||||
AND cp2.id_product IS NOT NULL
|
||||
ORDER BY c.position, cp2.position
|
||||
)
|
||||
UNION
|
||||
(
|
||||
SELECT cp.*
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
||||
AND cp.id_product NOT IN
|
||||
(
|
||||
SELECT cp2.id_product
|
||||
FROM `'._DB_PREFIX_.'category_product` cp2
|
||||
WHERE cp2.id_category IN
|
||||
(
|
||||
SELECT id_category
|
||||
FROM `'._DB_PREFIX_.'category`
|
||||
WHERE id_parent ='.(int)$this->_category->id.'
|
||||
)
|
||||
)
|
||||
ORDER BY cp.id_product
|
||||
SELECT cp2.id_product
|
||||
FROM `'._DB_PREFIX_.'category_product` cp2
|
||||
WHERE cp2.id_category IN
|
||||
(
|
||||
SELECT id_category
|
||||
FROM `'._DB_PREFIX_.'category`
|
||||
WHERE id_parent ='.(int)$this->_category->id.'
|
||||
)
|
||||
)
|
||||
ORDER BY cp.id_product
|
||||
');
|
||||
|
||||
$products = array_merge($first_products,$second_products);
|
||||
// Update des postions
|
||||
foreach ($products as $key => $product) {
|
||||
if ($key == 0){
|
||||
|
Loading…
Reference in New Issue
Block a user