diff --git a/local/ilsa_update.php b/local/ilsa_update.php index f0195de..7453538 100644 --- a/local/ilsa_update.php +++ b/local/ilsa_update.php @@ -84,6 +84,8 @@ $repost_models = []; $repost_modifications = []; $repost_cars = []; +$flags = []; + function elasticIndex($index, $payload) { if(!in_array("debug", $GLOBALS['argv'])) @@ -141,6 +143,18 @@ function elasticIndex($index, $payload) } } +$properties = CIBlockPropertyEnum::GetList([ "sort" => "asc", "name" => "asc" ], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, "CODE" => "TAXI" ]); +while ($prop_fields = $properties->GetNext()) +{ + $flags[ 'BRANDS_TAXI' ][ $prop_fields['XML_ID'] ] = $prop_fields["ID"]; +} + +$properties = CIBlockPropertyEnum::GetList([ "sort" => "asc", "name" => "asc" ], [ "IBLOCK_ID" => IBLOCK_ID_MODELS, "CODE" => "TAXI" ]); +while ($prop_fields = $properties->GetNext()) +{ + $flags[ 'MODELS_TAXI' ][ $prop_fields['XML_ID'] ] = $prop_fields["ID"]; +} + $all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, ], false, false, [] ); while($all_brands_search_ob = $all_brands_search_res->GetNextElement()) { @@ -268,7 +282,6 @@ while($all_cars_search_ob = $all_cars_search_res->GetNextElement()) { array_push( $bitrix_hidden_cars, $car_search['PROPERTIES']['UID']['VALUE'] ); } - } //наполняем массивы имеющихся и активных типов кузова @@ -740,7 +753,7 @@ function set_car_activity($car_uid, $active = "N") { $update_element = new CIBlockElement; $update_result = $update_element->Update($car_id, [ "ACTIVE" => $active, ]); - + if($active == "N") { array_push($hide_cars, $car_search['NAME']); @@ -951,6 +964,9 @@ foreach($json AS $car) $car_codes = []; +$taxi_brands = []; +$taxi_models = []; + $c = 0; foreach($json AS $car) { @@ -980,6 +996,18 @@ foreach($json AS $car) //print "new car --- uid ".$car['uid']." | code ".$code."\n"; + if(is_array($car['programms']) && !in_array("taxi", $car['programms'])) + { + $taxi_bodies_list = ["лифтбек", "кроссовер", "седан", "хэтчбек", "внедорожник", "универсал", "минивэн"]; + + if(in_array($car['body'], $taxi_bodies_list)) + { + array_push($car['programms'], "taxi"); + array_push($taxi_brands, $bitrix_brands[ $car['brand']['id'] ]); + array_push($taxi_models, $bitrix_models[ $car['model']['id'] ]); + } + } + $PROPERTY_VALUES = [ "UID" => $car['uid'], "BRAND" => $bitrix_brands[ $car['brand']['id'] ], @@ -1079,6 +1107,26 @@ foreach($json AS $car) } } +$taxi_brands = array_unique($taxi_brands); +$taxi_models = array_unique($taxi_models); + +foreach($taxi_brands AS $taxi_brand_id) +{ + CIBlockElement::SetPropertyValuesEx($taxi_brand_id, IBLOCK_ID_BRANDS, [ "TAXI" => $flags['BRANDS_TAXI']['YES'] ], []); +} + +foreach($taxi_models AS $taxi_model_id) +{ + CIBlockElement::SetPropertyValuesEx($taxi_model_id, IBLOCK_ID_MODELS, [ "TAXI" => $flags['MODELS_TAXI']['YES'] ], []); +} + +print "\n------------------------------\n"; +print "\ntaxi_brands\n"; +print_r($taxi_brands); +print "\ntaxi_models\n"; +print_r($taxi_models); +print "\n------------------------------\n"; + //print "car_codes?\n"; /* foreach($car_codes AS $cc => $count) @@ -1336,7 +1384,6 @@ foreach($bitrix_existed_bodies AS $bitrix_body) } } - //топливо foreach($api_engine_fuels AS $api_engine_fuel) { @@ -2458,7 +2505,6 @@ if(!in_array("simulate", $GLOBALS['argv'])) } } - $sitemap_catalog_string .= ""."\n"; file_put_contents("/home/bitrix/www/sitemap-catalog.xml", $sitemap_catalog_string);