function MinMaxSKUPriceUpdate arFields isProduct CCatalogSKU GetInfoBy

 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
function MinMaxSKUPriceUpdate(&$arFields){
$isProduct = CCatalogSKU::GetInfoByProductIBlock($arFields['IBLOCK_ID']);
if (is_array($isProduct)){
$rsOffers = CIBlockElement::GetList(array(),array('IBLOCK_ID' => $isProduct['IBLOCK_ID'], 'PROPERTY_'.$isProduct['SKU_PROPERTY_ID'] => $arFields['ID']), false, false, array('IBLOCK_ID', 'ID', 'CATALOG_GROUP_1'));
$k=0;
while ($arOffer = $rsOffers->GetNext()){
$k++;
if(!isset($MIN_PRICE)){$MIN_PRICE = $arOffer['CATALOG_PRICE_1'];}
if(!isset($MAX_PRICE)){$MAX_PRICE = $arOffer['CATALOG_PRICE_1'];}
if($MIN_PRICE > $arOffer['CATALOG_PRICE_1']){
$MIN_PRICE = $arOffer['CATALOG_PRICE_1'];
}
if($MAX_PRICE < $arOffer['CATALOG_PRICE_1']){
$MAX_PRICE = $arOffer['CATALOG_PRICE_1'];
}
}
if ($k == 0) {
$ar_res = CPrice::GetBasePrice($arFields['ID']);
$MIN_PRICE = $ar_res['PRICE'];
$MAX_PRICE = $ar_res['PRICE'];
}
$arFields['PROPERTY_VALUES']['MINIMUM_PRICE'] = $MIN_PRICE;
$arFields['PROPERTY_VALUES']['MAXIMUM_PRICE'] = $MAX_PRICE;
}
}