Answer the question
In order to leave comments, you need to log in
Bitrix property change CIBlockElement::SetPropertyValuesEx?
Tell me, have you encountered such a problem with writing values for properties of the STRING type, but it is possible that LIST has the same problem, in general, this problem concerns exactly the values \u200b\u200bof which STRING
The whole problem boils down to the fact that in the CIBlockElement::SetPropertyValuesEx method the array ["CODE"= >"Value"] to add, change property value and manage other fields of type VALUE_ENUM, VALUE_NUM is not possible from this method, tried like this ["CODE"=["VALUE"=>Value, "VALUE_ENUM"=>0, "VALUE_NUM "=>0]] does not perceive, well, it's understandable because in the CIBlockElement::SetPropertyValuesEx method, only VALUE and DESCRIPTION can be defined in $PROPERTY_VALUES, and VALUE_ENUM, VALUE_NUM are taken from VALUE
and that's actually what the problem is, all values from VALUE are converted to intval() and if you look at what intval() actually does in the php docks, you will see this
intval ( mixed $value , int $base = 10 ) : int
// Замечание:
// Если base равно 0, основание системы счисления определяется форматом value:
// если строка включает префикс "0x" (или "0X"), основание выбирается равным 16 (шестнадцатеричным);
// иначе, если строка начинается с "0", основание равно 8 (восьмеричное);
// иначе, основание выбирается равным 10 (десятеричным).
$maxValuesLen = $DB->type=="MYSQL"?1024:0;
$strSqlValues = "";
foreach($properties as $property_id=>$values)
{
foreach($values as $value)
{
if($value["VALUE"] <> '')
{
$strSqlValues .= ",\n(".
$property_id.", ".
$ELEMENT_ID.", ".
"'".$DB->ForSQL($value["VALUE"])."', ".
intval($value["VALUE"]).", ".
CIBlock::roundDB($value["VALUE"]).", ".
($value["DESCRIPTION"] <> ''? "'".$DB->ForSQL($value["DESCRIPTION"])."'" : "null")." ".
")";
}
if(mb_strlen($strSqlValues) > $maxValuesLen)
{
$DB->Query($strSqlPrefix.mb_substr($strSqlValues, 2));
$strSqlValues = "";
}
}
}
"'".$DB->ForSQL($value["VALUE"])."', ".
intval($value["VALUE"]).", ".
CIBlock::roundDB($value["VALUE"]).", ".
class CIBlockElementModify extends CIBlockElement
{
public static function SetPropertyValuesEx($ELEMENT_ID, $IBLOCK_ID, $PROPERTY_VALUES, $FLAGS=array())
{
...
$maxValuesLen = $DB->type=="MYSQL"?1024:0;
$strSqlValues = "";
foreach($properties as $property_id=>$values)
{
foreach($values as $value)
{
if($value["VALUE"] <> '')
{
$strSqlValues .= ",\n(".
$property_id.", ".
$ELEMENT_ID.", ".
"'".$DB->ForSQL($value["VALUE"])."', ".
(intval($value["VALUE"])===$value["VALUE"]?intval($value["VALUE"]):'null').", ".
(intval($value["VALUE"])===$value["VALUE"]?CIBlock::roundDB($value["VALUE"]):0).", ".
($value["DESCRIPTION"] <> ''? "'".$DB->ForSQL($value["DESCRIPTION"])."'" : "null")." ".
")";
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question