Your IP : 52.14.9.138
<?
$top_prod = array();
$prodIds = array();
$products = array();
$secIds = array();
$arSelect = Array("ID", "IBLOCK_ID","PROPERTY_PRODUCTS");//IBLOCK_ID и ID обязательно должны быть указаны, см. описание arSelectFields выше
$arFilter = Array("IBLOCK_ID"=>IntVal(113), "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array("shows"=>"DESC"), $arFilter, false, Array(), $arSelect);
while($ob = $res->GetNextElement()){
$aElementP = $ob->GetProperties();
$prodIds = array_unique(array_merge($aElementP["PRODUCTS"]["VALUE"],$prodIds), SORT_REGULAR);
}
foreach ($prodIds as $id){
$ar_res = CCatalogProduct::GetByIDEx($id);
// pre($ar_res);
if (!empty( $ar_res ) ){
$secName = "";
$imageUrl = "/src/images/products/product-1.jpg";
if(is_array($ar_res["PROPERTIES"]["MORE_PHOTO"]["VALUE"]))
$imageUrl = CFile::GetPath($ar_res["PROPERTIES"]["MORE_PHOTO"]["VALUE"][0]);
else
if($ar_res["PROPERTIES"]["MORE_PHOTO"]["VALUE"])
$imageUrl = CFile::GetPath($ar_res["PROPERTIES"]["MORE_PHOTO"]["VALUE"]);
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(empty($secIds[$ar_res["IBLOCK_SECTION_ID"]])){
$res1 = CIBlockSection::GetByID($ar_res["IBLOCK_SECTION_ID"]);
if($ar_res1 = $res1->GetNext()) {
$secName = $ar_res1['NAME'];
$secIds[$ar_res["IBLOCK_SECTION_ID"]]["NAME"] = $secName;
}
}else{
$secName = $secIds[$ar_res["IBLOCK_SECTION_ID"]]["NAME"];
}
$top_prod [$secName][] = array(
"ID" => $id,
"NAME" => $ar_res["NAME"],
"LINK" => $ar_res["DETAIL_PAGE_URL"],
"IMG" => $imageUrl,
"PRICE" => $ar_res["PRICES"]["1"]["PRICE"],
);
$top_prod [$secName]["NAME"] = $secName;
$top_prod [$secName]["ID"] = $ar_res["IBLOCK_SECTION_ID"];
}
}
//pre($secIds);
?>
<div class="container">
<div class="home-tab">
<div class="tab-title text-left">
<h2>ТОП ПРОДАЖ</h2>
<ul class="nav home-nav-tabs home-product-tabs">
<?$first = true;
foreach ($top_prod as $sec):?>
<li <?=$first?"class=\"active\"":""?>><a href="#sec_<?=$sec["ID"]?>" data-toggle="tab" aria-expanded="false"><?=$sec["NAME"]?></a></li>
<?$first = false; endforeach;?>
</ul>
</div>
<div id="productTabContent" class="tab-content">
<?
$first = true;
foreach ($top_prod as $sec):?>
<div class="tab-pane <?=$first?"active in":""?>" id="sec_<?=$sec["ID"]?>">
<div class="featured-pro">
<div class="slider-items-products">
<div id="computer-slider" class="product-flexslider hidden-buttons">
<div class="slider-items slider-width-col4">
<?foreach ($sec as $prod): if(!is_array($prod)) continue;?>
<div class="product-item">
<div class="item-inner">
<div class="product-thumbnail">
<!-- <div class="icon-new-label new-left">Новинка</div>-->
<div class="pr-img-area"> <a title="Product title here" href="<?=$prod["LINK"]?>">
<figure> <img width="265" height="198" class="first-img" src="<?=$prod["IMG"]?>" alt="HTML template"> <img width="265" height="198" class="hover-img" src="<?=$prod["IMG"]?>" alt="HTML template"></figure>
</a> </div>
<div class="pr-info-area">
<div class="pr-button">
<div class="mt-button add_to_wishlist"> <a onclick="addToFavorites(<?= $item['ID'] ?>);"> <i class="fa fa-heart-o"></i> </a> </div>
<div class="mt-button add_to_compare"> <a onclick="addToCompare(<?= $item['ID'] ?>);"> <i class="fa fa-link"></i> </a> </div>
<div class="mt-button quick-view"> <a href="quick_view.html"> <i class="fa fa-search"></i> </a> </div>
</div>
</div>
</div>
<div class="item-info">
<div class="info-inner">
<div class="item-title"> <a title="<?=$prod["NAME"]?>" href="<?=$prod["LINK"]?>"><?=$prod["NAME"]?></a> </div>
<div class="item-content">
<div class="item-price">
<div class="price-box"> <span class="regular-price"> <span class="price"><?=$prod["PRICE"]?> грн</span> </span> </div>
</div>
<div class="pro-action">
<button type="button" class="add-to-cart" onclick="buyProduct(<?=$prod["ID"]?>)"><span> Купить</span> </button>
</div>
</div>
</div>
</div>
</div>
</div>
<?endforeach;?>
</div>
</div>
</div>
</div>
</div>
<?$first = false; endforeach;?>
</div>
</div>
</div>