Advertisement
animdenis

AddSection By Regions

Oct 3rd, 2020
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. CModule::IncludeModule('iblock');
  2. CModule::IncludeModule('sale');
  3.  
  4. $iblockId = 128;
  5.  
  6. $locs = COption::GetOptionString('rbs.moyskladstocksextended', 'locations_config');
  7. $locs = explode('|', $locs);
  8.  
  9. $sec = new \CIblockSection;
  10. foreach($locs as $loc){
  11.     $locOb = CSaleLocation::GetById($loc);
  12.     $cityName = $locOb['CITY_NAME'];
  13.     $cityCode = \CUtil::translit($cityName, 'ru');
  14.  
  15.     $check = \CIblockSection::GetList([], ['IBLOCK_ID' => $iblockId, '=CODE' => $cityCode]);
  16.     if($check->GetNext()) continue;
  17.  
  18.  
  19.     $sec->Add([
  20.         'IBLOCK_ID' => $iblockId,
  21.         'CODE' => $cityCode,
  22.         'NAME' => $cityName
  23.     ]);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement