M
M
malayamarisha2020-05-20 06:52:18
1C-Bitrix
malayamarisha, 2020-05-20 06:52:18

How to display products with the same property value in the product card?

Good day!
It is necessary to display in the product card only those products whose property value matches the property value of the product itself. Tell me please.
Example:
1) there is a product "Product1", property "Collection", property type "Directory". The value of the property "Collection" = "Test collection"
2) there is a product "Product2", property "Collection", property type "Directory". The value of the property "Collection" = "Test collection"
3) there is a product "Product3", property "Collection", property type "Directory". The value of the property "Collection" = "Test collection"
It is necessary to display the goods "

$arSelect = Array("ID", "IBLOCK_ID", "NAME","PROPERTY_*");
$arFilter = Array("IBLOCK_ID"=>$arParams['IBLOCK_ID'], "ACTIVE"=>"Y", "PROPERTY_KOLLEKTSIYA"=>$arResult['DISPLAY_PROPERTIES']['KOLLEKTSIYA']['DISPLAY_VALUE']);
$res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, false, Array());
while($ar_fields = $res->Fetch())
{
  echo "<pre>" .print_r($arFields,1)."</pre>";
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smilingcheater, 2020-05-20
@smilingcheater

If you want to filter exactly by the text value of the list, you should use 'PROPERTY_KOLLEKTSIYA_VALUE' => ... in the filter,
but this will not be optimal in terms of query execution speed.
It is better to use search by value ID in the list. Look in the $arResult['DISPLAY_PROPERTIES']['KOLLEKTSIYA'] array in which property the ID of the list element is stored, unfortunately I don't remember which key to use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question