I
I
IgorRastarov2018-03-04 21:32:29
1C-Bitrix
IgorRastarov, 2018-03-04 21:32:29

How to display only filled properties?

Hello. I have a question. I have a lot of product properties in the infoblock. Unfortunately, you won't be able to create a separate infoblock with product properties. And I need to display all 500 properties completely. Perhaps they will be added. I want to display only completed properties.
I am using API

foreach($arResult as $key => $props){
  $arSelectNew = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM", "ACTIVE"=>"Y", "PROPERTY_*");
  $arFilterNew = Array("IBLOCK_ID" => 3,"ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y", "!PROPERTY_*"=> false);
  $resNew = CIBlockElement::GetList(Array(),$arFilterNew,false,Array(),$arSelectNew);
  
  while($obNew = $resNew->GetNextElement()){ 
    $arPropsNew = $obNew->GetProperties();
    $props['ALL_PROPS'] = $arPropsNew;	
  }
  
$arResult["NEW_PROPERTIES"]["ALL_PROPS"] = $props;
}

But, the condition "!PROPERTY_*"=> false - doesn't want to work. It works, only with a specific indication of the Property Name. For example, "!PROPERTY_ARTNUMBER"=> false.
I've been googling for two days now and can't find an answer.
Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serginhold, 2018-03-04
@serginhold

only through checking the value on the output. There is no way to request via GetList() api. In any case, you have 1 product, for example, has 2 properties, the second product has 3 other properties, in total, you need data on 5 properties for two products. Etc. etc. It's easier to ask for everything. And if you really want to optimize somehow, let’s say you don’t pull 300 exactly empty properties, then first select products without properties, then take their ID, then a direct query to the database, get a list of properties for products, then getList again, into which you pass set of received properties. In short, this is Bitrix, everything is bad with this. I’ll also write right away that the getProperties () method makes a request to the database with each call, i.e. if there are 50 products on the page, then there will be 50 extra requests .. in general, sit, suffer and think what is best for you =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question