A
A
Anto2017-10-07 13:38:13
1C-Bitrix
Anto, 2017-10-07 13:38:13

How to compare two infoblocks and output values?

Good afternoon
Hint:
There are two infoblocks, one Product catalog and the second one is called Brands.
The first one stores goods from 1C, the second one has the brand name and logo.
The Catalog has the following property: Trademark with the symbolic code ATT_TRADEMARK
The Brands infoblock in the Name field has exactly the same name with Breds as in the Catalog in the Trademark property field
Example:
Trademark with the symbolic code ATT_TRADEMARK = RIEKER
and Brand name = RIEKER
Using CIBlockElement::GetList, I try to compare them in the detailed product card and display a link to the page of this brand, in the Brands infoblock there may not be a brand that is uploaded to the Catalog, for this I make a condition in which just the name is displayed, but it turns out to either display a link for the product if there is a brand in the info. Brand, and the product if there is no such nonsense in inf. The brand disappears the brand completely or remove the brand but without links.
tell me what's wrong.
IBLOCK_ID"=> 4 is the Brands infoblock

<?	
  $arSelect = Array("CODE", "NAME");
  $arFilter = Array("IBLOCK_ID"=> 4, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
  $res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>5010), $arSelect);

  while($ob = $res->GetNextElement())
  {
    $arFields = $ob->GetFields();	
      
      if($arResult["PROPERTIES"]["ATT_TRADEMARK"]["VALUE"] == $arFields["NAME"])
      {
        
          echo "<a href='/brend/brend-s/".$arFields["CODE"]."/'>".$arResult['PROPERTIES']['ATT_TRADEMARK']['VALUE']."</a>";	
        
      }
//Если присутствует ниже указанный if то выводятся бренды у всех товаров без ссылки, если его убрать то бренд присутствует ссылкой только у товара у которого есть бред, а у товара у которого бренда нету она отсутствует
      if(!$arResult["PROPERTIES"]["ATT_TRADEMARK"]["VALUE"] == $arFields["NAME"])
      {
        
        echo $arResult['PROPERTIES']['ATT_TRADEMARK']['VALUE'];	
        break;
      }
  }
        
?>

I hope I described clearly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-10-07
@ZIROKUL

What's the code? This is some kind of gesture.
Add filtering by name. And that at you the request through an ass works.
But in general your approach is bad. After importing from 1C, it is necessary to write a handler that will run through the products and set the new property "Binding to the element of the Brands infoblock" and work with it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question