Commit a2c617c0 authored by Kulya's avatar Kulya 😊

Upd alvbx add prods1

parent a895d16a
......@@ -306,34 +306,120 @@ class AloVoiceRest
}
}
private function process_bx_product($data,$full=false) {
private function bx_process_product($data,$full=false) {
/*
{
"ID": 1261574,
"name": "*Tahorat va namoz",
"sku": "Q001",
"barCode": "9789943542556",
"price": 23000,
"priceUSD": 23000,
"discountAmount": 0,
"qty": 15,
"properties": {
"BRAND": "",
"CATEGORY": "Kitob",
"COLLECTION": "",
"COLOR": "",
"DESCRIPTION": "Tahorat lug'atda poklikdir. Poklik – inson tabiatan rag'bat qiladigan go'zal sifatlarning biridir. Islom dini insonlarni poklikka targ'ib qiladi va o'zlarini pok tutuvchilarni maqtaydi. \"Albatta Alloh tavba qilguvchilarni va o'zlarini mudom pok tutguvchilarni sevadi\" (Baqara - 222). Hadisi sharifda Rasululloh sollallohu alayhi vasallam: \"poklik iymonning yarmidir\", deb aytganlar. (Buxoriy rivoyati).",
"GENDER": "",
"SEASON": "",
"SIZE": "14*21",
"SUB_CATEGORY": "Foydali kitoblar",
"АВТОР": "",
"ВЕС": "220gr",
"ЖАНР": "",
"ИЗДАТЕЛЬСТВО": "G'afur G'ulom nashryot-matbaa ijodiy uyi",
"КОЛИЧЕСТВО_СТРАНИЦ": "185",
"НАПРАВЛЕНИЕ": "Kitoblar",
"ПОДКАТЕГОРИЯ2": "Din ahkomlari (namoz, zakot..)",
"ПОСТАВЩИК": "Islomaka",
"ТИП_ОБЛОЖКИ": "Yumshoq"
},
"offices": [
{
"officeID": 1347,
"officeName": "Qamar Kitoblar A.Navoiy",
"price": 23000,
"priceUSD": 23000,
"discountAmount": 0,
"qty": 15
}
],
"imageUrls": [
{
"url": "https://app.billz.uz/fileupload/products/2021/02/25/901F535D975D24B3334CC40D4DC62922_022521120712_square.jpeg"
}
],
"totalRows": 990
}
*/
$conf = self::get_billzconf();
// $data["xmlId"] = "1226zz";
$arProduct = [];
$xmlId = (!empty($data["xmlId"])) ? $data["xmlId"] : $data["id"];
$currency = 'UZS';
$result = false;
if(!empty($conf["bx_catalog_id"])){
$arProduct = [];
$select = ($full) ? [ 'id', 'iblockId', '*' ] : ['id', 'iblockId'];
$result = BxRest::call('catalog.product.list',[
"filter" => [
"xmlId" => $data["xmlId"],
"iblockId" => $conf["bx_catalog_id"],
],
"select" => $select
]);
if(!empty($result["result"]["products"])){
$arProduct = $result["result"]["products"][0];
}
$xmlId = $data["ID"];
$select = ($full) ? [ 'id', 'iblockId', '*' ] : ['id', 'iblockId'];
$result = BxRest::call('catalog.product.list',[
"filter" => [
"xmlId" => $data["xmlId"],
"iblockId" => $conf["bx_catalog_id"],
],
"select" => $select
]);
if(!empty($result["result"]["products"])){
$arProduct = $result["result"]["products"][0];
}
if(empty($arProduct)){
$arNewProductParams = [];
if(empty($arProduct)){
$arNewProductParams = [
"iblockId" => $conf["bx_catalog_id"],
"name" => $data["name"],
"code" => $this->translit($data["name"]),
"xmlId" => $data["id"],
"quantity" => (!empty($data["qty"])) ? $data["qty"] : 0,
"quantityTrace" => 'N',
];
if(!empty($data["price"])){
$arNewProductParams["purchasingCurrency"] = $currency;
$arNewProductParams["purchasingPrice"] = $data["price"];
}
if(!empty($data["sid"])){
$arNewProductParams["iblockSectionId"] = $data["sid"];
}
if(!empty($conf["bxbillzfields"])){
foreach($conf["bxbillzfields"] as $bxf=>$blzf){
$bxFld = substr($bxf,9);
if(substr($blzf,0,11)=="properties_"){
$blzSubFldCode = substr($blzf,11);
$blzVal = $data["properties"][$blzSubFldCode];
}
else {
$blzVal = $blzf;
}
if( $bxFld != "xmlId" && $bxFld != "quantity" ){
$arNewProductParams[$bxFld] = $blzVal;
}
}
}
if(!empty($data["imageUrls"])){
}
$arProduct = BxRest::call('catalog.product.list',$arNewProductParams);
}
}
return $arProduct;
}
......@@ -414,23 +500,27 @@ class AloVoiceRest
}
foreach($first["answer"]["result"] as $prd){
$prid = false;
$sid = false;
if(!empty($prd["properties"]["CATEGORY"])){
if(!in_array($prd["properties"]["CATEGORY"],$arSections)){
$arSections[] = $prd["properties"]["CATEGORY"];
}
$rpid = $this->process_product_section($prd["properties"]["CATEGORY"]);
// if(!in_array($prd["properties"]["CATEGORY"],$arSections)){
// $arSections[] = $prd["properties"]["CATEGORY"];
// }
}
if(!empty($prd["properties"]["SUB_CATEGORY"])){
if(!in_array($prd["properties"]["SUB_CATEGORY"],$arSubSections)){
$arSubSections[] = $prd["properties"]["SUB_CATEGORY"];
}
$sid = $this->process_product_section($prd["properties"]["SUB_CATEGORY"],$rpid);
// if(!in_array($prd["properties"]["SUB_CATEGORY"],$arSubSections)){
// $arSubSections[] = $prd["properties"]["SUB_CATEGORY"];
// }
}
if(!empty($prd["properties"]["ПОДКАТЕГОРИЯ2"])){
if(!in_array($prd["properties"]["ПОДКАТЕГОРИЯ2"],$arTrdSections)){
$arTrdSections[] = $prd["properties"]["ПОДКАТЕГОРИЯ2"];
}
$this->process_product_section($prd["properties"]["SUB_CATEGORY"],$sid);
// if(!in_array($prd["properties"]["ПОДКАТЕГОРИЯ2"],$arTrdSections)){
// $arTrdSections[] = $prd["properties"]["ПОДКАТЕГОРИЯ2"];
// }
}
// process offices
......@@ -458,6 +548,15 @@ class AloVoiceRest
return $return;
}
private function process_product_section($name='',$parent_id=false) {
$sid = false;
if(!$sid = $this->bx_get_product_section($name)){
$sid = $this->bx_add_product_section($name,$parent_id);
}
return $sid;
}
private function bx_get_product_section($name='') {
$conf = self::get_billzconf();
$result = false;
......@@ -501,6 +600,14 @@ class AloVoiceRest
}
private function test($r=false) {
$conf = self::get_billzconf();
return BxRest::call("catalog.product.getFieldsByFilter",[
"filter" => [
"iblockId" => $conf["bx_catalog_id"],
"productType" => 1
]
]);
return $this->bx_add_product_section($r[0]);
}
......@@ -2297,6 +2404,18 @@ function(result){
}
private function testmtd($r=false) {
$method = $r["method"];
$r["method"] = null;
unset($r["method"]);
if(!empty($r)){
$arResults = BxRest::call($method,$r);
}
else {
$arResults = BxRest::call($method);
}
//return $this->configv["alovoice_host"];
//return $r;
/*
......@@ -2309,7 +2428,6 @@ function(result){
]);
*/
//$arResults = BxRest::call('crm.activity.type.delete',['TYPE_ID'=>'alosms']);
$arResults = BxRest::call('crm.activity.type.list');
//$arResults = BxRest::call('crm.enum.activitydirection');
//$arResults = BxRest::call('crm.enum.contenttype');
//$arResults = BxRest::call('crm.enum.activitypriority');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment