if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die(); if(!CModule::IncludeModule("iblock")) return; $sectName = ''; $sectUrl = ''; $arResult['item'] = null; $arResult['sims'] = []; $rows = CIBlockElement::GetList(['SORT' => 'ASC'], ['IBLOCK_ID'=>$arParams['IBLOCK_ID'], 'CODE'=>$arParams['ELEMENT_CODE'], 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y'], false, false, array('*', 'CATALOG_GROUP_1', 'CATALOG_AVAILABLE', 'IBLOCK_SECTION_ID', 'ZAKAZNAYA_PRODKUTSIYA_DLYA_SAYTA')); if($ob = $rows->GetNextElement()) { $row = $ob->GetFields(); $props = $ob->GetProperties(); global $USER; $item = []; $item['id'] = $row['ID']; $item['name'] = $row['NAME']; $item['podzakaz'] = $props['ZAKAZNAYA_PRODKUTSIYA_DLYA_SAYTA']['VALUE']; $item['quality'] = trim(preg_replace('/([А-Я]+)/u', ' $1', Order::GetQuality($row['XML_ID']))); if($_GET["DEV"] == "Y"){ echo "
";
var_dump($row['XML_ID']);
echo "";
}
$APPLICATION->SetTitle($item['name']);
$item['short'] = $row['PREVIEW_TEXT'];
$item['desc'] = $row['DETAIL_TEXT'];
$item['url'] = $row['DETAIL_PAGE_URL'];
$cfile = CFile::GetFileArray($row['DETAIL_PICTURE']);
$item['image'] = $cfile ? $cfile['SRC'] : '/local/images/no-image.png';
$item['is_image'] = (int)($cfile != null);
$item['qty'] = $row['CATALOG_QUANTITY'];
$item['how'] = ($item['qty'] > 4) ? 'Много' : 'Мало';
$item['available'] = $row['CATALOG_AVAILABLE'] == 'Y';
$item['sku'] = $props['CML2_ARTICLE']['VALUE'];
$item['used_with'] = $props['DLYA_KAKOGO_KONKRETNO_OBORUDOVANIYA']['VALUE'];
$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'] : 'шт';
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['images'] = [];
$sectRow = CIBlockSection::GetList(['SORT' => 'ASC'], ['IBLOCK_ID'=>$arParams['IBLOCK_ID'], 'ID' => $row['IBLOCK_SECTION_ID']], false)->GetNext();
if($sectRow)
{
$sectName = $sectRow['NAME'];
$sectUrl = $sectRow['SECTION_PAGE_URL'];
}
if($props['MORE_PHOTO']['VALUE'] && count($props['MORE_PHOTO']['VALUE']))
foreach($props['MORE_PHOTO']['VALUE'] as $p)
{
$cfile = CFile::GetFileArray($p);
if($cfile)
$item['images'][] = $cfile['SRC'];
}
$price = CPrice::GetBasePrice($item['id'])['PRICE'];
$item['price'] = number_format($price, 0, '.', ' ');
$arResult['item'] = $item;
$sRows = CIBlockElement::GetList(['SORT' => 'ASC'], ['IBLOCK_ID'=>$arParams['IBLOCK_ID'], '!ID' => $item['id'], 'SECTION_ID'=>$row['IBLOCK_SECTION_ID'], 'ACTIVE' => 'Y', 'GLOBAL_ACTIVE' => 'Y'], false, Array("nPageSize"=> 6));
while($sRow = $sRows->GetNextElement())
{
$row = $sRow->GetFields();
$props = $sRow->GetProperties();
if(!Order::IsQuality($row["XML_ID"]))
continue;
$sim = [];
$sim['id'] = $row["ID"];
$sim['name'] = $row['NAME'];
$sim['url'] = $row['DETAIL_PAGE_URL'];
$cfile = CFile::GetFileArray($row['PREVIEW_PICTURE']);
$sim['image'] = $cfile ? $cfile['SRC'] : '/local/images/no-image.png';
$cfile = CFile::GetFileArray($row['DETAIL_PICTURE']);
$sim['imaged'] = $cfile ? $cfile['SRC'] : '/local/images/no-image.png';
$price = CPrice::GetBasePrice($sim['id'])['PRICE'];
$sim['price'] = number_format($price, 0, '.', ' ');
if($props['STATUS']['VALUE'] && count($props['STATUS']['VALUE']))
foreach($props['STATUS']['VALUE'] as $s)
{
if($sim['status'])
$sim['status'] .= ', ' . $s;
else
$sim['status'] .= $s;
}
$arResult['sims'][] = $sim;
}
}
// if($sectName)
// $APPLICATION->AddChainItem($sectName, $sectUrl);
// $APPLICATION->AddChainItem($item["name"]);
$APPLICATION->AddChainItem($sectName, $sectUrl);
$elementGroups = CIBlockElement::GetElementGroups($item['id'], true);
while($eGroups = $elementGroups->Fetch())
{
$navChainArr[] = $eGroups;
}
$navChain = CIBlockSection::GetNavChain($navChainArr[array_key_last($navChainArr)]["IBLOCK_ID"], $navChainArr[array_key_last($navChainArr)]["ID"], array(), false);
while ($arNav = $navChain->GetNext()){
$APPLICATION->AddChainItem($arNav["NAME"], $arNav["SECTION_PAGE_URL"]);
}
// foreach ($navChainArr as $arNav2){
// $APPLICATION->AddChainItem($arNav2["NAME"], "/catalog/" . $arNav2["CODE"] . "/");
// }
if(!$arResult['item'] || ($arResult['item']['quality'] == 'Не Годен'))
LocalRedirect("/404.php", "404 Not Found");
$arResult['inCart'] = 0;
if(CModule::IncludeModule("sale"))
{
$rows = CSaleBasket::GetList(array(), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "PRODUCT_PROVIDER_CLASS"));
while($row = $rows->Fetch())
{
if($row['PRODUCT_ID'] == $item['id'])
$arResult['inCart'] = 1;
}
}
$this->IncludeComponentTemplate();