L
L
lotoseu2021-06-11 16:10:58
1C-Bitrix
lotoseu, 2021-06-11 16:10:58

How to change Activity value using API?

Can't change property with Update

<?
CModule::IncludeModule("iblock");

$el = new CIBlockElement;
 if($enum_fields['XML_ID']=='true'){
      $res= $el->Update($id, array("ACTIVE"=> "Y"));
 } else
       $res= $el->Update($id, array("ACTIVE"=> "N"));

?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
scottparker, 2021-06-11
@scottparker

What exactly doesn't work?
Did you look at $el->LAST_ERROR?

A
Alexander, 2021-06-12
Madzhugin @Suntechnic

There are only two options:
1 The condition is invalid and $enum_fields['XML_ID'] is never equal to 'true' (it would be strange if it was).
2 The condition is true and there is a product with XML_ID== 'true', but on the AfterUpdate event, there is a handler that changes the value to N, deactivating the product.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question