示例#1
0
 /**
  * @param array $arOrder
  * @param array $arFilter
  * @param bool $arGroupBy
  * @param bool $arNavStartParams
  * @param array $arSelectFields
  * @return \CDBResult
  * @throws \Bitrix\Main\ArgumentException
  * @deprecated
  */
 public static function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array('*'))
 {
     if (empty($arSelectFields)) {
         $arSelectFields = array('*');
     }
     $params = array('order' => self::convertFilterOldToNew($arOrder), 'filter' => self::convertFilterOldToNew($arFilter), 'group' => self::convertGroupOldToNew($arGroupBy), 'select' => self::convertSelectOldToNew($arSelectFields));
     $services = array();
     $params['filter']['=CLASS_NAME'] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
     $dbRes = \Bitrix\Sale\Delivery\Services\Table::getList($params);
     if (isset($arFilter["WEIGHT"]) && DoubleVal($arFilter["WEIGHT"]) > 0) {
         if (!isset($arFilter["WEIGHT_FROM"]) || floatval($arFilter["WEIGHT"]) > floatval($arFilter["WEIGHT_FROM"])) {
             $arFilter["+<=WEIGHT_FROM"] = $arFilter["WEIGHT"];
         }
         if (!isset($arFilter["WEIGHT_TO"]) || floatval($arFilter["WEIGHT"]) < floatval($arFilter["WEIGHT_TO"])) {
             $arFilter["+>=WEIGHT_TO"] = $arFilter["WEIGHT"];
         }
     }
     if (isset($arFilter["ORDER_PRICE"]) && IntVal($arFilter["ORDER_PRICE"]) > 0) {
         if (!isset($arFilter["ORDER_PRICE_FROM"]) || floatval($arFilter["ORDER_PRICE"]) > floatval($arFilter["ORDER_PRICE_FROM"])) {
             $arFilter["+<=ORDER_PRICE_FROM"] = $arFilter["ORDER_PRICE"];
         }
         if (!isset($arFilter["ORDER_PRICE_TO"]) || floatval($arFilter["ORDER_PRICE"]) < floatval($arFilter["ORDER_PRICE_TO"])) {
             $arFilter["+>=ORDER_PRICE_TO"] = $arFilter["ORDER_PRICE"];
         }
     }
     while ($service = $dbRes->fetch()) {
         $dbRstrRes = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array('filter' => array("=SERVICE_ID" => $service["ID"], "=SERVICE_TYPE" => \Bitrix\Sale\Services\Base\RestrictionManager::SERVICE_TYPE_SHIPMENT)));
         while ($restr = $dbRstrRes->fetch()) {
             if (!self::checkRestrictionFilter($restr, $arFilter)) {
                 continue 2;
             }
             $service = self::getSelectedRestrictionField($service, $restr, $arSelectFields);
         }
         $selectAsterisk = in_array('*', $arSelectFields);
         $mofifiedFields = array("LID", "WEIGHT_FROM", "WEIGHT_TO", "ORDER_PRICE_FROM", "ORDER_PRICE_TO", "ORDER_CURRENCY");
         foreach ($mofifiedFields as $field) {
             if (($selectAsterisk || in_array($field, $arSelectFields)) && !array_key_exists($field, $service)) {
                 $service[$field] = "";
             }
         }
         if ($selectAsterisk || in_array("PERIOD_FROM", $arSelectFields)) {
             $service["PERIOD_FROM"] = $service["CONFIG"]["MAIN"]["PERIOD"]["FROM"];
         }
         if ($selectAsterisk || in_array("PERIOD_TO", $arSelectFields)) {
             $service["PERIOD_TO"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TO"];
         }
         if ($selectAsterisk || in_array("PERIOD_TYPE", $arSelectFields)) {
             $service["PERIOD_TYPE"] = $service["CONFIG"]["MAIN"]["PERIOD"]["TYPE"];
         }
         if ($selectAsterisk || in_array("PRICE", $arSelectFields)) {
             $service["CLASS_NAME"] = '\\Bitrix\\Sale\\Delivery\\Services\\Configurable';
             $tmpSrv = \Bitrix\Sale\Delivery\Services\Manager::createObject($service);
             if ($tmpSrv) {
                 $res = $tmpSrv->calculate();
                 $service["PRICE"] = $res->getPrice();
             } else {
                 $service["PRICE"] = 0;
             }
         }
         if ($selectAsterisk || in_array("STORE", $arSelectFields)) {
             $stores = \Bitrix\Sale\Delivery\ExtraServices\Manager::getStoresList($service["ID"]);
             $service["STORE"] = count($stores) > 0 ? serialize($stores) : "";
         }
         if (intval($service["CODE"]) > 0) {
             $service["ID"] = $service["CODE"];
         }
         unset($service["CODE"], $service["CLASS_NAME"], $service["CONFIG"], $service["PARENT_ID"]);
         $services[] = $service;
     }
     if (!empty($arOrder)) {
         foreach ($arOrder as $k => $v) {
             if ($v == 'ASC') {
                 $arOrder[$k] = SORT_ASC;
             } elseif ($v == 'DESC') {
                 $arOrder[$k] = SORT_DESC;
             }
         }
         sortByColumn($services, $arOrder);
     }
     $result = new \CDBResult();
     $result->InitFromArray($services);
     return $result;
 }