bebeboutik-scripts/regeneration_order_state_current.php
2017-12-18 17:14:31 +01:00

32 lines
1.3 KiB
PHP

<?php
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
include('www/config/config.inc.php');
exit;
//$id_sale = 5840;
// foreach(Db::getInstance()->ExecuteS('
// SELECT DISTINCT o.`id_order`, oh.`id_order_state`
// FROM `ps_orders` o
// LEFT JOIN `ps_order_history` oh ON (oh.`id_order` = o.`id_order`)
// LEFT JOIN `ps_order_detail` d ON o.`id_order` = d.`id_order`
// LEFT JOIN `ps_product_ps_cache` c ON d.`product_id` = c.`id_product`
// LEFT JOIN `ps_philea_sent` pms ON (pms.`id_sale` = c.`id_sale` AND pms.`id_order` = o.`id_order`)
// WHERE c.`id_sale` = '.(int) $id_sale.'
// AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = o.`id_order` GROUP BY moh.`id_order`)
// -- AND oh.`id_order_state` IN (2, 3, 4, 13, 17, 9, 18, 19)
// AND pms.`id_order` IS NULL
// -- AND d.`product_quantity` - d.`product_quantity_refunded` > 0
// ') as $row){
// Db::getInstance()->ExecuteS('
// INSERT INTO `'._DB_PREFIX_.'order_state_current`
// VALUES (
// '.(int) $row['id_order'].',
// '.(int) $row['id_order_state'].',
// NOW()
// )
// ON DUPLICATE KEY UPDATE
// `id_order_state` = '.(int) $row['id_order_state'].',
// `date_upd` = NOW()
// ');
// }