Answer the question
In order to leave comments, you need to log in
How to display properties of another element in a section through a UF box?
Hello.
There is a block "Bestsellers". Already output IMG, NAME and DETAIL_PAGE_URL, and buttons.
How can I display the "Number" and "String" properties - Price and Dimensions - from the infoblock elements? To the category.
<?
$rsResult = CIBlockSection::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => "27", 'ID' => $arResult["SECTION"]["ID"]), true, Array("UF_HITS"));
while ($arResult = $rsResult -> GetNext())
{
if (!empty($arResult["UF_HITS"]))
{
$iter = $arResult["UF_HITS"];
}
}
$arFilter = array('IBLOCK_ID' => 27,'ID' => $iter);
$rsItems = CIBlockElement::GetList(array(),$arFilter);
while ($arItem = $rsItems->GetNext())
{
if (!empty($iter))
{
$resizer = $arItem['PREVIEW_PICTURE'];
$file = CFile::ResizeImageGet($resizer, array('width'=>180, 'height'=>290), BX_RESIZE_IMAGE_PROPORTIONAL , true);
$img = $file['src'];
echo
'<div class="hits-smallcard">
<img src="'.$img.'" />
<p><a href="'.$arItem["DETAIL_PAGE_URL"].'">'.$arItem["NAME"].'</a></p>
<p><a href="#modal1" class="popup-content">Заказать</a></p>
<p><a href="'.$arItem["DETAIL_PAGE_URL"].'">Подробнее</a></p>
<p>'.$arItem["CASH"].'</p> //не выводит, число
<p>'.$arItem["ATT_PRICE"].'</p> //не выводит, строка
</div>';
}
}
?>
Answer the question
In order to leave comments, you need to log in
In order for the IB element to have property values in $arItem, they must be added to the arSelectFields parameter in CIblockElement::GetList
$rsItems = CIBlockElement::GetList(array(),$arFilter, false, false, ["*", "PROPERTY_CASH", "PROPERTY_ATT_PRICE"]);
<?
<?
$rsResult = CIBlockSection::GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => "27", 'ID' => $arResult["SECTION"]["ID"]), true, Array("UF_HITS"));
while ($arResult = $rsResult -> GetNext())
{
if (!empty($arResult["UF_HITS"]))
{
$iter = $arResult["UF_HITS"];
}
}
if (!empty($iter))
{
$arFilter = array('IBLOCK_ID' => 27,'ID' => $iter);
$rsItems = CIBlockElement::GetList(array(),$arFilter);
while ($arItem = $rsItems->GetNext())
{
$resizer = $arItem['PREVIEW_PICTURE'];
$file = CFile::ResizeImageGet($resizer, array('width'=>180, 'height'=>290), BX_RESIZE_IMAGE_PROPORTIONAL , true);
$img = $file['src'];
echo
'<div class="hits-smallcard">
<img src="'.$img.'" />
<p><a href="'.$arItem["DETAIL_PAGE_URL"].'">'.$arItem["NAME"].'</a></p>
<p><a href="#modal1" class="popup-content">Заказать</a></p>
<p><a href="'.$arItem["DETAIL_PAGE_URL"].'">Подробнее</a></p>
<p>'.$arItem["CASH"].'</p> //не выводит, число
<p>'.$arItem["ATT_PRICE"].'</p> //не выводит, строка
</div>';
}
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question