Скрытый текст |
---|
<? require($_SERVER["DOCUMENT_ROOT"]. "/bitrix/header.php"); ini_set('memory_limit', '1G'); ?><pre><? if(CModule::IncludeModule("iblock")){ $id_catalog = 8; $prop = []; $order = ['ID' => 'ASC']; $filter = ['IBLOCK_ID' => $id_catalog]; $rows = CIBlockElement::GetList($order, $filter); while ($row = $rows->fetch()) { $row['PROPERTIES'] = []; $prop[$row['ID']] =& $row; unset($row); } //получаю настройки элементов каталога из бд CIBlockElement::GetPropertyValuesArray($prop, $filter['IBLOCK_ID'], $filter); unset($rows, $filter, $order); $arCodeValue = []; $arAlcoContent = []; $arSale = []; //записываю в массивы нужные мне настройки foreach ($prop as $key => $value) { if(!empty($value)){ if(strstr($value['PROPERTIES']['VOLUME']['VALUE'], ',')){ $value['PROPERTIES']['VOLUME']['VALUE'] = str_replace(',','.',$value['PROPERTIES']['VOLUME']['VALUE']); $arCodeValue[$key] = [$value['PROPERTIES']['VOLUME']['ID'] => $value['PROPERTIES']['VOLUME']['VALUE']]; } if(strstr($value['PROPERTIES']['ALCOHOL_CONTENT']['VALUE'], ',')){ $value['PROPERTIES']['ALCOHOL_CONTENT']['VALUE'] = str_replace(',','.',$value['PROPERTIES']['ALCOHOL_CONTENT']['VALUE']); $arAlcoContent[$key] = [$value['PROPERTIES']['ALCOHOL_CONTENT']['ID'] => $value['PROPERTIES']['ALCOHOL_CONTENT']['VALUE']]; } if(strstr($value['PROPERTIES']['SALE']['VALUE'], ',')){ $value['PROPERTIES']['SALE']['VALUE'] = str_replace(',','.',$value['PROPERTIES']['SALE']['VALUE']); $arSale[$key] = [$value['PROPERTIES']['SALE']['ID'] => $value['PROPERTIES']['SALE']['VALUE']]; } }else echo 'empty'; } $ibId = 8; $elsCount = 50; $lastId = $_POST['LAST_ID']; $i = 0; $ibElements = CIBlockElement::GetList( array('ID' => 'ASC'), array( 'IBLOCK_ID' => $ibId, '>ID' => $lastId ), false, array( 'nTopCount' => $elsCount ), array( 'ID' ) ); //выгружаю из массивов настройки в бд while ($dbRes = $ibElements->Fetch()) { if(!empty($arCodeValue[$dbRes['ID']])) { CIBlockElement::SetPropertyValuesEx($dbRes['ID'], $id_catalog, $arCodeValue[$dbRes['ID']]); $elthis = new CIBlockElement; $elthis->Update( $dbRes['ID'], ['WF_STATUS_ID' => 1, 'ACTIVE' => 'Y'], true ); } if(!empty($arAlcoContent[$dbRes['ID']])) { CIBlockElement::SetPropertyValuesEx($dbRes['ID'], $id_catalog, $arAlcoContent[$dbRes['ID']]); $elthis = new CIBlockElement; $elthis->Update( $dbRes['ID'], ['WF_STATUS_ID' => 1, 'ACTIVE' => 'Y'], true ); } if(!empty($arSale[$dbRes['ID']])) { CIBlockElement::SetPropertyValuesEx($dbRes['ID'], $id_catalog, $arSale[$dbRes['ID']]); $elthis = new CIBlockElement; $elthis->Update( $dbRes['ID'], ['WF_STATUS_ID' => 1, 'ACTIVE' => 'Y'], true ); } $lastId = $dbRes['ID']; $i++; } ?> <form action="" method="POST"> <input type="text" name="LAST_ID" value="<?echo $lastId > 2 ? $lastId : '1';?>"> <button type="submit" id="go">Go</button> </form> <? if ($i > 1) {?> <script> $('#go').click(); </script> <? } else { ?> Элементы обработаны <?php } } ?></pre><? require($_SERVER["DOCUMENT_ROOT"]. "/bitrix/footer.php"); ?> |
Код в виде кода оформить не получилось, тогда всё сообщение удаляется