Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CModule::IncludeModule("iblock");
- $i = 0;
- $iblock_id = 16;
- $arSelect = Array("ID", "DETAIL_TEXT", "NAME");
- $arFilter = Array("IBLOCK_ID" => $iblock_id, "SECTION_ID" => 808, "INCLUDE_SUBSECTIONS"=>"Y"); // "SECTION_ID"=>52,
- $res = CIBlockElement::GetList(Array('ID' => 'DESC'), $arFilter, false, false, $arSelect);
- $arAllLog = [];
- $el = new CIBlockElement;
- while($ob = $res->GetNext()){
- //print_r($ob['DETAIL_TEXT']);die();
- $tmpDescr = explode('Купить ', $ob['DETAIL_TEXT']);
- if(count($tmpDescr) == 2) {
- if(substr_count($tmpDescr[1], '</div>') == 1){
- if(substr_count($ob['DETAIL_TEXT'], 'Layta.Ru') > 0) {
- $arAllLog['SUCCESS_ERROR'][] = $ob['ID'];
- $detailText = str_replace('Layta.Ru', 'shop-elvent.ru', $ob['DETAIL_TEXT']);
- if(!$el->Update($ob['ID'], ['DETAIL_TEXT' => $detailText])) $arAllLog['ERROR_UPDATE'][] = $ob['ID'];
- } else {
- $arAllLog['SUCCESS'][] = $ob['ID'];
- if(!$el->Update($ob['ID'], ['DETAIL_TEXT' => $tmpDescr[0] . '</div>'])) $arAllLog['ERROR_UPDATE'][] = $ob['ID'];
- }
- } else {
- $arAllLog['ERROR_DIV'][] = $ob['ID'];
- }
- } else {
- if(substr_count($ob['DETAIL_TEXT'], 'Layta.Ru') > 0) {
- $arAllLog['SUCCESS_POS'][] = $ob['ID'];
- $detailText = str_replace('Layta.Ru', 'shop-elvent.ru', $ob['DETAIL_TEXT']);
- if(!$el->Update($ob['ID'], ['DETAIL_TEXT' => $detailText])) $arAllLog['ERROR_UPDATE'][] = $ob['ID'];
- } else {
- if(empty($ob['DETAIL_TEXT'])) $arAllLog['EMPTY'][] = $ob['ID'];
- else $arAllLog['ERROR_EXPLODE'][] = $ob['ID'];
- }
- }
- }
- print_r([
- 'SUCCESS' => count($arAllLog['SUCCESS']),
- 'SUCCESS_POS' => count($arAllLog['SUCCESS_POS']),
- 'SUCCESS_ERROR' => count($arAllLog['SUCCESS_ERROR']),
- 'ERROR_UPDATE' => count($arAllLog['ERROR_UPDATE']),
- 'ERROR_DIV' => count($arAllLog['ERROR_DIV']),
- 'ERROR_EXPLODE' => count($arAllLog['ERROR_EXPLODE']),
- 'EMPTY' => count($arAllLog['EMPTY']),
- ]);
- print_r($arAllLog['ERROR_EXPLODE']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement