79 $changedAchieved =
false;
81 foreach($skuOrder as $skuId)
83 if($skuId == $changedSkuId)
85 $changedAchieved =
true;
89 if($skuId != $changedSkuId && !$changedAchieved)
92 if(!empty($skuProps[$skuId]))
93 $result[$skuId] = $skuProps[$skuId];
107 public static function getProductId(array $skuProps, $productId, array $skuOrder, $changedSkuId)
111 || intval($productId) <= 0
113 || intval($changedSkuId) <= 0
123 if(count($offersIds) == 0)
126 if(count($offersIds) == 1)
127 return current($offersIds);
131 if(empty($optionalProps))
132 return current($offersIds);
134 foreach($optionalProps as $id => $val)
136 $prevProducts = $offersIds;
139 if(count($offersIds) == 0)
140 return current($prevProducts);
142 if(count($offersIds) == 1)
143 return current($offersIds);
146 return current($offersIds);
156 if(!Loader::includeModule(
'catalog'))
160 $offers = \CCatalogSKU::getOffersList($productIds, 0, array(), array(
'ID'));
162 if(is_array($offers))
164 foreach($offers as $productId => $items)
166 $result[$productId] ??= [];
168 if(!is_array($result[$productId]))
170 $result[$productId] = [];
173 foreach($items as $item)
175 $result[$productId][] = $item[
'ID'];
192 if(!Loader::includeModule(
'iblock'))
196 $foundElements = array();
198 $res = \CIBlockElement::GetList(
199 array(
"SORT"=>
"ASC"),
202 '!=PROPERTY_'.$propId =>
false
206 array(
'ID',
'PROPERTY_'.$propId)
209 while($el = $res->Fetch())
211 if(isset($el[
'PROPERTY_'.$propId.
'_ENUM_ID']))
212 $value = $el[
'PROPERTY_'.$propId.
'_ENUM_ID'];
214 $value = $el[
'PROPERTY_'.$propId.
'_VALUE'];
216 if(!in_array($value, $result))
219 $foundElements[] = $el[
'ID'];
221 if($value != $currentValue)
223 $key = array_search($el[
'ID'], $offersIds);
226 unset($offersIds[$key]);
230 $foundElements = array_unique($foundElements, SORT_NUMERIC);
231 $valueLess = array_diff($offersIds, $foundElements);
233 if(!empty($valueLess))
238 if($currentValue !=
'-')
239 $offersIds = array_diff($offersIds, $valueLess);
253 $productIds = array();
255 foreach($params as $param)
256 $productIds[] = $param[
'PRODUCT_ID'];
260 foreach($params as $param)
262 if(intval($param[
'PRODUCT_ID']) <= 0)
265 if(empty($productOffersIds[$param[
'PRODUCT_ID']]))
268 $offerId = intval($param[
'OFFER_ID']);
270 $result[$offerId] ??= [];
271 if (!is_array($result[$offerId]))
273 $result[$offerId] = [];
276 if(empty($param[
'SKU_PROPS']) || empty($param[
'SKU_ORDER']))
279 $offersIds = $productOffersIds[$param[
'PRODUCT_ID']];
281 foreach($param[
'SKU_ORDER'] as $propId)
283 if(empty($param[
'SKU_PROPS'][$propId]))
286 if(count($offersIds) > 0)
289 if(count($offersIds) > 0)
292 $result[$offerId][$propId] = $res;
296 $result[$offerId][$propId] = $param[
'SKU_PROPS'][$propId];