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
|
// 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
|
// 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.*
|
SELECT cp2.id_product
|
||||||
FROM `'._DB_PREFIX_.'category_product` cp
|
FROM `'._DB_PREFIX_.'category_product` cp2
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.id_parent = cp.id_category)
|
WHERE cp2.id_category IN
|
||||||
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)
|
SELECT id_category
|
||||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
FROM `'._DB_PREFIX_.'category`
|
||||||
AND cp2.id_product IS NOT NULL
|
WHERE id_parent ='.(int)$this->_category->id.'
|
||||||
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
|
|
||||||
)
|
)
|
||||||
|
ORDER BY cp.id_product
|
||||||
');
|
');
|
||||||
|
|
||||||
|
$products = array_merge($first_products,$second_products);
|
||||||
// Update des postions
|
// Update des postions
|
||||||
foreach ($products as $key => $product) {
|
foreach ($products as $key => $product) {
|
||||||
if ($key == 0){
|
if ($key == 0){
|
||||||
|
Loading…
Reference in New Issue
Block a user