hotfix for JS onDocumentLoad state, fixes for ILSA update function
This commit is contained in:
parent
0df841e64b
commit
b03fae38ca
@ -20,10 +20,12 @@ $arrContextOptions = [
|
||||
|
||||
$bitrix_existed_brands = [];
|
||||
$bitrix_existed_models = [];
|
||||
$api_brands = [];
|
||||
$api_models = [];
|
||||
$bitrix_existed_modifications = [];
|
||||
$bitrix_existed_cars = [];
|
||||
|
||||
$all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 8, "ACTIVE" => "Y" ], false, false, [] );
|
||||
$all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, "ACTIVE" => "Y" ], false, false, [] );
|
||||
while($all_brands_search_ob = $all_brands_search_res->GetNextElement())
|
||||
{
|
||||
$brand_search = $all_brands_search_ob->GetFields();
|
||||
@ -32,7 +34,7 @@ while($all_brands_search_ob = $all_brands_search_res->GetNextElement())
|
||||
array_push( $bitrix_existed_brands, $brand_search['PROPERTIES']['UID']['VALUE'] );
|
||||
}
|
||||
|
||||
$all_models_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 9, "ACTIVE" => "Y" ], false, false, [] );
|
||||
$all_models_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_MODELS, "ACTIVE" => "Y" ], false, false, [] );
|
||||
while($all_models_search_ob = $all_models_search_res->GetNextElement())
|
||||
{
|
||||
$model_search = $all_models_search_ob->GetFields();
|
||||
@ -72,6 +74,71 @@ $brands_and_models = [];
|
||||
//print "---------------\n\n";
|
||||
|
||||
$c = 0;
|
||||
|
||||
$api_data = [];
|
||||
$api_brands = [];
|
||||
$api_models = [];
|
||||
$api_cars = [];
|
||||
|
||||
//prepare brands list from API
|
||||
foreach($json AS $entry)
|
||||
{
|
||||
if(!isset($api_data[ $entry['brand']['id'] ]))
|
||||
{
|
||||
$api_data[ $entry['brand']['id'] ] = [
|
||||
"models" => []
|
||||
];
|
||||
}
|
||||
|
||||
if(!in_array($entry['brand']['id'], $api_brands))
|
||||
{
|
||||
array_push($api_brands, $entry['brand']['id']);
|
||||
}
|
||||
}
|
||||
|
||||
//prepare models list from API
|
||||
foreach($json AS $entry)
|
||||
{
|
||||
if(!isset($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]))
|
||||
{
|
||||
$api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ] = [
|
||||
"cars" => []
|
||||
];
|
||||
}
|
||||
|
||||
if(!in_array($entry['model']['id'], $api_models))
|
||||
{
|
||||
array_push($api_models, $entry['model']['id']);
|
||||
}
|
||||
}
|
||||
|
||||
//prepare models list from API
|
||||
foreach($json AS $entry)
|
||||
{
|
||||
if(!isset($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['cars'][ $entry['uid'] ]))
|
||||
{
|
||||
array_push($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['cars'], $entry['uid']);
|
||||
}
|
||||
|
||||
if(!in_array($entry['uid'], $api_cars))
|
||||
{
|
||||
array_push($api_cars, $entry['uid']);
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($bitrix_existed_models);
|
||||
foreach($bitrix_existed_models AS $existed_model)
|
||||
{
|
||||
//print $existed_model." ?\n";
|
||||
if(!in_array($existed_model, $api_models))
|
||||
{
|
||||
print "HIDE MODEL ".$existed_model."\n";
|
||||
}
|
||||
}
|
||||
|
||||
////print_r($api_data);
|
||||
////die();
|
||||
|
||||
foreach($json AS $entry)
|
||||
{
|
||||
if(!isset($brands_and_models[ $entry['brand']['id'] ]))
|
||||
@ -126,13 +193,13 @@ foreach($brands_and_models AS $brand_uid => $brand)
|
||||
//{
|
||||
//добавляем новую марку
|
||||
$brand_existed = null;
|
||||
$brand_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 8, "PROPERTY_UID" => $brand_uid ], false, ["nPageSize" => 1], [] );
|
||||
$brand_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, "PROPERTY_UID" => $brand_uid ], false, ["nPageSize" => 1], [] );
|
||||
while($brand_search_ob = $brand_search_res->GetNextElement())
|
||||
{
|
||||
$brand_existed = $brand_search_ob->GetFields();
|
||||
$brand_existed['PROPERTIES'] = $brand_search_ob->GetProperties();
|
||||
|
||||
$bitrix_brands[$brand_uid] = $brand_existed['ID'];
|
||||
$bitrix_brands[ $brand_uid ] = $brand_existed['ID'];
|
||||
}
|
||||
|
||||
$code = CUtil::translit( $brand['name'], "ru", [ "max_len" => 255, "change_case" => "L", "replace_space" => "-", "replace_other" => "-", ] );
|
||||
@ -141,12 +208,11 @@ foreach($brands_and_models AS $brand_uid => $brand)
|
||||
$brand_update_payload = [
|
||||
"ACTIVE" => "Y",
|
||||
"CODE" => $code,
|
||||
"UID" => $brand_uid,
|
||||
"NAME" => $brand['name'],
|
||||
"TRANSCRIPTION" => $brand_existed['PROPERTIES']['TRANSCRIPTION']['VALUE'],
|
||||
"PROMO" => $brand_existed['PROPERTIES']['PROMO']['VALUE_ENUM_ID'],
|
||||
];
|
||||
CIBlockElement::SetPropertyValuesEx($brand_existed['ID'], IBLOCK_ID_BRANDS, $brand_update_payload, []);
|
||||
|
||||
$update_element = new CIBlockElement;
|
||||
$update_result = $update_element->Update($brand_existed['ID'], $brand_update_payload);
|
||||
|
||||
$result = models_check($bitrix_models, $bitrix_modifications, $bitrix_modifications_codes, $brand_uid, $brand);
|
||||
|
||||
@ -159,7 +225,7 @@ foreach($brands_and_models AS $brand_uid => $brand)
|
||||
$brand_element = new CIBlockElement;
|
||||
$brand_payload = [
|
||||
"IBLOCK_SECTION_ID" => false,
|
||||
"IBLOCK_ID" => 8,
|
||||
"IBLOCK_ID" => IBLOCK_ID_BRANDS,
|
||||
"PROPERTY_VALUES" => [
|
||||
"UID" => $brand_uid,
|
||||
"TRANSCRIPTION" => $brand['name'],
|
||||
@ -191,15 +257,10 @@ foreach($brands_and_models AS $brand_uid => $brand)
|
||||
$c++;
|
||||
}
|
||||
|
||||
//require_once("../bitrix/modules/main/include/prolog_before.php");
|
||||
//require_once("../bitrix/modules/main/include/prolog_before.php");
|
||||
//require_once("../bitrix/modules/main/include/prolog.php");
|
||||
//require_once('../bitrix/modules/main/cli/bitrix.php');
|
||||
|
||||
function set_brand_activity($brand_uid, $active = "N")
|
||||
{
|
||||
$brand_id = null;
|
||||
$brand_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 8, "PROPERTY_UID" => $brand_uid ], false, false, [] );
|
||||
$brand_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, "PROPERTY_UID" => $brand_uid ], false, false, [] );
|
||||
|
||||
while($brand_search_ob = $brand_search_res->GetNextElement())
|
||||
{
|
||||
@ -209,14 +270,15 @@ function set_brand_activity($brand_uid, $active = "N")
|
||||
|
||||
if($brand_id !== null)
|
||||
{
|
||||
CIBlockElement::SetPropertyValuesEx($brand_id, IBLOCK_ID_BRANDS, [ "ACTIVE" => $active, ], []);
|
||||
$update_element = new CIBlockElement;
|
||||
$update_result = $update_element->Update($brand_id, [ "ACTIVE" => $active, ]);
|
||||
}
|
||||
}
|
||||
|
||||
function set_model_activity($model_uid, $active = "N")
|
||||
{
|
||||
$model_id = null;
|
||||
$model_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 9, "PROPERTY_UID" => $model_uid ], false, false, [] );
|
||||
$model_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_MODELS, "PROPERTY_UID" => $model_uid ], false, false, [] );
|
||||
|
||||
while($model_search_ob = $model_search_res->GetNextElement())
|
||||
{
|
||||
@ -226,7 +288,8 @@ function set_model_activity($model_uid, $active = "N")
|
||||
|
||||
if($model_id !== null)
|
||||
{
|
||||
CIBlockElement::SetPropertyValuesEx($model_id, IBLOCK_ID_MODELS, [ "ACTIVE" => $active, ], []);
|
||||
$update_element = new CIBlockElement;
|
||||
$update_result = $update_element->Update($model_id, [ "ACTIVE" => $active, ]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,12 +306,14 @@ function set_modification_activity($modification_code, $active = "N")
|
||||
|
||||
if($modification_id !== null)
|
||||
{
|
||||
CIBlockElement::SetPropertyValuesEx($modification_id, IBLOCK_ID_MODIFICATIONS, [ "ACTIVE" => $active, ], []);
|
||||
$update_element = new CIBlockElement;
|
||||
$update_result = $update_element->Update($modification_id, [ "ACTIVE" => $active, ]);
|
||||
}
|
||||
}
|
||||
|
||||
function set_car_activity($car_uid, $active = "N")
|
||||
{
|
||||
print "SET ACTIVE ".$car_uid." | ".$active."\n";
|
||||
$car_id = null;
|
||||
$car_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, "PROPERTY_UID" => $car_uid ], false, false, [] );
|
||||
|
||||
@ -260,7 +325,8 @@ function set_car_activity($car_uid, $active = "N")
|
||||
|
||||
if($car_id !== null)
|
||||
{
|
||||
CIBlockElement::SetPropertyValuesEx($car_id, IBLOCK_ID_CATALOG_CARS_NEW, [ "ACTIVE" => $active, ], []);
|
||||
$update_element = new CIBlockElement;
|
||||
$update_result = $update_element->Update($car_id, [ "ACTIVE" => $active, ]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +337,7 @@ function models_check($bitrix_models, $bitrix_modifications, $bitrix_modificatio
|
||||
$model_name = $model['name'];
|
||||
|
||||
$model_existed = null;
|
||||
$model_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 9, "PROPERTY_UID" => $model_uid ], false, ["nPageSize" => 1], [] );
|
||||
$model_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_MODELS, "PROPERTY_UID" => $model_uid ], false, ["nPageSize" => 1], [] );
|
||||
while($model_search_ob = $model_search_res->GetNextElement())
|
||||
{
|
||||
$model_existed = $model_search_ob->GetFields();
|
||||
@ -287,22 +353,20 @@ function models_check($bitrix_models, $bitrix_modifications, $bitrix_modificatio
|
||||
//print "MODEL ".$model_uid." EXISTED";
|
||||
|
||||
$model_update_payload = [
|
||||
"BRAND_UID" => $brand_uid,
|
||||
"UID" => $model_uid,
|
||||
"PROMO" => $model_existed['PROPERTIES']['PROMO']['VALUE_ENUM_ID'],
|
||||
"ACTIVE" => "Y",
|
||||
"NAME" => $model_name,
|
||||
"CODE" => $code,
|
||||
"ACTIVE" => "Y",
|
||||
];
|
||||
|
||||
CIBlockElement::SetPropertyValuesEx($model_existed['ID'], IBLOCK_ID_MODELS, $model_update_payload, []);
|
||||
$update_element = new CIBlockElement;
|
||||
$update_result = $update_element->Update($model_existed['ID'], $model_update_payload);
|
||||
}
|
||||
else
|
||||
{
|
||||
$model_element = new CIBlockElement;
|
||||
$model_payload = [
|
||||
"IBLOCK_SECTION_ID" => false,
|
||||
"IBLOCK_ID" => 9,
|
||||
"IBLOCK_ID" => IBLOCK_ID_MODELS,
|
||||
"PROPERTY_VALUES" => [
|
||||
"BRAND_UID" => $brand_uid,
|
||||
"UID" => $model_uid,
|
||||
@ -385,82 +449,117 @@ foreach($json AS $car)
|
||||
array_push($json_new_cars, $car['uid']);
|
||||
}
|
||||
|
||||
$car_codes = [];
|
||||
|
||||
$c = 0;
|
||||
foreach($json AS $car)
|
||||
{
|
||||
//обновляем список ТС в битриксе
|
||||
if(!in_array($car['uid'], $bitrix_existed_cars))
|
||||
{
|
||||
$modification_content = file_get_contents(API_HOST."/site/Vehicle/GetCatalog?id=". $car['uid'] ."", false, stream_context_create($arrContextOptions));
|
||||
$modification_json = json_decode($modification_content, true);
|
||||
$c++;
|
||||
}
|
||||
|
||||
//обновляем список ТС в битриксе
|
||||
$modification_content = file_get_contents(API_HOST."/site/Vehicle/GetCatalog?id=". $car['uid'] ."", false, stream_context_create($arrContextOptions));
|
||||
$modification_json = json_decode($modification_content, true);
|
||||
|
||||
$name = "".$car['brand']['name']." ".$car['model']['name']." ".$car['modification']."";
|
||||
$code = CUtil::translit( $name, "ru", [ "max_len" => 255, "change_case" => "L", "replace_space" => "-", "replace_other" => "-", ] );
|
||||
$name = "".$car['brand']['name']." ".$car['model']['name']." ".$car['modification']."";
|
||||
$replace_name = "".$car['brand']['name']." ".$car['model']['name']." ".$car['modification']."";
|
||||
$code = CUtil::translit( str_replace(["+"], ["-plus-"], $replace_name), "ru", [ "max_len" => 255, "change_case" => "L", "replace_space" => "-", "replace_other" => "-" ] );
|
||||
|
||||
$PROPERTY_VALUES = [
|
||||
"UID" => $car['uid'],
|
||||
"BRAND" => $bitrix_brands[ $car['brand']['id'] ],
|
||||
"MODEL" => $bitrix_models[ $car['model']['id'] ],
|
||||
"MODIFICATION" => $bitrix_modifications[ md5($car['brand']['id'].$car['model']['id'].$car['modification']) ],
|
||||
"MODIFICATION_YEAR" => $car['modificationYear'],
|
||||
"GEAR" => $car['gear'],
|
||||
"DRIVE" => $car['drive'],
|
||||
"BODY" => $car['body'],
|
||||
"ENGINE_POWER" => $car['engine']['power'],
|
||||
"ENGINE_VOLUME" => $car['engine']['volume'],
|
||||
"ENGINE_FUEL" => $car['engine']['fuel'],
|
||||
"PRICE" => $car['price'],
|
||||
"IMAGE_URL" => $car['url'],
|
||||
"COMPLECTATION_BODY" => json_encode($modification_json['body']),
|
||||
"COMPLECTATION_INTERIOR" => json_encode($modification_json['interior']),
|
||||
"COMPLECTATION_SECURITY" => json_encode($modification_json['security']),
|
||||
"COMPLECTATION_GUARANTEE" => json_encode($modification_json['guarantee']),
|
||||
"COMPLECTATION_TECHNICAL_DESCRIPTION" => json_encode($modification_json['technicalDescription']),
|
||||
"COMPLECTATION_FUNCTIONAL_EQUIPMENT" => json_encode($modification_json['functionalEquipment']),
|
||||
"COMPLECTATION_TOTAL_INFORMATION" => json_encode($modification_json['totalInformation']),
|
||||
"LEASING_PROGRAMS" => $car['programms'],
|
||||
];
|
||||
print "new car --- uid ".$car['uid']." | code ".$code."\n";
|
||||
|
||||
//"ID"
|
||||
$car_existed = null;
|
||||
$car_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, "PROPERTY_UID" => $car['uid'] ], false, ["nPageSize" => 1], [] );
|
||||
$PROPERTY_VALUES = [
|
||||
"UID" => $car['uid'],
|
||||
"BRAND" => $bitrix_brands[ $car['brand']['id'] ],
|
||||
"MODEL" => $bitrix_models[ $car['model']['id'] ],
|
||||
"MODIFICATION" => $bitrix_modifications[ md5($car['brand']['id'].$car['model']['id'].$car['modification']) ],
|
||||
"MODIFICATION_YEAR" => $car['modificationYear'],
|
||||
"GEAR" => $car['gear'],
|
||||
"DRIVE" => $car['drive'],
|
||||
"BODY" => $car['body'],
|
||||
"ENGINE_POWER" => $car['engine']['power'],
|
||||
"ENGINE_VOLUME" => $car['engine']['volume'],
|
||||
"ENGINE_FUEL" => $car['engine']['fuel'],
|
||||
"PRICE" => $car['price'],
|
||||
"IMAGE_URL" => $car['url'],
|
||||
"COMPLECTATION_BODY" => json_encode($modification_json['body']),
|
||||
"COMPLECTATION_INTERIOR" => json_encode($modification_json['interior']),
|
||||
"COMPLECTATION_SECURITY" => json_encode($modification_json['security']),
|
||||
"COMPLECTATION_GUARANTEE" => json_encode($modification_json['guarantee']),
|
||||
"COMPLECTATION_TECHNICAL_DESCRIPTION" => json_encode($modification_json['technicalDescription']),
|
||||
"COMPLECTATION_FUNCTIONAL_EQUIPMENT" => json_encode($modification_json['functionalEquipment']),
|
||||
"COMPLECTATION_TOTAL_INFORMATION" => json_encode($modification_json['totalInformation']),
|
||||
"LEASING_PROGRAMS" => $car['programms'],
|
||||
];
|
||||
|
||||
while($car_search_ob = $car_search_res->GetNextElement())
|
||||
{
|
||||
$car_existed = $car_search_ob->GetFields();
|
||||
//print "CAR FOUND\n\n";
|
||||
//print_r($car_existed);
|
||||
}
|
||||
//"ID"
|
||||
$car_existed = null;
|
||||
$car_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, "PROPERTY_UID" => $car['uid'] ], false, ["nPageSize" => 1], [] );
|
||||
|
||||
if($car_existed !== null)
|
||||
{
|
||||
CIBlockElement::SetPropertyValuesEx($car_existed['ID'], IBLOCK_ID_CATALOG_CARS_NEW, array_merge($car_update_payload, $PROPERTY_VALUES), []);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if($c === 0)
|
||||
//{
|
||||
$car_element = new CIBlockElement;
|
||||
$car_payload = [ "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => 1, "NAME" => $name, "CODE" => $code, "PROPERTY_VALUES" => $PROPERTY_VALUES, "ACTIVE" => "Y", ];
|
||||
|
||||
if($new_car_id = $car_element->Add($car_payload))
|
||||
{
|
||||
//$bitrix_brands[$brand_uid] = $new_brand_id;
|
||||
//echo "new car id: ".$new_car_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "brand error: ".$car_element->LAST_ERROR;
|
||||
}
|
||||
//}
|
||||
}
|
||||
while($car_search_ob = $car_search_res->GetNextElement())
|
||||
{
|
||||
$car_existed = $car_search_ob->GetFields();
|
||||
//print "CAR FOUND\n\n";
|
||||
//print_r($car_existed);
|
||||
}
|
||||
|
||||
$c++;
|
||||
$car_update_payload = [ "IBLOCK_SECTION" => false, "NAME" => $name, "CODE" => $code, "ACTIVE" => "Y", ];
|
||||
if($car_existed !== null)
|
||||
{
|
||||
$car_update_element = new CIBlockElement;
|
||||
$car_update_result = $car_update_element->Update($car_existed['ID'], $car_update_payload);
|
||||
|
||||
CIBlockElement::SetPropertyValuesEx($car_existed['ID'], IBLOCK_ID_CATALOG_CARS_NEW, $PROPERTY_VALUES, []);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if($c === 0)
|
||||
//{
|
||||
$car_element = new CIBlockElement;
|
||||
$car_payload = [ "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => 1, "NAME" => $name, "CODE" => $code, "PROPERTY_VALUES" => $PROPERTY_VALUES, "ACTIVE" => "Y", ];
|
||||
|
||||
if($new_car_id = $car_element->Add($car_payload))
|
||||
{
|
||||
//$bitrix_brands[$brand_uid] = $new_brand_id;
|
||||
//echo "new car id: ".$new_car_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "CAR ERROR: ".$car_element->LAST_ERROR." | ".$car['uid']." | ".$code."\n";
|
||||
|
||||
/*
|
||||
if($car_element->LAST_ERROR === "Элемент с таким символьным кодом уже существует.<br>")
|
||||
{
|
||||
print "replace: ".$car_existed['UID']." -> ".$car['uid']." | ".$code."\n";
|
||||
|
||||
$car_update_element = new CIBlockElement;
|
||||
$car_update_result = $car_update_element->Update($car_existed['ID'], $car_update_payload);
|
||||
|
||||
CIBlockElement::SetPropertyValuesEx($car_existed['ID'], IBLOCK_ID_CATALOG_CARS_NEW, $PROPERTY_VALUES, []);
|
||||
}
|
||||
*/
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
//print "car_codes?\n";
|
||||
/*
|
||||
foreach($car_codes AS $cc => $count)
|
||||
{
|
||||
if($count > 1)
|
||||
{
|
||||
print "cc ".$cc." - ".$count."\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
print "\n\nновых ТС: ".$c."\n\n";
|
||||
|
||||
//print "bitrix_existed_cars = ".count($bitrix_existed_cars)."\n";
|
||||
//print "json_new_cars = ".count($json_new_cars)."\n";
|
||||
|
||||
$h = 0;
|
||||
foreach($bitrix_existed_cars AS $existed_car_uid)
|
||||
{
|
||||
@ -479,7 +578,7 @@ foreach($bitrix_existed_brands AS $k => $b)
|
||||
{
|
||||
if($c < 10)
|
||||
{
|
||||
print $k." => ".$b."\n";
|
||||
//print $k." => ".$b."\n";
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
@ -490,7 +589,7 @@ foreach($bitrix_brands AS $k => $b)
|
||||
{
|
||||
if($c < 10)
|
||||
{
|
||||
print $k." => ".$b."\n";
|
||||
//print $k." => ".$b."\n";
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
@ -505,6 +604,9 @@ foreach($bitrix_existed_modifications AS $existed_modifications_code)
|
||||
}
|
||||
}
|
||||
|
||||
//print "API_MODELS:\n";
|
||||
//print_r($api_models);
|
||||
|
||||
print "\n\nснято с публикации модификаций: ".$md."\n";
|
||||
|
||||
$m = 0;
|
||||
@ -514,11 +616,17 @@ foreach($bitrix_existed_models AS $existed_model_uid)
|
||||
{}
|
||||
else
|
||||
{
|
||||
set_model_activity($existed_model_uid, "N");
|
||||
$m++;
|
||||
if(!in_array($existed_model_uid, $api_models))
|
||||
{
|
||||
set_model_activity($existed_model_uid, "N");
|
||||
$m++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//print "API_BRANDS:\n";
|
||||
//print_r($api_brands);
|
||||
|
||||
print "\n\nснято с публикации моделей: ".$m."\n";
|
||||
|
||||
$b = 0;
|
||||
@ -528,15 +636,16 @@ foreach($bitrix_existed_brands AS $existed_brand_uid)
|
||||
{}
|
||||
else
|
||||
{
|
||||
set_brand_activity($existed_brand_uid, "N");
|
||||
$b++;
|
||||
if(!in_array($existed_brand_uid, $api_brands))
|
||||
{
|
||||
set_brand_activity($existed_brand_uid, "N");
|
||||
$b++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n\nснято с публикации марок: ".$b."\n";
|
||||
|
||||
|
||||
die();
|
||||
|
||||
|
||||
?>
|
||||
@ -1,21 +1,85 @@
|
||||
$('a[href*="#order"]').each(function() {
|
||||
$(this).on("click", function(e) {
|
||||
e.preventDefault();
|
||||
$([document.documentElement, document.body]).animate({
|
||||
scrollTop: $("#order").offset().top - 80
|
||||
}, 500);
|
||||
})
|
||||
});
|
||||
// Cookie
|
||||
function setCookie(cookieName,cookieValue,daysToExpire,path,domain)
|
||||
{
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(daysToExpire*24*60*60*1000));
|
||||
document.cookie = cookieName + "=" + cookieValue + "; expires=" + date.toGMTString() + '; path=' + path;
|
||||
// + 'domain=' + domain
|
||||
}
|
||||
|
||||
//let activeMenuLink = $("header #menu_list li.active").length > 0 ? $("header #menu_list li.active a").text() : "Главная";
|
||||
//console.log($("header #menu_list li.active"));
|
||||
//$("header .nav_toggle").text(activeMenuLink);
|
||||
function getCookieValue(cookieName)
|
||||
{
|
||||
var cookieValue = document.cookie.match('(^|;)\\s*' + cookieName + '\\s*=\\s*([^;]+)');
|
||||
return cookieValue ? cookieValue.pop() : '0';
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
function is_email(email)
|
||||
{
|
||||
var regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return regex.test(email);
|
||||
}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('a[href*="#order"]').each(function() {
|
||||
$(this).on("click", function(e) {
|
||||
e.preventDefault();
|
||||
$([document.documentElement, document.body]).animate({
|
||||
scrollTop: $("#order").offset().top - 80
|
||||
}, 500);
|
||||
})
|
||||
});
|
||||
|
||||
// Main menu toggle
|
||||
let menuToggleBtn = document.getElementsByClassName("nav_toggle")[0];
|
||||
menuToggleBtn.addEventListener("click", (event) => {
|
||||
document.getElementById("menu_list").classList.toggle("open");
|
||||
$(".nav_toggle").on("click", function()
|
||||
{
|
||||
$("#menu_list").toggleClass("open");
|
||||
});
|
||||
|
||||
let cookies = getCookieValue('Policy');
|
||||
if(cookies != 'true')
|
||||
{
|
||||
$("#cookie").show();
|
||||
}
|
||||
|
||||
$('#cookie .close').click(function()
|
||||
{
|
||||
$('#cookie').hide();
|
||||
setCookie('Policy', 'true', '365', '/');
|
||||
});
|
||||
|
||||
$(".personal_data_link").on("click", function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
window.open('/personal_data/', "_blank");
|
||||
});
|
||||
|
||||
var urlSearchParams = new URLSearchParams(window.location.search);
|
||||
var params = Object.fromEntries(urlSearchParams.entries());
|
||||
|
||||
for(let i in params)
|
||||
{
|
||||
if(i.indexOf("utm_") > -1)
|
||||
{
|
||||
setCookie(i, params[i], '365', '/');
|
||||
}
|
||||
}
|
||||
|
||||
$("#bx-panel-expander").on("click", function()
|
||||
{
|
||||
$(".header_with_offset").removeClass("header_with_offset").addClass("header_with_offset_extended");
|
||||
$(".content_with_offset").removeClass("content_with_offset").addClass("content_with_offset_extended");
|
||||
});
|
||||
|
||||
$("#bx-panel-hider").on("click", function()
|
||||
{
|
||||
$(".header_with_offset_extended").removeClass("header_with_offset_extended").addClass("header_with_offset");
|
||||
$(".content_with_offset_extended").removeClass("content_with_offset_extended").addClass("content_with_offset");
|
||||
});
|
||||
|
||||
$(".header_recall_button").on("click", function()
|
||||
{
|
||||
ComagicWidget.openSitePhonePanel();
|
||||
});
|
||||
|
||||
// News Slider
|
||||
@ -199,7 +263,6 @@ document.addEventListener("DOMContentLoaded", function (event) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Фильтры
|
||||
const filterBlock = document.querySelectorAll(".sort_selector");
|
||||
if (filterBlock.length > 0) {
|
||||
@ -211,74 +274,4 @@ document.addEventListener("DOMContentLoaded", function (event) {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Cookie
|
||||
function setCookie(cookieName,cookieValue,daysToExpire,path,domain)
|
||||
{
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(daysToExpire*24*60*60*1000));
|
||||
document.cookie = cookieName + "=" + cookieValue + "; expires=" + date.toGMTString() + '; path=' + path;
|
||||
// + 'domain=' + domain
|
||||
}
|
||||
|
||||
function getCookieValue(cookieName)
|
||||
{
|
||||
var cookieValue = document.cookie.match('(^|;)\\s*' + cookieName + '\\s*=\\s*([^;]+)');
|
||||
return cookieValue ? cookieValue.pop() : '0';
|
||||
}
|
||||
|
||||
function is_email(email)
|
||||
{
|
||||
var regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return regex.test(email);
|
||||
}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
let cookies = getCookieValue('Policy');
|
||||
if(cookies != 'true')
|
||||
{
|
||||
$("#cookie").show();
|
||||
}
|
||||
|
||||
$('#cookie .close').click(function()
|
||||
{
|
||||
$('#cookie').hide();
|
||||
setCookie('Policy', 'true', '365', '/');
|
||||
});
|
||||
|
||||
$(".personal_data_link").on("click", function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
window.open('/personal_data/', "_blank");
|
||||
});
|
||||
|
||||
var urlSearchParams = new URLSearchParams(window.location.search);
|
||||
var params = Object.fromEntries(urlSearchParams.entries());
|
||||
|
||||
for(let i in params)
|
||||
{
|
||||
if(i.indexOf("utm_") > -1)
|
||||
{
|
||||
setCookie(i, params[i], '365', '/');
|
||||
}
|
||||
}
|
||||
|
||||
$("#bx-panel-expander").on("click", function()
|
||||
{
|
||||
$(".header_with_offset").removeClass("header_with_offset").addClass("header_with_offset_extended");
|
||||
$(".content_with_offset").removeClass("content_with_offset").addClass("content_with_offset_extended");
|
||||
});
|
||||
|
||||
$("#bx-panel-hider").on("click", function()
|
||||
{
|
||||
$(".header_with_offset_extended").removeClass("header_with_offset_extended").addClass("header_with_offset");
|
||||
$(".content_with_offset_extended").removeClass("content_with_offset_extended").addClass("content_with_offset");
|
||||
});
|
||||
|
||||
$(".header_recall_button").on("click", function()
|
||||
{
|
||||
ComagicWidget.openSitePhonePanel();
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user