37 public static function getList(array $parameters = array())
39 return Internals\BasketTable::getList($parameters);
49 public static function deleteNoDemand($idOrder)
53 $itemsDataList = static::getList(
55 "filter" => array(
"=ORDER_ID" => $idOrder),
56 "select" => array(
"ID",
"TYPE")
61 $itemClassName = static::getItemCollectionClassName();
62 while ($item = $itemsDataList->fetch())
64 if ($item[
'TYPE'] === $itemClassName::TYPE_SET)
66 $r = Internals\BasketTable::deleteBundle($item[
'ID']);
70 $r = Internals\BasketTable::deleteWithItems($item[
'ID']);
75 $result->addErrors($r->getErrors());
87 public static function deleteOld($days)
89 $expired =
new Main\Type\DateTime();
90 $expired->add(
'-'.$days.
' days');
91 $expiredValue = $expired->format(
'Y-m-d H:i:s');
94 $connection = Main\Application::getConnection();
96 $sqlHelper = $connection->getSqlHelper();
98 $sqlExpiredDate = $sqlHelper->getDateToCharFunction(
"'" . $expiredValue .
"'");
100 $query =
"DELETE FROM b_sale_basket WHERE
102 SELECT b_sale_fuser.id FROM b_sale_fuser WHERE
103 b_sale_fuser.DATE_UPDATE < ".$sqlExpiredDate.
"
104 AND b_sale_fuser.USER_ID IS NULL
105 ) AND ORDER_ID IS NULL LIMIT ". static::BASKET_DELETE_LIMIT;
107 $connection->queryExecute($query);
108 $affectRows = $connection->getAffectedRowsCount();
110 $query =
"DELETE FROM b_sale_basket
112 FUSER_ID NOT IN (SELECT b_sale_fuser.id FROM b_sale_fuser)
115 LIMIT ". static::BASKET_DELETE_LIMIT;
117 $connection->queryExecute($query);
118 $affectRows = max($affectRows, $connection->getAffectedRowsCount());
122 FROM b_sale_basket_props
123 WHERE b_sale_basket_props.BASKET_ID NOT IN (
124 SELECT b_sale_basket.ID FROM b_sale_basket
126 LIMIT ".static::BASKET_DELETE_LIMIT;
128 $connection->queryExecute($query);
130 return max($affectRows, $connection->getAffectedRowsCount());
148 $affectRows = static::deleteOld($days);
149 Fuser::deleteOld($days);
151 $days = intval(Main\
Config\Option::get(
"sale",
"delete_after",
"30"));
152 $result =
"\Bitrix\Sale\Basket::deleteOldAgent(".$days.
");";
154 if ($affectRows === static::BASKET_DELETE_LIMIT)
175 public function getListOfFormatText()
180 $basketItemClassName = static::getItemCollectionClassName();
183 foreach ($this->collection as $basketItem)
185 $basketItemData = $basketItem->getField(
"NAME");
188 if ($basketPropertyCollection = $basketItem->getPropertyCollection())
190 $basketItemDataProperty =
"";
192 foreach ($basketPropertyCollection as $basketPropertyItem)
194 if ($basketPropertyItem->getField(
'CODE') ==
"PRODUCT.XML_ID"
195 || $basketPropertyItem->getField(
'CODE') ==
"CATALOG.XML_ID"
196 || $basketPropertyItem->getField(
'CODE') ==
"SUM_OF_CHARGE"
202 if (strval(trim($basketPropertyItem->getField(
'VALUE'))) ==
"")
206 $basketItemDataProperty .= (!empty($basketItemDataProperty) ?
"; " :
"").trim($basketPropertyItem->getField(
'NAME')).
": ".trim($basketPropertyItem->getField(
'VALUE'));
209 if (!empty($basketItemDataProperty))
210 $basketItemData .=
" [".$basketItemDataProperty.
"]";
213 $measure = (strval($basketItem->getField(
"MEASURE_NAME")) !=
'') ? $basketItem->getField(
"MEASURE_NAME") :
Loc::getMessage(
"SOA_SHT");
214 $list[$basketItem->getBasketCode()] = $basketItemData.
" - ".$basketItemClassName::formatQuantity($basketItem->getQuantity()).
" ".$measure.
" x ".SaleFormatCurrency($basketItem->getPrice(), $basketItem->getCurrency());
218 return !empty($list) ? $list :
false;
226 public function save()
228 $result = parent::save();
236 $orderHistory = $registry->getOrderHistoryClassName();
237 $orderHistory::collectEntityFields(
'BASKET', $orderId);
252 $result =
new Result();
255 $itemClassName = static::getItemCollectionClassName();
256 if ($itemValues[
'TYPE'] == $itemClassName::TYPE_SET)
258 $r = Internals\BasketTable::deleteBundle($itemValues[
'ID']);
262 $r = Internals\BasketTable::deleteWithItems($itemValues[
'ID']);
265 if (!$r->isSuccess())
267 $result->addErrors($r->getErrors());
276 $orderHistory = $registry->getOrderHistoryClassName();
277 $orderHistory::addLog(
280 'BASKET_ITEM_DELETED',
284 "PRODUCT_ID" => $itemValues[
"PRODUCT_ID"],
285 "NAME" => $itemValues[
"NAME"],
286 "QUANTITY" => $itemValues[
"QUANTITY"],
288 $orderHistory::SALE_ORDER_HISTORY_LOG_LEVEL_1
302 parent::callEventOnSaleBasketItemDeleted($itemValues);
310 $orderHistory = $registry->getOrderHistoryClassName();
311 $orderHistory::addAction(
318 'NAME' => $itemValues[
'NAME'],
319 'QUANTITY' => $itemValues[
'QUANTITY'],
320 'PRODUCT_ID' => $itemValues[
'PRODUCT_ID'],
325 $entityMarker = $registry->getEntityMarkerClassName();
326 $entityMarker::deleteByFilter(array(
327 '=ORDER_ID' => $orderId,
328 '=ENTITY_TYPE' => $entityMarker::ENTITY_TYPE_BASKET_ITEM,
329 '=ENTITY_ID' => $itemValues[
'ID'],
346 public function deleteItem($index)
352 $item = $this->getItemByIndex($index);
354 $order->onBeforeBasketItemDelete($item);
357 return parent::deleteItem($index);
static getMessage($code, $replace=null, $language=null)
$GLOBALS['____1444769544']