A
A
Anton2018-05-12 09:52:34
1C-Bitrix
Anton, 2018-05-12 09:52:34

How to correctly write a query to get the property of the bound element?

Given:
IB element
Elements of the same IB are attached to it - with the help of CIBlockElement::GetList I get ID-nicks
Having received the ID-s of the elements bound to it for the initial element, I need to get the ID-s of the elements already bound to them from the second IB.
I don't understand how to do it.
To make it clearer, an example:
There is a product. Similar models should be shown on the product page. In general, all products have a color. Colors are stored in a separate infoblock.
The task on the product page is to get the IDs of similar models and, on the contrary, display the IDs of the colors
It seems that everything is simple, but I got confused already (

<? require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');?>
<!-- Функции -->
<?
if (CModule::IncludeModule("iblock")):
$iblock_id = 66;
$my_slider = CIBlockElement::GetList (
Array("NAME" => "ASC"),
Array('ACTIVE' => 'Y', "IBLOCK_ID" => $iblock_id, "ID"  => #вставляем ID текущего элемента
PROPERTY_OTHER_COLORS,
),
false,
false,
Array(
'ID',
'NAME',
'PROPERTY_OTHER_COLORS'
)
);
while($ar_fields = $my_slider->GetNext())
{echo $ar_fields['NAME'];echo ' - ';echo $ar_fields['PROPERTY_OTHER_COLORS_VALUE'];
//получаем название и ID-шники схожих товаров
}
foreach(array_unique($serialValues) as $value){
//echo "$value";

}
endif;?>
//ниже бестолковый код, можно без него, видимо
<?
if (CModule::IncludeModule("iblock")):
 
  $my_elements = CIBlockElement::GetList (
    Array("ID" => "ASC"),
    Array("IBLOCK_ID" => 75, "ID" =>  #вставив ID цвета получим его название),
    false,
    false,
    Array('ID', 'NAME', 'PREVIEW_PICTURE')
  );
 
  while($ar_fields = $my_elements->GetNext())
  {
 $IMGID = $ar_fields['ID'];
 $URLCV = $ar_fields['NAME'];
 $URL = CFile::GetPath($ar_fields['PREVIEW_PICTURE']);
echo  $URLCV; 
  }

endif;
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasya, 2018-05-12
@haramba

A slightly different code, but the essence is the same,
in this case, IB products - IB manufacturers - IB colors

CModule::IncludeModule("iblock");

  $res = CIBlockElement::GetList(
    Array("NAME" => "ASC"), 
    Array("IBLOCK_ID"	 => 8, "ID" => 5346), 
    false, 
    false, 
    Array(
      'ID',
      'NAME',
      'PROPERTY_MANUFACTURER.PROPERTY_TESTLINK',
    )
  );
  while ($item = $res->GetNext())
  {
    echo '<pre>';
    print_r($item);
    echo '</pre>';
  }

Thanks for the question, at the same time I remembered better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question