Advertisement
vitvayti

Untitled

Aug 9th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. //title: Парсим CSV
  2.  
  3. $csv = array_map('str_getcsv', file('/home/c/ci25473/belikova.net/public_html/upload/export_file_3XuhuHO4sQop9HPt.csv'));
  4.  
  5. foreach ($csv as $item) {
  6.  
  7. $csv_new[] = $item[0];
  8.  
  9. }
  10.  
  11. // echo "<pre>";
  12. // print_r($csv_new);
  13. // echo "</pre>";
  14.  
  15. CModule::IncludeModule('iblock');
  16.  
  17. $IBLOCK_ID = 6;
  18.  
  19. $arSelect = Array("ID", "CODE");
  20. $arFilter = Array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y");
  21. $res = CIBlockElement::GetList(Array(), $arFilter, false, Array(), $arSelect);
  22.  
  23. $i = 0;
  24.  
  25. while($ob = $res->GetNextElement()) {
  26.  
  27. $arFields = $ob->GetFields();
  28.  
  29. // echo "<pre>";
  30. // print_r($arFields);
  31. // echo "</pre>";
  32.  
  33. $ELEMENT_ID = $arFields["ID"];
  34. $property_value = $arFields["CODE"];
  35. $property_code = "CODE";
  36.  
  37. $bd[] = $property_value;
  38.  
  39. if (in_array($property_value, $csv_new)) {
  40.  
  41. $arLoadProductArray = Array(
  42. "CODE" => ""
  43. );
  44.  
  45. $el = new CIBlockElement;
  46.  
  47. $tmp = $el->Update($ELEMENT_ID, $arLoadProductArray);
  48.  
  49. $i++;
  50.  
  51. }
  52.  
  53.  
  54. // CIBlockElement::SetPropertyValueCode($ELEMENT_ID, $property_code, $property_value);
  55.  
  56. }
  57.  
  58. //echo count($csv_new);
  59. //echo $i;
  60.  
  61. //print_r(array_count_values ($bd));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement