N
N
Namco2016-05-13 09:09:41
PHP
Namco, 2016-05-13 09:09:41

Update only one property in infoblock?

Tell me more, such a problem has appeared, that is, when updating the date, all the other properties are overwritten so as not to list all the properties in the array, there is still a method that can only update the date of the element

<?
include($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
define("NO_KEEP_STATISTIC", true);
define("NO_AGENT_STATISTIC", true);
if(CModule::IncludeModule("iblock")){ 
 
if (isset($_GET['ID']) && intval($_GET['ID'])):
    $newDate = ConvertTimeStamp(time(), "FULL");
    $elProps = array(
            "MODIFIED_BY"       => $USER->GetID(),       
            "IBLOCK_ID"         => 3,
            "ACTIVE_FROM"       => $newDate,
            "ACTIVE"            => "Y",
        );
    $newEl = new CIBlockElement;
      $res = $newEl->Update($_GET['ID'], $elProps);
    echo $newDate;
endif;
die();
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Vyachenkov, 2016-09-30
@vsyakiyjr

You can use the CIBlockElement::SetPropertyValuesEx function to update an arbitrary number of properties. Example CIBlockElement::SetPropertyValuesEx($ID_ELEM, false, array($PROPERTY_CODE => Array ("VALUE" => $VALUE)));

E
Express777, 2016-05-13
@Express777

Maybe the time format in $newDate is wrong. Try to manually set the date for the test, for example, 05/05/2016.
See if $res returns true or false?
At the end of the code, check the value of $newEl->LAST_ERROR?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question