I
I
IliaMal2020-05-26 10:39:03
1C-Bitrix
IliaMal, 2020-05-26 10:39:03

Why doesn't it add a price using CPrice::Add?

Hello.

The task is to write down the price for the product without TP.
If the price was, rewrite, if not, add:

$arPrice = Array("PRODUCT_ID" => $ar_fields["ID"], "PRICE" => $ar_fields["PROPERTY_PRICE_EXPO_VALUE"], "CURRENCY" => "RUB");
$cp = new CPrice;
            $rs = $cp->GetList(array(), array("PRODUCT_ID" => $ar_fields["ID"]), false, false, array("ID"));
            if ($rs->SelectedRowsCount() > 0)
            {
                $ar = $rs->GetNext();
                $cp->Update($ar["ID"], $arPrice);
            }
            else
            {
                $cp->Add($arPrice);
            }

The script handles the price change as it should, but if the "Retail price" field is empty, then $cp->Add($arPrice) is triggered and returns false.

How to add a price to a product if the field is empty?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2020-05-26
@anton99zel

CURRENCY specified?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question