Answer the question
In order to leave comments, you need to log in
How to get rid of the 500 error with a large script?
Hello! There is the following code that massively fills the property of the infoblock elements:
$resElements = CIBlockElement::GetList(
Array("SORT"=>"ASC"),
Array("IBLOCK_ID"=>2,"ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y"),
false,
false,
Array("ID", "IBLOCK_ID", "NAME")
);
if($resElements){
while($obElements = $resElements->GetNextElement()){
$arFields = $obElements->GetFields();
$arProps = $obElements->GetProperties();
// если у элемента заполнено свойство
if (is_array($arProps[$NAME_PROPERTY_SNAP]['VALUE']) && !empty($arProps[$NAME_PROPERTY_SNAP]['VALUE'])) {
$SNAPPING_BY_PRODUCT_ARR = $arProps[$NAME_PROPERTY_SNAP]['VALUE'];
// проверяем, есть ли уже привязка у элемента к желаемому значению свойства
if(in_array($SNAPPING_ID, $SNAPPING_BY_PRODUCT_ARR)){
// проверяем на отсутствие в выборке привязки, то есть это привязку надо удалить
if(in_array($SNAPPING_ID, $SNAPPING_BY_PRODUCT_ARR) && !in_array($arFields['ID'], $ARR_ELEMENT_ID) ){
if(($key_prop = array_search($SNAPPING_ID, $SNAPPING_BY_PRODUCT_ARR)) !== false){
unset($SNAPPING_BY_PRODUCT_ARR[$key_prop]);
$PROP = array($NAME_PROPERTY_SNAP =>$SNAPPING_BY_PRODUCT_ARR);
$CIBlockElement->SetPropertyValuesEx($arFields['ID'], 2, $PROP);
}
}
}else if(in_array($arFields['ID'], $ARR_ELEMENT_ID)){
$SNAPPING_BY_PRODUCT_ARR[] = $SNAPPING_ID;
$PROP = array($NAME_PROPERTY_SNAP =>$SNAPPING_BY_PRODUCT_ARR);
$CIBlockElement->SetPropertyValuesEx($arFields['ID'], 2, $PROP);
}
// если свойство не заполнено
}else if(in_array($arFields['ID'], $ARR_ELEMENT_ID)){
$PROP = array($NAME_PROPERTY_SNAP =>array($SNAPPING_ID));
$CIBlockElement->SetPropertyValuesEx($arFields['ID'], 2, $PROP);
}
} ?>
PHP Warning: Unknown: Input variables exceeded 10000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0, referer: https://artameb.boxdev.ru/bitrix/admin/isvapp.iblockhelper_reson_offers.php
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question