emergency updates after release, ILSA loading update

This commit is contained in:
merelendor 2022-11-30 08:04:37 +03:00
parent b03fae38ca
commit f0671ffcc4
11 changed files with 7573 additions and 31 deletions

4
.gitignore vendored
View File

@ -8,4 +8,6 @@ sitemap*
.htsecure
cron/yasprav.log
vizitka/tmp/
vkteamssetup.exe
vkteamssetup.exe
local/*.json
local/*.txt

7346
.htaccess

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
function get_related($iblock_id, $id)
{
$res = CIBlockElement::GetList(Array("NAME" => "ASC"), Array("IBLOCK_ID" => $iblock_id, "ID" => $id, "ACTIVE" => "Y"), false, Array("nPageSize" => 1000));
$res = CIBlockElement::GetList(Array("NAME" => "ASC"), Array("IBLOCK_ID" => $iblock_id, "ID" => $id, ), false, Array("nPageSize" => 1000));
$ar_res = Array();
while ($obElement = $res->GetNextElement())
@ -20,7 +20,7 @@ function get_related_array($iblock_id, $ids)
foreach($ids AS $id)
{
$res = CIBlockElement::GetList(Array("NAME" => "ASC"), Array("IBLOCK_ID" => $iblock_id, "ID" => $id, "ACTIVE" => "Y"), false, Array("nPageSize" => 1000));
$res = CIBlockElement::GetList(Array("NAME" => "ASC"), Array("IBLOCK_ID" => $iblock_id, "ID" => $id, ), false, Array("nPageSize" => 1000));
while ($obElement = $res->GetNextElement())
{

View File

@ -36,7 +36,6 @@ $APPLICATION->SetTitle("Новые автомобили в лизинг");
)
);
?>
<?
$APPLICATION->IncludeComponent(
"evolution:form.leasing",

View File

@ -21,7 +21,7 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
{
$arResult = [];
$sort = Array("SORT" => "ASC", "NAME" => "ASC");
$filter = Array("ACTIVE" => "Y", "IBLOCK_ID" => 1, "CODE" => $arParams['OFFER']);
$filter = Array("IBLOCK_ID" => 1, "CODE" => $arParams['OFFER']);
$options = Array("nPageSize" => 1);
$res = CIBlockElement::GetList($sort, $filter, false, $options);

View File

@ -0,0 +1,51 @@
<?
define('STOP_STATISTICS', true);
define('NO_KEEP_STATISTIC', 'Y');
define('NO_AGENT_STATISTIC', 'Y');
define('DisableEventsCheck', true);
define('BX_SECURITY_SHOW_MESSAGE', true);
define('NOT_CHECK_PERMISSIONS', true);
$_SERVER['DOCUMENT_ROOT'] = dirname(__DIR__, 1);
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');
CModule::IncludeModule('iblock');
$old_uids_json = file_get_contents("./uids_codes.json");
$old_uids = json_decode($old_uids_json, true);
$old = 0;
$new = 0;
$total = 0;
$car_search_res = CIBlockElement::GetList( [ "ID" => "ASC" ], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, ], false, [], [] );
$redirects = "";
while($car_search_ob = $car_search_res->GetNextElement())
{
$car_existed = $car_search_ob->GetFields();
$car_existed['PROPERTIES'] = $car_search_ob->GetProperties();
$uid = $car_existed['PROPERTIES']['UID']['VALUE'];
if(isset($old_uids[ $uid ]))
{
$old++;
$redirects .= "RewriteRule ^car/". $old_uids[ $uid ] ."/$ https://www.evoleasing.ru/car/". $car_existed['CODE'] ."/ [R=301,NE,NC,L]\n";
}
else
{
$new++;
}
$total++;
}
print "old "+$old."\n";
print "new "+$new."\n";
print "total "+$total."\n";
file_put_contents("./car_redirects.txt", $redirects);
die();
?>

35
local/ilsa_code_fix.php Normal file
View File

@ -0,0 +1,35 @@
<?
define('STOP_STATISTICS', true);
define('NO_KEEP_STATISTIC', 'Y');
define('NO_AGENT_STATISTIC', 'Y');
define('DisableEventsCheck', true);
define('BX_SECURITY_SHOW_MESSAGE', true);
define('NOT_CHECK_PERMISSIONS', true);
$_SERVER['DOCUMENT_ROOT'] = dirname(__DIR__, 1);
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');
CModule::IncludeModule('iblock');
$car_search_res = CIBlockElement::GetList( [ "ID" => "ASC" ], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, ], false, [], [] );
$c = 0;
while($car_search_ob = $car_search_res->GetNextElement())
{
$car_existed = $car_search_ob->GetFields();
$car_existed['PROPERTIES'] = $car_search_ob->GetProperties();
$title = $car_existed['NAME']." ".$car_existed['PROPERTIES']['MODIFICATION_YEAR']['VALUE'];
$code = CUtil::translit( str_replace(["&quot;", " ", "+"], ['"', "-", "-plus-"], $title), "ru", [ "max_len" => 255, "change_case" => "L", "replace_space" => "-", "replace_other" => "-", "safe_chars" => "-" ] );
print $code."\n";
$car_update_element = new CIBlockElement;
$car_update_result = $car_update_element->Update($car_existed['ID'], [ "CODE" => $code ]);
$c++;
}
print "\n\ntotal ".$c;
die();
?>

View File

@ -51,7 +51,7 @@ while($all_modifications_search_ob = $all_modifications_search_res->GetNextEleme
array_push( $bitrix_existed_modifications, $modification_search['CODE'] );
}
$all_cars_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 1, "ACTIVE" => "Y" ], false, false, [] );
$all_cars_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => 1, ], false, false, [] );
while($all_cars_search_ob = $all_cars_search_res->GetNextElement())
{
$car_search = $all_cars_search_ob->GetFields();
@ -65,7 +65,12 @@ print "bitrix_existed_models = ".count($bitrix_existed_models)."\n";
print "bitrix_existed_modifications = ".count($bitrix_existed_modifications)."\n";
print "bitrix_existed_cars = ".count($bitrix_existed_cars)."\n";
$content = file_get_contents(API_HOST."/site/Vehicle/GetModifications", false, stream_context_create($arrContextOptions));
$api_modifications_url = API_HOST."/site/Vehicle/GetModifications";
$content = file_get_contents($api_modifications_url, false, stream_context_create($arrContextOptions));
print $api_modifications_url."\n\n";
file_put_contents("./api_modifications.json", $content);
$json = json_decode($content, true);
$brands_and_models = [];
@ -75,9 +80,12 @@ $brands_and_models = [];
$c = 0;
$api_data_titles = [];
$api_data = [];
$api_brands = [];
$api_models = [];
$api_modifications = [];
$api_cars = [];
//prepare brands list from API
@ -90,6 +98,13 @@ foreach($json AS $entry)
];
}
if(!isset($api_data_titles[ $entry['brand']['name'] ]))
{
$api_data_titles[ $entry['brand']['name'] ] = [
"models" => []
];
}
if(!in_array($entry['brand']['id'], $api_brands))
{
array_push($api_brands, $entry['brand']['id']);
@ -102,7 +117,14 @@ 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" => []
"modifications" => []
];
}
if(!isset($api_data_titles[ $entry['brand']['name'] ]['models'][ $entry['model']['name'] ]))
{
$api_data_titles[ $entry['brand']['name'] ]['models'][ $entry['model']['name'] ] = [
"modifications" => []
];
}
@ -112,12 +134,40 @@ foreach($json AS $entry)
}
}
//prepare models list from API
//prepare modifications list from API
foreach($json AS $entry)
{
if(!isset($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['cars'][ $entry['uid'] ]))
if(!isset($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['modifications'][ $entry['modification'] ]))
{
array_push($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['cars'], $entry['uid']);
$api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['modifications'][ $entry['modification'] ] = [
"cars" => []
];
}
if(!isset($api_data_titles[ $entry['brand']['name'] ]['models'][ $entry['model']['name'] ]['modifications'][ $entry['modification'] ]))
{
$api_data_titles[ $entry['brand']['name'] ]['models'][ $entry['model']['name'] ]['modifications'][ $entry['modification'] ] = [
"cars" => []
];
}
if(!in_array($entry['modification'], $api_modifications))
{
array_push($api_modifications, $entry['modification']);
}
}
//prepare cars list from API
foreach($json AS $entry)
{
if(!isset($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['modifications'][ $entry['modification'] ]['cars'][ $entry['uid'] ]))
{
array_push($api_data[ $entry['brand']['id'] ]['models'][ $entry['model']['id'] ]['modifications'][ $entry['modification'] ]['cars'], $entry['uid']);
}
if(!isset($api_data_titles[ $entry['brand']['name'] ]['models'][ $entry['model']['name'] ]['modifications'][ $entry['modification'] ]['cars'][ $entry['uid'] ]))
{
array_push($api_data_titles[ $entry['brand']['name'] ]['models'][ $entry['model']['name'] ]['modifications'][ $entry['modification'] ]['cars'], $entry['uid']);
}
if(!in_array($entry['uid'], $api_cars))
@ -126,6 +176,25 @@ foreach($json AS $entry)
}
}
ksort($api_data_titles);
foreach($api_data_titles AS $k => $v)
{
$models = $v['models'];
ksort($models);
foreach($models AS $kk => $vv)
{
$modifications = $vv['modifications'];
ksort($modifications);
$models[$kk]['modifications'] = $modifications;
}
$api_data_titles[$k]['models'] = $models;
}
file_put_contents("./api_data_titles.json", json_encode($api_data_titles));
//print_r($bitrix_existed_models);
foreach($bitrix_existed_models AS $existed_model)
{
@ -313,7 +382,7 @@ function set_modification_activity($modification_code, $active = "N")
function set_car_activity($car_uid, $active = "N")
{
print "SET ACTIVE ".$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, [] );
@ -433,14 +502,14 @@ function models_check($bitrix_models, $bitrix_modifications, $bitrix_modificatio
];
}
print "bitrix brands\n\n";
print_r($bitrix_brands);
print "bitrix brands count: ".count($bitrix_brands)."\n";
//print_r($bitrix_brands);
print "bitrix models\n\n";
print_r($bitrix_models);
print "bitrix models count: ".count($bitrix_models)."\n";
//print_r($bitrix_models);
print "bitrix modifications\n\n";
print_r($bitrix_modifications);
print "bitrix modifications count: ".count($bitrix_modifications)."\n";
//print_r($bitrix_modifications);
//кешируем новые UID ТС
$json_new_cars = [];
@ -464,10 +533,11 @@ foreach($json AS $car)
$modification_json = json_decode($modification_content, true);
$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" => "-" ] );
print "new car --- uid ".$car['uid']." | code ".$code."\n";
$title = $name." ".$car['modificationYear']."";
$code = CUtil::translit( str_replace(["&quot;", " ", "+"], ['"', "-", "-plus-"], $title), "ru", [ "max_len" => 255, "change_case" => "L", "replace_space" => "-", "replace_other" => "-", "safe_chars" => "-" ] );
//print "new car --- uid ".$car['uid']." | code ".$code."\n";
$PROPERTY_VALUES = [
"UID" => $car['uid'],
@ -528,17 +598,24 @@ foreach($json AS $car)
{
print "CAR ERROR: ".$car_element->LAST_ERROR." | ".$car['uid']." | ".$code."\n";
/*
if($car_element->LAST_ERROR === "Элемент с таким символьным кодом уже существует.<br>")
if($car_element->LAST_ERROR == "Элемент с таким символьным кодом уже существует.<br>")
{
print "replace: ".$car_existed['UID']." -> ".$car['uid']." | ".$code."\n";
$car_with_problem = null;
$car_with_problem_res = CIBlockElement::GetList( [ "ID" => "ASC" ], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, "CODE" => $code ], false, ["nPageSize" => 1], [] );
while($car_with_problem_ob = $car_with_problem_res->GetNextElement())
{
$car_with_problem = $car_with_problem_ob->GetFields();
}
$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, []);
if($car_with_problem !== null)
{
print "REPLACE FOR ".$car_with_problem['ID']." uid => ".$car['uid']."\n\n";
print_r($car_with_problem);
print "\n\n\n";
CIBlockElement::SetPropertyValuesEx($car_with_problem['ID'], IBLOCK_ID_CATALOG_CARS_NEW, $PROPERTY_VALUES, []);
}
}
*/
}
//}
}

