ilsa update hotfix
This commit is contained in:
parent
ad1b5435e6
commit
383d506b72
@ -86,24 +86,59 @@ $repost_cars = [];
|
||||
|
||||
function elasticIndex($index, $payload)
|
||||
{
|
||||
if(!in_array("debug", $GLOBALS['argv']))
|
||||
{
|
||||
print "elasticIndex()\n";
|
||||
print_r([ "index" => $index, "payload" => $payload ]);
|
||||
print "\n\n";
|
||||
}
|
||||
|
||||
$uid = implode("_", array_merge([ "date" => date("Ymd") ], array_intersect_key($payload, array_flip(['brand', 'model', 'modification']))));
|
||||
print "uid = ".$uid." | ".$payload['status']."\n";
|
||||
print "elasticIndex() uid = ".$uid." | ".$payload['status']."\n";
|
||||
$id = md5($uid);
|
||||
|
||||
print "prepare curl request for: ".ELASTICSEARCH_HOST.$index."/_doc/".$id."/\n";
|
||||
print "elasticIndex() payload:\n";
|
||||
print_r($payload);
|
||||
print "\n";
|
||||
print "JSON: ".json_encode($payload)."\n";
|
||||
print "\n\n";
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, ELASTICSEARCH_HOST.$index."/_doc/".$id."/");
|
||||
curl_setopt($ch, CURLOPT_USERPWD, ELASTICSEARCH_USERNAME . ":" . ELASTICSEARCH_PASSWORD);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 2000);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//curl_setopt($ch, CURLOPT_FORBID_REUSE, 0);
|
||||
//curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||
|
||||
if(!in_array("debug", $GLOBALS['argv']))
|
||||
{
|
||||
print "elasticIndex() payload:\n";
|
||||
print json_encode($payload);
|
||||
print "\n\n";
|
||||
}
|
||||
|
||||
print "make curl request\n";
|
||||
$response = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
print $response."\n\n";
|
||||
|
||||
if($error)
|
||||
{
|
||||
print "elasticIndex() error:\n";
|
||||
print $error;
|
||||
print "\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "elasticIndex() response:\n";
|
||||
print $response;
|
||||
print "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
$all_brands_search_res = CIBlockElement::GetList( [], [ "IBLOCK_ID" => IBLOCK_ID_BRANDS, ], false, false, [] );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user