require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if(isset($_POST["title"]) && isset($_POST["sort"]) && isset($_POST["page"]) && isset($_POST["section"])){
$sort = Order::GetSort();
$sort = $_POST["sort"];
$title = $_POST["title"];
$page = $_POST["page"];
$section = $_POST["section"];
if($sort == 'abc'){
$asort = ['NAME' => 'ASC'];
}else if($sort == 'zyx'){
$asort = ['NAME' => 'DESC'];
}else if($sort == 'price'){
$asort = ['CATALOG_PRICE_2' => 'ASC'];
}else if($sort == 'priced'){
$asort = ['CATALOG_PRICE_2' => 'DESC'];
}
$sWords = explode(" ", $title);
foreach($sWords as $word){
$sQuery .= "%" . $word;
}
$sQuery .= "%";
$filter = Array('IBLOCK_ID' => 11, 'SECTION_ID' => $section, 'INCLUDE_SUBSECTIONS' => 'Y', 'NAME' => $sQuery, 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y', 'CATALOG_AVAILABLE' => 'Y');
$filterSKU = Array(
'IBLOCK_ID' => 11,
'SECTION_ID' => $section,
'INCLUDE_SUBSECTIONS' => 'Y',
[
'LOGIC' => 'OR',
['NAME' => $sQuery],
['PROPERTY_CML2_ARTICLE' => "%{$sQuery}%"],
],
'ACTIVE' => 'Y',
'GLOBAL_ACTIVE' => 'Y',
'CATALOG_AVAILABLE' => 'Y',
);
$select = Array('ID', 'NAME', 'XML_ID', 'PREVIEW_PICTURE', 'CATALOG_GROUP_1', 'DETAIL_PAGE_URL', 'CATALOG_AVAILABLE', 'IBLOCK_SECTION_ID', 'ZAKAZNAYA_PRODKUTSIYA_DLYA_SAYTA');
$rows = CIBlockElement::GetList($asort, $filterSKU, false, Array("nPageSize" => 10, "iNumPage" => $page), $select);
while($ob = $rows->GetNextElement())
{
$res = $ob->GetFields();
$props = $ob->GetProperties();
$item = [];
if(!Order::IsQuality($res["XML_ID"]))
continue;
$item['id'] = $res['ID'];
$item['name'] = $res['NAME'];
$file = CFile::GetFileArray($res["PREVIEW_PICTURE"]);
$item['image'] = $file ? $file['SRC'] : '/local/images/no-image.png';
$item['price'] = CPrice::GetBasePrice($item['id'])['PRICE'];
$item['url'] = $res['DETAIL_PAGE_URL'];
$item['cat'] = isset($cats[$res['IBLOCK_SECTION_ID']]) ? $cats[$res['IBLOCK_SECTION_ID']] : '';
$item['qty'] = $res['CATALOG_QUANTITY'];
if($item['qty']>0) {
$item['podzakaz']="Нет";
}else{
$item['podzakaz']="Да";
}
$item['how'] = ($item['qty'] > 4) ? 'Много' : 'Мало';
$item['available'] = $res['CATALOG_AVAILABLE'] == 'Y';
$item['sku'] = $props['CML2_ARTICLE']['VALUE'];
$item['used_with'] = $props['DLYA_KAKOGO_KONKRETNO_OBORUDOVANIYA']['VALUE'];
if($props['DLYA_KAKOGO_KONKRETNO_OBORUDOVANIYA_1']['VALUE'])
$item['used_with'] .= ($item['used_with'] ? ', ' : '') . $props['DLYA_KAKOGO_KONKRETNO_OBORUDOVANIYA_1']['VALUE'];
if($props['DLYA_KAKOGO_KONKRETNO_OBORUDOVANIYA_2']['VALUE'])
$item['used_with'] .= ($item['used_with'] ? ', ' : '') . $props['DLYA_KAKOGO_KONKRETNO_OBORUDOVANIYA_2']['VALUE'];
$item['used_with'] = trim($item['used_with']);
$item['man'] = trim($props['CML2_MANUFACTURER']['VALUE']);
$item['inCart'] = 0;
$meas = \Bitrix\Catalog\ProductTable::getCurrentRatioWithMeasure($item['id']);
$item['measure_count'] = [1, 2, 3, 4, 5, 10, 20];
$item['measure_ratio'] = $meas ? $meas[$item['id']]['RATIO'] : '1';
$item['measure_id'] = $meas ? $meas[$item['id']]['MEASURE']['ID'] : '5';
$item['measure'] = $meas ? $meas[$item['id']]['MEASURE']['SYMBOL_RUS'] : 'шт';
$prods[] = $item;
}
$product_count = count($prods);
$rows->NavStart();
$product_total = $rows->NavRecordCount;
}
?>
Warning: Undefined variable $prods in D:\ktt\ttepla.com\public_html\local\components\ttepla\catalog.list\templates\catalog-list-ajax\ajax.php on line 175
Warning: foreach() argument must be of type array|object, null given in D:\ktt\ttepla.com\public_html\local\components\ttepla\catalog.list\templates\catalog-list-ajax\ajax.php on line 175