<?
if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED!==true) die();
if (!$arResult['MODULES']['catalog'])
return;
$arDefaultParams = array(
'LABEL_PROP' => '-',
'OFFER_ADD_PICT_PROP' => '-',
'OFFER_TREE_PROPS' => array('-'),
'PRODUCT_SUBSCRIPTION' => 'N',
'SHOW_DISCOUNT_PERCENT' => 'N',
'SHOW_OLD_PRICE' => 'N',
'SHOW_MAX_QUANTITY' => 'N',
'DISPLAY_COMPARE' => 'N',
'MESS_BTN_BUY' => '',
'MESS_BTN_ADD_TO_BASKET' => '',
'MESS_BTN_SUBSCRIBE' => '',
'MESS_BTN_COMPARE' => '',
'MESS_NOT_AVAILABLE' => '',
'USE_VOTE_RATING' => 'N',
'VOTE_DISPLAY_AS_RATING' => 'rating',
'USE_COMMENTS' => 'N',
'BLOG_USE' => 'N',
'VK_USE' => 'N',
'FB_USE' => 'N',
);
$arParams = array_merge($arDefaultParams, $arParams);
if ('Y' != $arParams['PRODUCT_DISPLAY_MODE'])
$arParams['PRODUCT_DISPLAY_MODE'] = 'N';
$arParams['LABEL_PROP'] = trim($arParams['LABEL_PROP']);
if ('-' == $arParams['LABEL_PROP'])
$arParams['LABEL_PROP'] = '';
$arParams['OFFER_ADD_PICT_PROP'] = trim($arParams['OFFER_ADD_PICT_PROP']);
if ('-' == $arParams['OFFER_ADD_PICT_PROP'])
$arParams['OFFER_ADD_PICT_PROP'] = '';
if (!is_array($arParams['OFFER_TREE_PROPS']))
$arParams['OFFER_TREE_PROPS'] = array($arParams['OFFER_TREE_PROPS']);
foreach ($arParams['OFFER_TREE_PROPS'] as $key => $value)
{
$value = (string)$value;
if ('' == $value || '-' == $value)
unset($arParams['OFFER_TREE_PROPS'][$key]);
}
if (empty($arParams['OFFER_TREE_PROPS']) && isset($arParams['OFFERS_CART_PROPERTIES']) && is_array($arParams['OFFERS_CART_PROPERTIES']))
{
$arParams['OFFER_TREE_PROPS'] = $arParams['OFFERS_CART_PROPERTIES'];
foreach ($arParams['OFFER_TREE_PROPS'] as $key => $value)
{
$value = (string)$value;
if ('' == $value || '-' == $value)
unset($arParams['OFFER_TREE_PROPS'][$key]);
}
}
if ('Y' != $arParams['PRODUCT_SUBSCRIPTION'])
$arParams['PRODUCT_SUBSCRIPTION'] = 'N';
if ('Y' != $arParams['SHOW_DISCOUNT_PERCENT'])
$arParams['SHOW_DISCOUNT_PERCENT'] = 'N';
if ('Y' != $arParams['SHOW_OLD_PRICE'])
$arParams['SHOW_OLD_PRICE'] = 'N';
if ('Y' != $arParams['SHOW_MAX_QUANTITY'])
$arParams['SHOW_MAX_QUANTITY'] = 'N';
if ('Y' != $arParams['DISPLAY_COMPARE'])
$arParams['DISPLAY_COMPARE'] = 'N';
$arParams['DISPLAY_COMPARE'] = 'N';
$arParams['MESS_BTN_BUY'] = trim($arParams['MESS_BTN_BUY']);
$arParams['MESS_BTN_ADD_TO_BASKET'] = trim($arParams['MESS_BTN_ADD_TO_BASKET']);
$arParams['MESS_BTN_SUBSCRIBE'] = trim($arParams['MESS_BTN_SUBSCRIBE']);
$arParams['MESS_BTN_COMPARE'] = trim($arParams['MESS_BTN_COMPARE']);
$arParams['MESS_NOT_AVAILABLE'] = trim($arParams['MESS_NOT_AVAILABLE']);
if ('Y' != $arParams['USE_VOTE_RATING'])
$arParams['USE_VOTE_RATING'] = 'N';
if ('vote_avg' != $arParams['VOTE_DISPLAY_AS_RATING'])
$arParams['VOTE_DISPLAY_AS_RATING'] = 'rating';
if ('Y' != $arParams['USE_COMMENTS'])
$arParams['USE_COMMENTS'] = 'N';
if ('Y' != $arParams['BLOG_USE'])
$arParams['BLOG_USE'] = 'N';
if ('Y' != $arParams['VK_USE'])
$arParams['VK_USE'] = 'N';
if ('Y' != $arParams['FB_USE'])
$arParams['FB_USE'] = 'N';
if ('Y' == $arParams['USE_COMMENTS'])
{
if ('N' == $arParams['BLOG_USE'] && 'N' == $arParams['VK_USE'] && 'N' == $arParams['FB_USE'])
$arParams['USE_COMMENTS'] = 'N';
}
$arEmptyPreview = false;
$strEmptyPreview = $this->GetFolder().'/images/no_photo.png';
if (file_exists($_SERVER['DOCUMENT_ROOT'].$strEmptyPreview))
{
$arSizes = getimagesize($_SERVER['DOCUMENT_ROOT'].$strEmptyPreview);
if (!empty($arSizes))
{
$arEmptyPreview = array(
'SRC' => $strEmptyPreview,
'WIDTH' => intval($arSizes[0]),
'HEIGHT' => intval($arSizes[1])
);
}
unset($arSizes);
}
unset($strEmptyPreview);
$arSKUPropList = array();
$arSKUPropIDs = array();
$arSKUPropKeys = array();
$boolSKU = false;
$strBaseCurrency = '';
$boolConvert = isset($arResult['CONVERT_CURRENCY']['CURRENCY_ID']);
if ($arResult['MODULES']['catalog'])
{
if (!$boolConvert)
$strBaseCurrency = CCurrency::GetBaseCurrency();
$arSKU = CCatalogSKU::GetInfoByProductIBlock($arParams['IBLOCK_ID']);
$boolSKU = !empty($arSKU) && is_array($arSKU);
if ($boolSKU && !empty($arParams['OFFER_TREE_PROPS']))
{
$rsProps = CIBlockProperty::GetList(
array('SORT' => 'ASC', 'ID' => 'ASC'),
array('IBLOCK_ID' => $arSKU['IBLOCK_ID'], 'ACTIVE' => 'Y')
);
while ($arProp = $rsProps->Fetch())
{
$arProp['ID'] = intval($arProp['ID']);
if ($arProp['ID'] == $arSKU['SKU_PROPERTY_ID'])
continue;
if ('' == $arProp['CODE'])
$arProp['CODE'] = $arProp['ID'];
if (!in_array($arProp['CODE'], $arParams['OFFER_TREE_PROPS']))
continue;
if ('Y' == $arProp['MULTIPLE'])
continue;
$arProp['USER_TYPE'] = (string)$arProp['USER_TYPE'];
if ('L' != $arProp['PROPERTY_TYPE'] && 'E' != $arProp['PROPERTY_TYPE'] && !('S' == $arProp['PROPERTY_TYPE'] && 'directory' == $arProp['USER_TYPE']))
continue;
if ('S' == $arProp['PROPERTY_TYPE'] && 'directory' == $arProp['USER_TYPE'])
{
if (!isset($arProp['USER_TYPE_SETTINGS']['TABLE_NAME']) || empty($arProp['USER_TYPE_SETTINGS']['TABLE_NAME']))
continue;
if (!CModule::IncludeModule('highloadblock'))
continue;
}
$arOneSKU = array(
'ID' => intval($arProp['ID']),
'CODE' => $arProp['CODE'],
'NAME' => $arProp['NAME'],
'SORT' => intval($arProp['SORT']),
'PROPERTY_TYPE' => $arProp['PROPERTY_TYPE'],
'USER_TYPE' => $arProp['USER_TYPE'],
'LINK_IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'],
'USER_TYPE_SETTINGS' => $arProp['USER_TYPE_SETTINGS'],
'VALUES' => array()
);
$arSKUPropList[] = $arOneSKU;
$arSKUPropIDs[] = $arOneSKU['CODE'];
}
}
}
$arResult['SHOW_SLIDER'] = false;
$arResult['CHECK_QUANTITY'] = false;
if (!isset($arResult['CATALOG_MEASURE_RATIO']))
$arResult['CATALOG_MEASURE_RATIO'] = 1;
if (!isset($arResult['CATALOG_QUANTITY']))
$arResult['CATALOG_QUANTITY'] = 0;
$arResult['CATALOG_QUANTITY'] = (
0 < $arResult['CATALOG_QUANTITY'] && is_float($arResult['CATALOG_MEASURE_RATIO'])
? floatval($arResult['CATALOG_QUANTITY'])
: intval($arResult['CATALOG_QUANTITY'])
);
$arResult['CATALOG'] = false;
$arResult['LABEL'] = false;
if (!isset($arResult['CATALOG_SUBSCRIPTION']) || 'Y' != $arResult['CATALOG_SUBSCRIPTION'])
$arResult['CATALOG_SUBSCRIPTION'] = 'N';
if ('' != $arParams['LABEL_PROP'] && isset($arResult['DISPLAY_PROPERTIES'][$arParams['LABEL_PROP']]))
{
$arResult['LABEL'] = true;
$arProp = $arResult['DISPLAY_PROPERTIES'][$arParams['LABEL_PROP']];
if ('N' == $arProp['MULTIPLE'] && 'L' == $arProp['PROPERTY_TYPE'] && 'C' == $arProp['LIST_TYPE'])
{
$arResult['LABEL_VALUE'] = $arProp['NAME'];
}
else
{
$arResult['LABEL_VALUE'] = (is_array($arProp['DISPLAY_VALUE'])
? implode(' / ', $arProp['DISPLAY_VALUE'])
: $arProp['DISPLAY_VALUE']
);
}
unset($arResult['DISPLAY_PROPERTIES'][$arParams['LABEL_PROP']]);
}
if ($arResult['MODULES']['catalog'])
{
$arResult['CATALOG'] = true;
if (!isset($arResult['CATALOG_TYPE']))
$arResult['CATALOG_TYPE'] = CCatalogProduct::TYPE_PRODUCT;
if (
(CCatalogProduct::TYPE_PRODUCT == $arResult['CATALOG_TYPE'] || CCatalogProduct::TYPE_SKU == $arResult['CATALOG_TYPE'])
&& !empty($arResult['OFFERS'])
)
{
$arResult['CATALOG_TYPE'] = CCatalogProduct::TYPE_SKU;
}
switch ($arResult['CATALOG_TYPE'])
{
case CCatalogProduct::TYPE_SET:
$arResult['OFFERS'] = array();
$arResult['CATALOG_MEASURE_RATIO'] = 1;
$arResult['CATALOG_QUANTITY'] = 0;
$arResult['CHECK_QUANTITY'] = false;
break;
case CCatalogProduct::TYPE_SKU:
break;
case CCatalogProduct::TYPE_PRODUCT:
default:
$arResult['CHECK_QUANTITY'] = ('Y' == $arResult['CATALOG_QUANTITY_TRACE'] && 'N' == $arResult['CATALOG_CAN_BUY_ZERO']);
break;
}
}
else
{
$arResult['CATALOG_TYPE'] = 0;
$arResult['OFFERS'] = array();
}
if ($arResult['CATALOG'] && isset($arResult['OFFERS']) && !empty($arResult['OFFERS']))
{
$boolSKUDisplayProps = false;
$arResultSKUPropIDs = array();
foreach ($arResult['OFFERS'] as &$arOffer)
{
foreach ($arSKUPropIDs as &$strOneCode)
{
if (isset($arOffer['DISPLAY_PROPERTIES'][$strOneCode]))
$arResultSKUPropIDs[$strOneCode] = true;
}
unset($strOneCode);
}
unset($arOffer);
$arSKUPropIDs = array();
$arFilterProp = array();
foreach ($arSKUPropList as $arOneSKU)
{
if (!isset($arResultSKUPropIDs[$arOneSKU['CODE']]))
continue;
if ('L' == $arOneSKU['PROPERTY_TYPE'])
{
$arOneSKU['SHOW_MODE'] = 'LIST';
$arValues = array();
$rsPropEnums = CIBlockProperty::GetPropertyEnum($arOneSKU['ID']);
while ($arEnum = $rsPropEnums->Fetch())
{
$arEnum['ID'] = intval($arEnum['ID']);
$arValues[$arEnum['ID']] = array(
'ID' => $arEnum['ID'],
'NAME' => $arEnum['VALUE'],
'SORT' => intval($arEnum['SORT']),
'PICT' => false
);
}
$arValues[0] = array(
'ID' => 0,
'SORT' => PHP_INT_MAX,
'NA' => true,
'NAME' => '-',
'PICT' => false
);
$arOneSKU['VALUES'] = $arValues;
$arOneSKU['VALUES_COUNT'] = count($arValues);
}
elseif ('E' == $arOneSKU['PROPERTY_TYPE'])
{
$arOneSKU['SHOW_MODE'] = 'PICT';
$arValues = array();
$rsPropEnums = CIBlockElement::GetList(
array('SORT' => 'ASC'),
array('IBLOCK_ID' => $arOneSKU['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'),
false,
false,
array('ID', 'NAME', 'PREVIEW_PICTURE')
);
while ($arEnum = $rsPropEnums->Fetch())
{
$arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['PREVIEW_PICTURE']);
if (!is_array($arEnum['PREVIEW_PICTURE']))
continue;
$arEnum['ID'] = intval($arEnum['ID']);
$arValues[$arEnum['ID']] = array(
'ID' => $arEnum['ID'],
'NAME' => $arEnum['NAME'],
'SORT' => intval($arEnum['SORT']),
'PICT' => array(
'SRC' => $arEnum['PREVIEW_PICTURE']['SRC'],
'WIDTH' => intval($arEnum['PREVIEW_PICTURE']['WIDTH']),
'HEIGHT' => intval($arEnum['PREVIEW_PICTURE']['HEIGHT'])
)
);
}
$arValues[0] = array(
'ID' => 0,
'SORT' => PHP_INT_MAX,
'NA' => true,
'NAME' => '',
'PICT' => $arEmptyPreview
);
$arOneSKU['VALUES'] = $arValues;
$arOneSKU['VALUES_COUNT'] = count($arValues);
}
else
{
$hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array('TABLE_NAME' => $arOneSKU['USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch();
if (!isset($hlblock['ID']))
continue;
$arValues = array();
$arXmlMap = array();
$boolName = true;
$boolPict = true;
$entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
$entity_data_class = $entity->getDataClass();
$rsPropEnums = $entity_data_class::getList(array());
while ($arEnum = $rsPropEnums->fetch())
{
if (!isset($arEnum['UF_NAME']))
{
$boolName = false;
break;
}
$arEnum['PREVIEW_PICTURE'] = false;
if (!isset($arEnum['UF_FILE']))
$boolPict = false;
if ($boolPict)
$arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['UF_FILE']);
$arEnum['ID'] = intval($arEnum['ID']);
$arValues[$arEnum['ID']] = array(
'ID' => $arEnum['ID'],
'NAME' => $arEnum['UF_NAME'],
'SORT' => intval($arEnum['UF_SORT']),
'XML_ID' => $arEnum['UF_XML_ID'],
'PICT' => ($boolPict ?
array(
'SRC' => $arEnum['PREVIEW_PICTURE']['SRC'],
'WIDTH' => intval($arEnum['PREVIEW_PICTURE']['WIDTH']),
'HEIGHT' => intval($arEnum['PREVIEW_PICTURE']['HEIGHT'])
)
: false
)
);
$arXmlMap[$arEnum['UF_XML_ID']] = $arEnum['ID'];
}
$arValues[0] = array(
'ID' => 0,
'SORT' => PHP_INT_MAX,
'NA' => true,
'NAME' => ($boolPict ? '' : '-'),
'XML_ID' => '',
'PICT' => ($boolPict ? $arEmptyPreview : false)
);
if (!$boolName)
continue;
$arOneSKU['VALUES'] = $arValues;
$arOneSKU['VALUES_COUNT'] = count($arValues);
$arOneSKU['PROPERTY_TYPE'] = ($boolPict ? 'E' : 'L');
$arOneSKU['XML_MAP'] = $arXmlMap;
}
$arFilterProp[] = $arOneSKU;
$arSKUPropIDs[] = $arOneSKU['CODE'];
$arSKUPropKeys[$arOneSKU['CODE']] = false;
}
$arSKUPropList = $arFilterProp;
unset($arFilterProp);
$arMatrixFields = $arSKUPropKeys;
$arMatrix = array();
$arNewOffers = array();
$arIDS = array();
$arOfferSet = array();
$arResult['OFFER_GROUP'] = false;
foreach ($arResult['OFFERS'] as $keyOffer => $arOffer)
{
$arOffer['ID'] = intval($arOffer['ID']);
$arIDS[] = $arOffer['ID'];
$arResult['OFFERS_PROP'] = false;
$boolSKUDisplayProperties = false;
$arOffer['OFFER_GROUP'] = false;
$arRow = array();
foreach ($arSKUPropIDs as $propkey => $strOneCode)
{
$arCell = array(
'VALUE' => 0,
'SORT' => PHP_INT_MAX,
'NA' => true
);
if (isset($arOffer['DISPLAY_PROPERTIES'][$strOneCode]))
{
$arMatrixFields[$strOneCode] = true;
$arCell['NA'] = false;
if ('directory' == $arSKUPropList[$propkey]['USER_TYPE'])
{
$intValue = $arSKUPropList[$propkey]['XML_MAP'][$arOffer['DISPLAY_PROPERTIES'][$strOneCode]['VALUE']];
$arCell['VALUE'] = $intValue;
}
elseif ('L' == $arSKUPropList[$propkey]['PROPERTY_TYPE'])
{
$arCell['VALUE'] = intval($arOffer['DISPLAY_PROPERTIES'][$strOneCode]['VALUE_ENUM_ID']);
}
elseif ('E' == $arSKUPropList[$propkey]['PROPERTY_TYPE'])
{
$arCell['VALUE'] = intval($arOffer['DISPLAY_PROPERTIES'][$strOneCode]['VALUE']);
}
$arCell['SORT'] = $arSKUPropList[$propkey]['VALUES'][$arCell['VALUE']]['SORT'];
}
$arRow[$strOneCode] = $arCell;
}
$arMatrix[$keyOffer] = $arRow;
$arOffer['CHECK_QUANTITY'] = ('Y' == $arOffer['CATALOG_QUANTITY_TRACE'] && 'N' == $arOffer['CATALOG_CAN_BUY_ZERO']);
if (!isset($arOffer['CATALOG_MEASURE_RATIO']))
$arOffer['CATALOG_MEASURE_RATIO'] = 1;
if (!isset($arOffer['CATALOG_QUANTITY']))
$arOffer['CATALOG_QUANTITY'] = 0;
$arOffer['CATALOG_QUANTITY'] = (
0 < $arOffer['CATALOG_QUANTITY'] && is_float($arOffer['CATALOG_MEASURE_RATIO'])
? floatval($arOffer['CATALOG_QUANTITY'])
: intval($arOffer['CATALOG_QUANTITY'])
);
$arOffer['CATALOG_TYPE'] = CCatalogProduct::TYPE_OFFER;
if (!empty($arOffer['PREVIEW_PICTURE']) && !is_array($arOffer['PREVIEW_PICTURE']))
$arOffer['PREVIEW_PICTURE'] = CFile::GetFileArray($arOffer['PREVIEW_PICTURE']);
if (!empty($arOffer['DETAIL_PICTURE']) && !is_array($arOffer['DETAIL_PICTURE']))
$arOffer['DETAIL_PICTURE'] = CFile::GetFileArray($arOffer['DETAIL_PICTURE']);
if (empty($arOffer['PREVIEW_PICTURE']) && !empty($arOffer['DETAIL_PICTURE']))
$arOffer['PREVIEW_PICTURE'] = $arOffer['DETAIL_PICTURE'];
$arOffer['MORE_PHOTO'] = array();
$arOffer['MORE_PHOTO_COUNT'] = 0;
if ('' != $arParams['OFFER_ADD_PICT_PROP'] && isset($arOffer['PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]))
{
if ('F' == $arOffer['PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]['PROPERTY_TYPE'])
{
if (
isset($arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]['FILE_VALUE'])
&& !empty($arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]['FILE_VALUE'])
)
{
$boolOnePict = isset($arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]['FILE_VALUE']['ID']);
if ($boolOnePict)
{
$arOneFileValue = $arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]['FILE_VALUE'];
$arPict = array(
'ID' => intval($arOneFileValue['ID']),
'SRC' => $arOneFileValue['SRC'],
'WIDTH' => intval($arOneFileValue['WIDTH']),
'HEIGHT' => intval($arOneFileValue['HEIGHT'])
);
$arOffer["MORE_PHOTO"][] = $arPict;
$arOffer['MORE_PHOTO_COUNT'] = 1;
if (empty($arOffer['PREVIEW_PICTURE']))
{
$arOffer['PREVIEW_PICTURE'] = $arPict;
}
if (empty($arOffer['DETAIL_PICTURE']))
{
$arOffer['DETAIL_PICTURE'] = $arPict;
}
}
else
{
$boolFirst = true;
foreach ($arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]['FILE_VALUE'] as $arOneFileValue)
{
$arPict = array(
'ID' => intval($arOneFileValue['ID']),
'SRC' => $arOneFileValue['SRC'],
'WIDTH' => intval($arOneFileValue['WIDTH']),
'HEIGHT' => intval($arOneFileValue['HEIGHT'])
);
$arOffer["MORE_PHOTO"][] = $arPict;
if ($boolFirst)
{
if (empty($arOffer['PREVIEW_PICTURE']))
{
$arOffer['PREVIEW_PICTURE'] = $arPict;
}
if (empty($arOffer['DETAIL_PICTURE']))
{
$arOffer['DETAIL_PICTURE'] = $arPict;
}
}
$boolFirst = false;
}
$arOffer['MORE_PHOTO_COUNT'] = count($arOffer["MORE_PHOTO"]);
}
}
else
{
$arPropValue = $arItem['PROPERTIES'][$arParams['ADD_PICT_PROP']]['VALUE'];
if (!is_array($arPropValue))
$arPropValue = array($arPropValue);
foreach ($arPropValue as &$strOneValue)
{
$arOneFileValue = CFile::GetFileArray($strOneValue);
if (!empty($arOneFileValue))
{
$arPict = array(
'ID' => intval($arOneFileValue['ID']),
'SRC' => $arOneFileValue['SRC'],
'WIDTH' => intval($arOneFileValue['WIDTH']),
'HEIGHT' => intval($arOneFileValue['HEIGHT'])
);
if (empty($arOffer['PREVIEW_PICTURE']))
{
$arOffer['PREVIEW_PICTURE'] = $arPict;
}
if (empty($arOffer['DETAIL_PICTURE']))
{
$arOffer['DETAIL_PICTURE'] = $arPict;
}
$arOffer["MORE_PHOTO"][] = $arPict;
}
}
if (isset($strOneValue))
unset($strOneValue);
$arOffer['MORE_PHOTO_COUNT'] = count($arOffer["MORE_PHOTO"]);
}
}
if (isset($arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]))
unset($arOffer['DISPLAY_PROPERTIES'][$arParams['OFFER_ADD_PICT_PROP']]);
}
if (0 < $arOffer['MORE_PHOTO_COUNT'])
$arResult['SHOW_SLIDER'] = true;
if (!empty($arParams['OFFER_TREE_PROPS']))
{
foreach ($arParams['OFFER_TREE_PROPS'] as &$strOneCode)
{
if (isset($arOffer['DISPLAY_PROPERTIES'][$strOneCode]))
unset($arOffer['DISPLAY_PROPERTIES'][$strOneCode]);
}
if (isset($strOneCode))
unset($strOneCode);
}
if (!empty($arOffer['DISPLAY_PROPERTIES']))
$boolSKUDisplayProps = true;
$arNewOffers[$keyOffer] = $arOffer;
}
$arResult['OFFERS'] = $arNewOffers;
$arResult['SHOW_OFFERS_PROPS'] = $boolSKUDisplayProps;
$arUsedFields = array();
$arSortFields = array();
foreach ($arSKUPropIDs as $propkey => $strOneCode)
{
$boolExist = $arMatrixFields[$strOneCode];
foreach ($arMatrix as $keyOffer => $arRow)
{
if ($boolExist)
{
if (!isset($arResult['OFFERS'][$keyOffer]['TREE']))
$arResult['OFFERS'][$keyOffer]['TREE'] = array();
$arResult['OFFERS'][$keyOffer]['TREE']['PROP_'.$arSKUPropList[$propkey]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
$arResult['OFFERS'][$keyOffer]['SKU_SORT_'.$strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
$arUsedFields[$strOneCode] = true;
$arSortFields['SKU_SORT_'.$strOneCode] = SORT_NUMERIC;
}
else
{
unset($arMatrix[$keyOffer][$strOneCode]);
}
}
}
$arResult['OFFERS_PROP'] = $arUsedFields;
\Bitrix\Main\Type\Collection::sortByColumn($arResult['OFFERS'], $arSortFields);
if (!empty($arIDS) && CBXFeatures::IsFeatureEnabled('CatCompleteSet'))
{
$rsSets = CCatalogProductSet::getList(
array(),
array(
'@OWNER_ID' => $arIDS,
'=SET_ID' => 0,
'=TYPE' => CCatalogProductSet::TYPE_GROUP
),
false,
false,
array('ID', 'OWNER_ID')
);
while ($arSet = $rsSets->Fetch())
{
$arOfferSet[$arSet['OWNER_ID']] = true;
$arResult['OFFER_GROUP'] = true;
}
}
$arMatrix = array();
$intSelected = -1;
$arResult['MIN_PRICE'] = false;
foreach ($arResult['OFFERS'] as $keyOffer => $arOffer)
{
if (empty($arResult['MIN_PRICE']) && $arOffer['CAN_BUY'])
{
$intSelected = $keyOffer;
$arResult['MIN_PRICE'] = $arOffer['MIN_PRICE'];
}
$arSKUProps = false;
if (!empty($arOffer['DISPLAY_PROPERTIES']))
{
$boolSKUDisplayProps = true;
$arSKUProps = array();
foreach ($arOffer['DISPLAY_PROPERTIES'] as &$arOneProp)
{
if ('F' == $arOneProp['PROPERTY_TYPE'])
continue;
$arSKUProps[] = array(
'NAME' => $arOneProp['NAME'],
'VALUE' => $arOneProp['DISPLAY_VALUE']
);
}
unset($arOneProp);
}
if (isset($arOfferSet[$arOffer['ID']]))
{
$arOffer['OFFER_GROUP'] = true;
$arResult['OFFERS'][$keyOffer]['OFFER_GROUP'] = true;
}
$arOneRow = array(
'ID' => $arOffer['ID'],
'NAME' => $arOffer['~NAME'],
'TREE' => $arOffer['TREE'],
'PRICE' => $arOffer['MIN_PRICE'],
'DISPLAY_PROPERTIES' => $arSKUProps,
'PREVIEW_PICTURE' => $arOffer['PREVIEW_PICTURE'],
'DETAIL_PICTURE' => $arOffer['DETAIL_PICTURE'],
'CHECK_QUANTITY' => $arOffer['CHECK_QUANTITY'],
'MAX_QUANTITY' => $arOffer['CATALOG_QUANTITY'],
'STEP_QUANTITY' => $arOffer['CATALOG_MEASURE_RATIO'],
'QUANTITY_FLOAT' => is_double($arOffer['CATALOG_MEASURE_RATIO']),
'MEASURE' => $arOffer['~CATALOG_MEASURE_NAME'],
'OFFER_GROUP' => $arOffer['OFFER_GROUP'],
'CAN_BUY' => $arOffer['CAN_BUY'],
'SLIDER' => $arOffer['MORE_PHOTO'],
'SLIDER_COUNT' => $arOffer['MORE_PHOTO_COUNT'],
'BUY_URL' => $arOffer['~BUY_URL']
);
$arMatrix[$keyOffer] = $arOneRow;
}
if (-1 == $intSelected)
$intSelected = 0;
$arResult['JS_OFFERS'] = $arMatrix;
$arResult['OFFERS_SELECTED'] = $intSelected;
$arResult['OFFERS_IBLOCK'] = $arSKU['IBLOCK_ID'];
}
if (!is_array($arResult['PREVIEW_PICTURE']))
$arResult['PREVIEW_PICTURE'] = $arResult['DETAIL_PICTURE'];
if (empty($arResult['PREVIEW_PICTURE']))
$arResult['PREVIEW_PICTURE'] = $arEmptyPreview;
if (!isset($arResult['OFFERS']) || empty($arResult['OFFERS']))
{
if (!empty($arResult["MORE_PHOTO"]))
{
$arResult['SHOW_SLIDER'] = true;
$arResult["MORE_PHOTO_COUNT"] = count($arResult["MORE_PHOTO"]);
}
}
if (!empty($arResult['DISPLAY_PROPERTIES']))
{
foreach ($arResult['DISPLAY_PROPERTIES'] as $propKey => $arDispProp)
{
if ('F' == $arDispProp['PROPERTY_TYPE'])
unset($arResult['DISPLAY_PROPERTIES'][$propKey]);
}
}
$arResult['SKU_PROPS'] = $arSKUPropList;
$IBLOCK_ID = 11;
$arSelect = Array("NAME");
$arFilter = Array("IBLOCK_ID"=>$IBLOCK_ID, array( "LOGIC" => "OR", "PROPERTY_GUSKA1"=>$arResult['NAME'], "PROPERTY_GUSKA2"=>$arResult['NAME'], "PROPERTY_GUSKA3"=>$arResult['NAME']));
$arResult['EXFOR'] = CIBlockElement::GetList(
Array("NANE"=>"asc"),
$arFilter,
false,
false,
$arSelect);
//это все дальше ко скидкам и ценам
$arResult['OUT_PRICE'] = $arResult['MIN_PRICE']['VALUE'];
$vdk_skl = array("А 1-1", "А 1-2", "А 1-3", "А 1-4", "А 1-5", "А 1-6", "А 2-1", "А 2-2", "А 2-3", "А 2-4", "А 2-5", "А 2-6",
"А 3-1", "А 3-2", "А 3-3", "А 3-4", "А 3-5", "А 3-6", "А 4-1", "А 4-2", "А 4-3", "А 4-4", "А 4-5", "А 4-6", "А 5-1", "А 5-2",
"А 5-3", "А 5-4", "А 5-5", "А 5-6", "А 6-1", "А 6-2", "А 6-3", "А 6-4", "А 6-5", "А 6-6", "АА 1-1", "АА 1-2", "АА 1-3", "АА 1-4",
"АА 1-5", "АА 1-6", "АА 1-7", "АА 2-1", "АА 2-2", "АА 2-3", "АА 2-4", "АА 2-5", "АА 2-6", "АА 2-7", "АА 3-1", "АА 3-2",
"АА 3-3", "АА 3-4", "АА 3-5", "АА 3-6", "АА 4-1", "АА 4-2", "АА 4-3", "АА 4-4", "АА 4-5", "АА 4-6", "АА 5-1", "АА 5-2", "АА 5-3",
"АА 5-4", "АА 5-5", "АА 5-6", "АА 6-1", "АА 6-2", "АА 6-3", "АА 6-4", "АА 6-5", "АА 6-6", "брак", "К 1-1", "К 1-2", "К 1-3",
"К 1-4", "К 1-5", "К 1-6", "К 2-1", "К 2-2", "К 2-3", "К 2-4", "К 2-5", "К 2-6", "К 3-1", "К 3-2", "К 3-3", "К 3-4", "К 3-5",
"К 3-6", "К 4-1", "К 4-2", "К 4-3", "К 4-4", "К 4-5", "К 4-6", "куча", "куча2", "ТОВАР:Участок 210(Торговая Точка)", "Товары в пути",
"У 1-1", "У 1-2", "У 1-3", "У 1-4", "У 10-1", "У 10-2", "У 10-3", "У 10-4", "У 2-1", "У 2-2", "У 2-3", "У 2-4", "У 3-1", "У 3-2",
"У 3-3", "У 3-4", "У 4-1", "У 4-2", "У 4-3", "У 4-4", "У 5-1", "У 5-2", "У 5-3", "У 5-4", "У 6-1", "У 6-2", "У 6-3", "У 6-4",
"У 7-1", "У 7-2", "У 7-3", "У 7-4", "У 8-1", "У 8-2", "У 8-3", "У 8-4", "У 9-1", "У 9-2", "У 9-3", "У 9-4", "УУ 1-1", "УУ 1-2",
"УУ 1-3", "УУ 1-4", "УУ 1-5", "УУ 1-6", "УУ 2-1", "УУ 2-2", "УУ 2-3", "УУ 2-4", "УУ 2-5", "УУ 2-6", "УУ 3-1", "УУ 3-2", "УУ 3-3",
"УУ 3-4", "УУ 3-5", "УУ 3-6", "УУ 4-1", "УУ 4-2", "УУ 4-3", "УУ 4-4", "УУ 4-5", "УУ 4-6", "УУ 5-1", "УУ 5-2", "УУ 5-3", "УУ 5-4",
"УУ 5-5", "УУ 5-6", "УУ 6-1", "УУ 6-2", "УУ 6-3", "УУ 6-4", "УУ 6-5", "УУ 6-6", "Товары в пути");
$msk_skl = array("Товары в пути ВЛ-МСК", "М 1-2", "М 1-3", "М 1-4", "М 1-5", "М 1-6", "М 2-1", "М 2-2", "М 2-3", "М 2-4", "М 2-5", "М 2-6", "М 3-1", "М 3-2", "М 3-3", "М 3-4", "М 3-5", "М 3-6", "М 4-1", "М 4-2", "М 4-3", "М 4-4", "М 4-5", "М 4-6", "М 5-1", "М 5-2", "М 5-3", "М 5-4", "М 5-5", "М 5-6", "М 6-1", "М 6-2", "М 6-3", "М 6-4", "М 6-5", "М 6-6", "М 7-1", "М 7-2", "М 7-3", "М 7-4", "М 7-5", "М 7-6", "М 8-1", "М 8-2", "М 8-3", "М 8-4", "М 8-5", "М 8-6", "М 9-1", "М 9-2", "М 9-3", "М 9-4", "М 9-5", "М 9-6", "М 10-1", "М 10-2", "М 10-3", "М 10-4", "М 10-5", "М 10-6", "М 11-1", "М 11-2", "М 11-3", "М 11-4", "М 11-5", "М 11-6", "М 12-1", "М 12-2", "М 12-3", "М 12-4", "М 12-5", "М 12-6", "М 13-1", "М 13-2", "М 13-3", "М 13-4", "М 13-5", "М 13-6", "М 14-1", "М 14-2", "М 14-3", "М 14-4", "М 14-5", "М 14-6", "М 15-1", "М 15-2", "М 15-3", "М 15-4", "М 15-5", "М 15-6", "М 16-1", "М 16-2", "М 16-3", "М 16-4", "М 16-5", "М 16-6", "М 17-1", "М 17-2", "М 17-3", "М 17-4", "М 17-5", "М 17-6", "М 18-1", "М 18-2", "М 18-3", "М 18-4", "М 18-5", "М 18-6", "МОСКВА");
/*echo $arResult['OUT_PRICE'];
echo $arResult['DISPLAY_PROPERTIES']['_1_SHIRINA']['VALUE'];*/
$arSelect = array(
"TITLE",
"PRODUCT_AMOUNT",
);
$ostatki = CCatalogStore::GetList(array('TITLE' => 'ASC', 'ID' => 'ASC'),
array('ACTIVE' => 'Y',
"PRODUCT_ID" => $arResult['ID'],
"ISSUING_CENTER" => 'Y'),
false,
false,
$arSelect);
$in_vdk = false;
$in_msk = false;
while($arProp = $ostatki->GetNext())
{
if ($arProp["PRODUCT_AMOUNT"] > 0)
{
if (in_array($arProp["TITLE"], $vdk_skl))
{
$in_vdk = true;
}
if (in_array($arProp["TITLE"], $msk_skl))
{
$in_msk = true;
}
}
}
// это мы выводим наличие на складах
if ($in_vdk == true)
{
$vdk_out = "<span style='color: #00A80D'>в наличии</span>";
}
else
{
$vdk_out = "под заказ";
}
if ($in_msk == true)
{
$msk_out = "<span style='color: #00A80D'>в наличии</span>";
}
else
{
$msk_out = "под заказ";
}
$arResult['IN_SKLAD'] = "";
if ($in_vdk == true || $in_msk == true) {
$arResult['IN_SKLAD'] = '<span style="color: #FA8C00; font-size: 16px; font-weight: bold;">Наличие на складах:</span><br>
<span style="color: #4E4E4E; font-size: 13px; font-weight: bold;">Во Владивостоке: '.$vdk_out.'</span><br>
<span style="color: #4E4E4E; font-size: 13px; font-weight: bold;">В Москве: '.$msk_out.'</span><br><br>';
}
?>