View File

@ -0,0 +1,32 @@
<?
//$_SERVER["DOCUMENT_ROOT"] = __DIR__;
define('STOP_STATISTICS', true);
define('NO_KEEP_STATISTIC', 'Y');
define('NO_AGENT_STATISTIC', 'Y');
define('DisableEventsCheck', true);
define('BX_SECURITY_SHOW_MESSAGE', true);
define('NOT_CHECK_PERMISSIONS', true);
$_SERVER['DOCUMENT_ROOT'] = dirname(__DIR__, 1);
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');
CModule::IncludeModule('iblock');
$car_search_res = CIBlockElement::GetList( [ "ID" => "ASC" ], [ "IBLOCK_ID" => IBLOCK_ID_CATALOG_CARS_NEW, ], false, [], [] );
$c = 0;
$uids = [];
while($car_search_ob = $car_search_res->GetNextElement())
{
$car_existed = $car_search_ob->GetFields();
$car_existed['PROPERTIES'] = $car_search_ob->GetProperties();
$uids[$car_existed['PROPERTIES']['UID']['VALUE']] = $car_existed['CODE'];
}
print count($uids);
file_put_contents("./uids_codes_2022_11_30.json", json_encode($uids));
die();
?>

View File

@ -1,7 +1,7 @@
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
IncludeTemplateLangFile(__FILE__);
?>
<html>
<!DOCTYPE html><html lang="ru">
<head>
<? CJSCore::Init(array("jquery3")); ?>
<script type="text/javascript">

View File

@ -1,7 +1,7 @@
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
IncludeTemplateLangFile(__FILE__);
?>
<html>
<!DOCTYPE html><html lang="ru">
<head>
<? CJSCore::Init(array("jquery3")); ?>
<!-- Google Tag Manager -->