28 "ACCOUNT_NUMBER",
"USER_ID",
"PRICE",
"SUM_PAID",
"CURRENCY",
"STATUS_ID",
"PAYED",
"DEDUCTED",
"CANCELED",
29 "LID",
"PERSON_TYPE_ID",
"XML_ID",
"ID_1C",
"DATE_INSERT",
"RESPONSIBLE_ID",
"COMPANY_ID"
39 "PRODUCT_ID",
"PRODUCT_PRICE_ID",
"NAME",
"PRICE",
"MODULE",
"QUANTITY",
"WEIGHT",
"DATE_INSERT",
40 "CURRENCY",
"PRODUCT_XML_ID",
"MEASURE_NAME",
"TYPE",
"SET_PARENT_ID",
"MEASURE_CODE",
"BASKET_DATA"
55 public static function archiveOrders($filter = array(), $limit =
null, $timeExecution =
null)
60 if ((
int)$timeExecution)
65 $params[
"filter"] = $filter;
66 $params[
"order"] = array(
'ID' =>
"ASC");
69 $params[
"limit"] = (int)$limit;
72 $orderArchiveCollection =
new Process\OrderArchiveCollection();
73 $fillResult = $orderArchiveCollection->loadFromDB($params);
74 if ($fillResult->hasWarnings())
80 foreach ($orderArchiveCollection as $index => $item)
82 $resultArchiving = $item->archive();
83 if ($resultArchiving->isSuccess())
86 $orderArchiveCollection->deleteItem($index);
90 $errorMessages = $resultArchiving->getErrorMessages();
91 foreach ($errorMessages as $error)
93 $result->addError(
new Main\
Error(
Loc::getMessage(
"ARCHIVE_ERROR_ORDER_MESSAGE", array(
"#ID#" => $item->getId())).
": ".$error));
97 if ((
int)$timeExecution && (getmicrotime() - START_EXEC_TIME > $timeExecution))
103 $result->setData(array(
"count" => $countArchived));
121 $filter = Option::get(
'sale',
'archive_params');
128 $filter = unserialize($filter, [
'allowed_classes' =>
false]);
130 if (isset($filter[
'PERIOD']))
132 if ((
int)$filter[
'PERIOD'] > 0)
135 $latestDate = $date->add(
'-'.(
int)$filter[
'PERIOD'].
' day');
136 $filter[
'<=DATE_INSERT'] = $latestDate;
139 unset($filter[
'PERIOD']);
142 return static::archiveOrders($filter, $limit, $timeExecution);
160 $limit = (int)$limit ? (
int)$limit : 10;
161 $maxTime = (int)$maxTime ? (
int)$maxTime :
null;
163 $agentsList = \CAgent::GetList(array(
"ID"=>
"DESC"), array(
164 "MODULE_ID" =>
"sale",
165 "NAME" =>
"\\Bitrix\\Sale\\Archive\\Manager::archiveOnAgent(%",
167 while($agent = $agentsList->Fetch())
169 $agentId = $agent[
"ID"];
174 if (!(isset($USER) && $USER instanceof \CUser))
176 $USER = new \CUser();
179 $result = static::archiveByOptions($limit, $maxTime);
181 $resultData = $result->getData();
182 if ($resultData[
'count'])
184 \CAgent::Update($agentId, array(
"AGENT_INTERVAL" => 60*5));
189 \CAgent::Update($agentId, array(
"AGENT_INTERVAL" => 24*60*60));
194 \CAgent::AddAgent(
"\\Bitrix\\Sale\\Archive\\Manager::archiveOnAgent(".$limit.
",".$maxTime.
");",
"sale",
"N", 24*60*60,
"",
"Y");
197 return "\\Bitrix\\Sale\\Archive\\Manager::archiveOnAgent(".$limit.
",".$maxTime.
");";
205 public static function getList(array $parameters = array())
207 return Internals\OrderArchiveTable::getList($parameters);
219 return Internals\OrderArchiveTable::getById($id);
232 return Internals\BasketArchiveTable::getList($parameters);
245 return Internals\BasketArchiveTable::getById($id);
256 public static function delete($id)
258 $basketItems = static::getBasketList(
260 "filter" => array(
"ARCHIVE_ID" => $id),
261 "select" => array(
"ID")
264 while ($item = $basketItems->fetch())
266 Internals\BasketArchiveTable::delete($item[
'ID']);
269 return Internals\OrderArchiveTable::delete($id);
287 $restorer = Recovery\Restorer::load($id);
293 return $restorer->restoreOrder();
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)