1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<?php /** * TODO: Удаляем товары из корзины по крону, старше 6 часов, в 00 по мск */ /** * Логирование запуска скрипта */ function logSort() { $pid = getmypid(); $file = fopen('basket_clear.log', 'a+'); $message = "pid: [$pid] ClearBasket : " . date("d.m.Y H:i:s") . PHP_EOL; fwrite($file, $message); fclose($file); } logSort(); // подключаем prolog bitrix require $_SERVER["DOCUMENT_ROOT"] . '/bitrix/modules/main/include/prolog_before.php'; // подключаем нужные модули CModule::IncludeModule("sale"); $date = new DateTime(); $date->modify("-6 hour"); $date = $date->format("d.m.Y H:i:s"); $arBasketItems = array(); $dbBasketItems = CSaleBasket::GetList( array( "DATE_UPDATE" => "DESC" ), array( "ORDER_ID" => "NULL", "<=DATE_INSERT" => $date ), false, false, array("ID", "FUSER_ID", "USER_ID", "TIMESTAMP_X", "DATE_MODIFY_FROM", "DATE_INSERT", "DATE_UPDATE", "ORDER_ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT") ); while ($arItems = $dbBasketItems->Fetch()) { $arItems = CSaleBasket::GetByID($arItems["ID"]); CSaleBasket::Delete($arItems["ID"]); $arBasketItems[] = $arItems; } |
Bitrix очистка корзин/ ClearBasket