30 if (!isset(
$arFields[
'CATALOG_GROUP_ID']))
50 $currencyExist = isset(
$arFields[
'CURRENCY']);
87 if ($priceExist != $currencyExist)
90 'select' =>
array(
'PRICE',
'CURRENCY'),
101 unset($currentCurrency, $currentPrice);
105 elseif ($priceExist && $currencyExist)
110 unset($currencyExist, $priceExist,
$currency);
145 $price[
'TIMESTAMP_X'] = $price[
'TIMESTAMP_X']->toString();
148 $price[
'CATALOG_GROUP_NAME'] =
null;
149 if (isset($priceTypes[$price[
'CATALOG_GROUP_ID']]))
151 $price[
'CATALOG_GROUP_NAME'] = ($priceTypes[$price[
'CATALOG_GROUP_ID']][
'NAME_LANG'] !==
null
152 ? $priceTypes[$price[
'CATALOG_GROUP_ID']][
'NAME_LANG']
153 : $priceTypes[$price[
'CATALOG_GROUP_ID']][
'NAME']
158 $price[
'CAN_ACCESS'] =
'N';
159 $price[
'CAN_BUY'] =
'N';
161 'select' =>
array(
'ACCESS'),
163 '=CATALOG_GROUP_ID' => $price[
'CATALOG_GROUP_ID'],
170 $price[
'CAN_ACCESS'] =
'Y';
172 $price[
'CAN_BUY'] =
'Y';
194 self::normalizeFields(
$fields);
199 $recount = ($recount ===
true);
201 $data[
'actions'] =
array(
'OLD_RECOUNT' =>
true);
228 if ($id <= 0 || !is_array(
$fields))
231 self::normalizeFields(
$fields);
236 $recount = ($recount ===
true);
238 $data[
'actions'] =
array(
'OLD_RECOUNT' =>
true);
284 public static function GetBasePrice($productID, $quantityFrom =
false, $quantityTo =
false, $boolExt =
true)
286 $productID = (int)$productID;
291 if (empty($arBaseType))
295 'PRODUCT_ID' => $productID,
296 'CATALOG_GROUP_ID' => $arBaseType[
'ID']
299 if ($quantityFrom !==
false)
300 $arFilter[
'QUANTITY_FROM'] = (int)$quantityFrom;
301 if ($quantityTo !==
false)
302 $arFilter[
'QUANTITY_TO'] = (int)$quantityTo;
304 if ($boolExt ===
false)
306 $arSelect =
array(
'ID',
'PRODUCT_ID',
'EXTRA_ID',
'CATALOG_GROUP_ID',
'PRICE',
'CURRENCY',
'TIMESTAMP_X',
307 'QUANTITY_FROM',
'QUANTITY_TO',
'TMP_ID'
312 $arSelect =
array(
'ID',
'PRODUCT_ID',
'EXTRA_ID',
'CATALOG_GROUP_ID',
'PRICE',
'CURRENCY',
'TIMESTAMP_X',
313 'QUANTITY_FROM',
'QUANTITY_TO',
'TMP_ID',
314 'PRODUCT_QUANTITY',
'PRODUCT_QUANTITY_TRACE',
'PRODUCT_CAN_BUY_ZERO',
315 'PRODUCT_NEGATIVE_AMOUNT_TRACE',
'PRODUCT_WEIGHT',
'ELEMENT_IBLOCK_ID'
320 array(
'QUANTITY_FROM' =>
'ASC',
'QUANTITY_TO' =>
'ASC'),
323 array(
'nTopCount' => 1),
329 $res[
'CATALOG_GROUP_NAME'] = $arBaseType[
'NAME'];
348 public static function SetBasePrice($ProductID, $Price, $Currency, $quantityFrom =
false, $quantityTo =
false, $bGetID =
false)
350 $bGetID = ($bGetID ==
true);
355 $arFields[
"QUANTITY_FROM"] = ($quantityFrom ==
false ?
false : (int)$quantityFrom);
356 $arFields[
"QUANTITY_TO"] = ($quantityTo ==
false ?
false : (int)$quantityTo);
366 $arFields[
"CATALOG_GROUP_ID"] = $arBaseGroup[
"ID"];
374 return ($bGetID ?
$ID :
true);
385 if (
$TYPE ==
'EXTRA')
388 if (empty($baseType))
396 array(
'ID',
'PRODUCT_ID',
'EXTRA_ID',
'QUANTITY_FROM',
'QUANTITY_TO')
400 $parentFilter =
array(
401 'PRODUCT_ID' =>
$res[
'PRODUCT_ID'],
402 'CATALOG_GROUP_ID' => $baseType[
'ID'],
403 'QUANTITY_FROM' => (
$res[
'QUANTITY_FROM'] ===
null ?
false :
$res[
'QUANTITY_FROM']),
404 'QUANTITY_TO' => (
$res[
'QUANTITY_TO'] ===
null ?
false :
$res[
'QUANTITY_TO'])
411 array(
'ID',
'PRODUCT_ID',
'PRICE',
'CURRENCY',
'ELEMENT_IBLOCK_ID')
413 $basePrice = $parentIterator->Fetch();
414 if (!empty($basePrice))
416 $basePrice[
'ELEMENT_IBLOCK_ID'] = (int)$basePrice[
'ELEMENT_IBLOCK_ID'];
418 'PRICE' => roundex($basePrice[
'PRICE'] * (1 + 1 * $VAL / 100), 2),
419 'CURRENCY' => $basePrice[
'CURRENCY']
423 $iblockList[$basePrice[
'ELEMENT_IBLOCK_ID']] = $basePrice[
'ELEMENT_IBLOCK_ID'];
425 unset($basePrice, $parentIterator);
436 array(
'ID',
'PRODUCT_ID',
'EXTRA_ID',
'ELEMENT_IBLOCK_ID')
440 $res[
'ELEMENT_IBLOCK_ID'] = (int)
$res[
'ELEMENT_IBLOCK_ID'];
441 $res[
"EXTRA_ID"] = (int)
$res[
"EXTRA_ID"];
442 if (
$res[
"EXTRA_ID"] > 0)
446 "PRICE" => $VAL * (1 + 1 * $res1[
"PERCENTAGE"] / 100),
458 CIblock::clearIblockTagCache(
$iblock);
470 $strSql =
"DELETE FROM b_catalog_price WHERE CURRENCY = '".$DB->ForSql($Currency).
"'";
471 return $DB->Query($strSql,
true);
490 $ProductID = (int)$ProductID;
493 foreach (
GetModuleEvents(
"catalog",
"OnBeforeProductPriceDelete",
true) as $arEvent)
499 if (!empty($arExceptionIDs))
502 if (!empty($arExceptionIDs))
504 $strSql =
"DELETE FROM b_catalog_price WHERE PRODUCT_ID = ".$ProductID.
" AND ID NOT IN (".implode(
',',$arExceptionIDs).
")";
508 $strSql =
"DELETE FROM b_catalog_price WHERE PRODUCT_ID = ".$ProductID;
511 $mxRes =
$DB->Query($strSql,
true);
513 foreach (
GetModuleEvents(
"catalog",
"OnProductPriceDelete",
true) as $arEvent)
530 static $arExtraList =
array();
539 array(
'CATALOG_GROUP_ID' =>
'ASC',
"QUANTITY_FROM" =>
"ASC",
"QUANTITY_TO" =>
"ASC"),
543 array(
'ID',
'EXTRA_ID')
545 while ($arPrice = $rsPrices->Fetch())
547 $arPrice[
'EXTRA_ID'] = (int)$arPrice[
'EXTRA_ID'];
548 if ($arPrice[
'EXTRA_ID'] > 0)
550 $boolSearch = isset($arExtraList[$arPrice[
'EXTRA_ID']]);
554 if (!empty($arExtra))
557 $arExtraList[$arExtra[
'ID']] = (float)$arExtra[
'PERCENTAGE'];
584 if (!empty($arBaseGroup))
586 if (
$arFields[
'CATALOG_GROUP_ID'] == $arBaseGroup[
'ID'])
595 if (!empty($arExtra))
597 $arExtra[
"PERCENTAGE"] = (float)$arExtra[
"PERCENTAGE"];
604 array(
"QUANTITY_FROM" =>
"ASC",
"QUANTITY_TO" =>
"ASC"),
607 array(
'nTopCount' => 1),
608 array(
'PRICE',
'CURRENCY')
610 if ($arBasePrice = $rsBasePrices->Fetch())
612 $arFields[
'CURRENCY'] = $arBasePrice[
'CURRENCY'];
637 foreach (
$result->getErrorMessages() as $errorText)
639 $oldMessages[] = [
'text' => $errorText];
643 if (!empty($oldMessages))
645 $error =
new CAdminException($oldMessages);
652 private static function normalizeFields(
array &
$fields): void
654 if (isset(
$fields[
'QUANTITY_FROM']))
657 $fields[
'QUANTITY_FROM'] ===
''
658 ||
$fields[
'QUANTITY_FROM'] ===
false
659 ||
$fields[
'QUANTITY_FROM'] === 0
662 $fields[
'QUANTITY_FROM'] =
null;
665 if (isset(
$fields[
'QUANTITY_TO']))
669 ||
$fields[
'QUANTITY_TO'] ===
false
670 ||
$fields[
'QUANTITY_TO'] === 0
676 if (isset(
$fields[
'EXTRA_ID']))
const CATALOG_VALUE_PRECISION
static update($id, array $data)
static calculatePrice($id, $iblockId=null, $type=null, array $priceTypes=[])
static includeModule($moduleName)
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())
static normalizeArrayValuesByInt(&$map, $sorted=true)
static GetByID($currency)
static ReCountForBase(&$arFields)
static SetBasePrice($ProductID, $Price, $Currency, $quantityFrom=false, $quantityTo=false, $bGetID=false)
static OnCurrencyDelete($Currency)
static CheckFields($ACTION, &$arFields, $ID=0)
static ReCalculate($TYPE, $ID, $VAL)
static GetBasePrice($productID, $quantityFrom=false, $quantityTo=false, $boolExt=true)
static Update($id, $fields, $recount=false)
static OnIBlockElementDelete($ProductID)
static Add($fields, $recount=false)
static DeleteByProduct($ProductID, $arExceptionIDs=array())
static ReCountFromBase(&$arFields, &$boolBase)
static GetListEx($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if($request->isPost() && $currentAction !==null &&check_bitrix_sessid()) $currentValues
if(! $catalogEdit->isSuccess()) $iblock
ExecuteModuleEventEx($arEvent, $arParams=[])
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)