R
R
run1822019-07-10 19:09:31
1C-Bitrix
run182, 2019-07-10 19:09:31

How to fill in the base price of a product in Bitrix via API?

MAjQZbZTjw64q2.jpg
Here is the code:

$PRICE_TYPE_ID = 1;
$arFields = Array(
    "PRODUCT_ID" => $PRODUCT_ID,
    "CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
    "PRICE" => 500,
    "CURRENCY" => "RUB",
    "QUANTITY_FROM" => 0,
    "QUANTITY_TO" => 999
);
$res = CPrice::GetList(array(), array("PRODUCT_ID" => $PRODUCT_ID, "CATALOG_GROUP_ID" => $PRICE_TYPE_ID));
if ($arr = $res->Fetch()) {
    CPrice::Update($arr["ID"], $arFields);
} else {
    $idPrice = CPrice::Add($arFields);
    //CCatalogGroup::Update($idPrice, Array("BASE" => "Y"));
}
            
//CPrice::SetBasePrice($PRODUCT_ID, $arFieldsRow[2], "RUB", 0);
//CCatalogProduct::Update($PRODUCT_ID, array('WEIGTH' => $arFieldsRow[3]));

Here is the code that I used, I also tried commented out, it does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
run182, 2019-07-10
@run182

Sergey
Try to add before CPrice::Add

$cataloProductClass = new CCatalogProduct;
$cataloProductClass->Add(array(
    "ID" => $PRODUCT_ID,
    'QUANTITY' => 0,
));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question