Current Path : /home/bitrix/ext_www/klimatlend.ua/ajax/ |
Current File : /home/bitrix/ext_www/klimatlend.ua/ajax/search.php |
<? require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"); ?> <? CModule::IncludeModule("iblock"); CModule::IncludeModule("sale"); CModule::IncludeModule("catalog"); $APPLICATION->SetTitle("Поиск по фразе: \"" . $_GET["q"]."\""); $quote = ""; $page = "1"; if( !empty($_GET["q"]) ){ $quote = $_GET["q"]; } if( !empty($_GET["p"]) ){ $page = $_GET["p"]; } //$quote = "кондиционеры"; $categories = array(); $products = array(); $arQuote = array(); $s = strlen($quote); $arQuote[0] = $quote; $arQuote[1] = substr($quote,-$s,$s-1); //$arQuote[2] = substr($quote,-$s,$s-2); $arFilter = array('IBLOCK_ID' => 6, "%NAME"=>$arQuote, "ACTIVE"=>"Y", ">CATALOG_QUANTITY"=>"0"); $rsSections = CIBlockSection::GetList(array('ID' => 'ASC'), $arFilter, false, array("*"), Array("nPageSize"=>5)); while ($arSection = $rsSections->GetNext()) { // if($arSection["PICTURE"]) $categories [$arSection["ID"]] = array( "ID"=>$arSection["ID"], "NAME"=>$arSection["NAME"], "LINK"=>$arSection["SECTION_PAGE_URL"], "IMG"=>CFile::GetPath($arSection["PICTURE"]) ); } $arFilter1 = array('IBLOCK_ID' => 6, "%NAME"=>$arQuote, "ACTIVE"=>"Y"); $rsSections1 = CIBlockElement::GetList(array('shows' => 'DESC'), $arFilter1, false,Array("iNumPage"=>$page,"nPageSize"=>15), array("*")); while ($arSection1 = $rsSections1->GetNext()) { $ar_res = CCatalogProduct::GetByIDEx($arSection1["ID"]); // pre($ar_res); $imageUrl = ""; if ($ar_res["PROPERTIES"]["MORE_PHOTO"]["VALUE"][0]) $imageUrl = CFile::GetPath($ar_res["PROPERTIES"]["MORE_PHOTO"]["VALUE"][0]); if ($ar_res["PREVIEW_PICTURE"]) $imageUrl = CFile::GetPath($ar_res["PREVIEW_PICTURE"]); if ($ar_res["DETAIL_PICTURE"]) $imageUrl = CFile::GetPath($ar_res["DETAIL_PICTURE"]); if($imageUrl != "" && $ar_res["PRICES"][1]["PRICE"] > 0 && $ar_res["NAME"]){ if($ar_res["ID"]!= ""){ $products [] = array( "ID"=>$ar_res["ID"], "NAME"=>$ar_res["NAME"], "LINK"=>$ar_res["DETAIL_PAGE_URL"], "IMG"=>$imageUrl, "PRICE"=>$ar_res["PRICES"][1]["PRICE"] ); } } } pre($categories); ?> <div class="col-lg-9 search-fild remove-padding" id="mobile-search-reload"> <? $count = 0; foreach ($products as $product):$count++;?> <?if($count > 7) break;?> <div class="col-lg-12 col-12 result-fild"> <div class="row ign-right-margin d-flex align-items-center"> <div class="col-md-8 col-7 ign-left-padding"> <p class="remove-margin ign-left-padding result-product"><a href="<?=$product["LINK"]?>" class="link-product"><?=$product["NAME"]?></a></p> </div> <div class="col-md-3 col-4 text-right text-md-left"> <p class="remove-margin "><?=$product["PRICE"]?> грн.</p> </div> <div class="col-md-1 col-1 text-right ign-rightt-padding "> <img src="/local/templates/new-main/images/stock-value-yes.png" class="p-img-inline"> </div> </div> </div> <?endforeach;?> <?foreach ($categories as $category):?> <div class="col-12 result-fild"> <div class="row ign-right-margin d-flex align-items-center"> <div class="col-10 ign-left-padding"> <p class="remove-margin link-category"><a href="<?=$category["LINK"]?>"><?=$category["NAME"]?></a></p> </div> <div class="col-2 chng-padding chng-right"> <img class="arrow-small" src="/local/templates/new-main/images/category/arrow.png"> </div> </div> </div> <?endforeach;?> <div class="col-12 result-fild"> <p class="remove-margin result-product"><a href="<?="/search/?&q=".$quote?>" class="link-product">Все результаты ></a></p> </div> </div> <div id="desc-search-reload"> <div class="col-lg-12 result-fild"> <?foreach ($products as $product):?> <div class="row ign-right-margin d-flex align-items-center"> <div class="col-md-1 ign-left-padding d-none d-md-block"> <div class="preview d-flex align-items-center"> <img style="max-width: 50px;max-height: 28px" src="<?=$product["IMG"]?>"> </div> </div> <div class="col-md-6 col-7 ign-left-padding"> <p class="remove-margin size-font-result"><a href="<?=$product["LINK"]?>" class="link-product result-product"><?=$product["NAME"]?></a></p> </div> <div class="col-md-2 col-sm-4 col-4 text-right text-md-left"> <p class="remove-margin size-font-result"><?=$product["PRICE"]?> грн.</p> </div> <div class="col-md-1 col-1 text-right ign-rightt-padding "> <img src="/local/templates/new-main/images/stock-value-yes.png" class="p-img-inline"> </div> <div class="col-md-2 ign-rightt-padding stock-padding d-none d-md-block"> <p class="p-img-inline size-font-result on-stock">Есть в наличии</p> </div> </div> <?endforeach;?> </div> <?foreach ($categories as $category):?> <div class="col-12 result-fild"> <div class="row ign-right-margin d-flex align-items-center"> <div class="col-10 ign-left-padding"> <p class="remove-margin size-font-result link-category"><a href="<?=$category["LINK"]?>"><?=$category["NAME"]?></a> </p> </div> <div class="col-2 chng-padding chng-right"> <img class="arrow-small" src="/local/templates/new-main/images/category/arrow.png"> </div> </div> </div> <?endforeach;?> <div class="col-12 result-fild"> <p class="remove-margin size-font-result result-product"><a href="<?="/search/?&q=".$quote?>" class="link-product">Все результаты ></a> </p> </div> </div> <? require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php"); ?>