fix from prod on a cron
This commit is contained in:
parent
00428e330d
commit
c5a3c5af91
@ -19,7 +19,6 @@ foreach(Db::getInstance()->ExecuteS('
|
||||
') as $c){
|
||||
$categories[] = $c['id_category'];
|
||||
}
|
||||
|
||||
foreach ($categories as $key => $id_category) {
|
||||
$products = Db::getInstance()->ExecuteS('
|
||||
SELECT cp.`id_product`
|
||||
@ -29,14 +28,15 @@ foreach ($categories as $key => $id_category) {
|
||||
WHERE cp.id_category ='.(int)$id_category.' AND p.quantity != 0
|
||||
ORDER BY cp.`position`
|
||||
');
|
||||
|
||||
foreach ($products as $key => $product) {
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '. (int)($key) .'
|
||||
WHERE `id_product` = '.(int)($product['id_product']).'
|
||||
AND `id_category`='.(int)$id_category
|
||||
);
|
||||
if($products){
|
||||
foreach ($products as $key => $product) {
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '. (int)($key) .'
|
||||
WHERE `id_product` = '.(int)($product['id_product']).'
|
||||
AND `id_category`='.(int)$id_category
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$products_zero = Db::getInstance()->ExecuteS('
|
||||
@ -44,17 +44,19 @@ foreach ($categories as $key => $id_category) {
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product=p.id_product AND pl.`id_lang` = 1)
|
||||
WHERE cp.id_category ='.(int)$id_category.' AND p.quantity == 0
|
||||
WHERE cp.id_category ='.(int)$id_category.' AND p.quantity = 0
|
||||
ORDER BY cp.`position`
|
||||
');
|
||||
$position = count($products);
|
||||
foreach ($$products_zero as $key => $product) {
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '. (int)($position) .'
|
||||
WHERE `id_product` = '.(int)($product['id_product']).'
|
||||
AND `id_category`='.(int)$id_category
|
||||
);
|
||||
$position++;
|
||||
if($products_zero){
|
||||
$position = count($products);
|
||||
foreach ($products_zero as $key => $product) {
|
||||
Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'category_product`
|
||||
SET `position` = '. (int)($position) .'
|
||||
WHERE `id_product` = '.(int)($product['id_product']).'
|
||||
AND `id_category`='.(int)$id_category
|
||||
);
|
||||
$position++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user