How to compare two information block and print the values?

Good day

Podskagite:

There are two InfoBlock single Directory called the second product Brands.
In the first are stored the products of 1C, the second places for the brands name and logo.

The Directory has a property: Trade mark character code ATT_TRADEMARK

The InfoBlock Brands in the Name field, put the same name with Bredli in the Catalog, in the properties box, brand
Example:
Brand with character code ATT_TRADEMARK = RIEKER
and the Brand name = RIEKER

With the help of CIBlockElement::GetList trying to compare them in a detailed card of the product and display the page link of the brand in the InfoBlock Brands may not be the brand which is uploaded to the Catalog, this makes a condition which displays just the name, but it turns out or display link item if there is one brand in info. A brand, a product if such nonsense is not present in INF. Brand brand disappears completely or take the brand but the be links.
tell me what's wrong.
IBLOCK_ID"=> 4 is an InfoBlock Brands
<? 
 $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 there is specified below, if it displays the brands all the products without links, if it is clear that the brand is present in only a product which is nonsense, and a product whose brand is not present, it is not
 if(!$arResult["PROPERTIES"]["ATT_TRADEMARK"]["VALUE"] == $arFields["NAME"])
{

 echo $arResult['PROPERTIES']['ATT_TRADEMARK']['VALUE']; 
break;
}
}

?>

Hope I described clearly.
June 14th 19 at 19:10
1 answer
June 14th 19 at 19:12
Solution
What kind of code? It's a gesture of some sort.
Add filtering by name. And then you go through the ass working.

But in General your approach is bad. It is necessary after import from 1C to write a handler that will be run on tavar, and set the new property "Binding to element of the InfoBlock Brands" and work with it
Added filtering by the name "NAME" but with the same result, if not properly asked as I could tell. Beatrix just beginning to explore the experience a little, then tell me how to implement this feature correctly, without reference to the element? - Delia_Carter13 commented on June 14th 19 at 19:15
You have the semantics of the code is not correct.
<?


 $arSelect = Array("IBLOCK_ID", "ID". "CODE", "NAME");
 $arFilter = Array("IBLOCK_ID"=--> 4, "ACTIVE"=>"Y", "=NAME" => $arResult['PROPERTIES']['ATT_TRADEMARK']['VALUE']);
 $res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);

 if ($ob = $res->GetNextElement())
{
 $arFields = $ob->GetFields(); 

 echo "<a href="/brend/brend-s/".$arFields["CODE"]."/">".$arFields["NAME"]."</a>"; 
 } else {
 echo $arResult['PROPERTIES']['ATT_TRADEMARK']['VALUE']; 
 }


But in your code
if(!$arResult["PROPERTIES"]["ATT_TRADEMARK"]["VALUE"] == $arFields["NAME"])

It would be correct to write
if($arResult["PROPERTIES"]["ATT_TRADEMARK"]["VALUE"] != $arFields["NAME"])
- Mabel commented on June 14th 19 at 19:18
Thank you very much.
If You don't mind tell me what's in $arSelect is selected, more "IBLOCK_ID", "ID". "CODE", "NAME", the parameters are selected from the information block 4 ?
If so then $arSelect ("IBLOCK_ID" = 4) ? - Delia_Carter13 commented on June 14th 19 at 19:21
Yes , of item 4 of the information block. IBLOCK_ID will be equal to 4. In arSelect worth it to add always, unless sure exactly what sample you will be hurt. This affects for example the selection of PROPERTIES, without IBLOCK_ID they are correctly selected. Well, I also add ID on the machine, but you can not choose. Resource is not wasted - Mabel commented on June 14th 19 at 19:24
Thank you, I'll know. - Delia_Carter13 commented on June 14th 19 at 19:27

Find more questions by tags 1C-Bitrix