Bitrix Site Manager

CPrice::Update

bool
CPrice::Update(
 int ID, 
 array arFields
);

The method Update updates the price properties with the new values.

Parameters

ParameterDescription
ID Price ID.
arFields Associated array of the new parameter values with the following keys:
  • PRODUCT_ID - product ID;
  • EXTRA_ID - the ID of discount or extra;
  • CATALOG_GROUP_ID - price type ID;
  • PRICE - price value;
  • CURRENCY - currency of the price.
If the discount ID is specified, the created price will be automatically recalculated when the base price or discount changes.

Return Values

Returns True on success or False otherwise.

Example



<?
// Assign the price of USD29.95 of the type 2
// to the product with the ID of 15
$PRODUCT_ID = 15;
$PRICE_TYPE_ID = 2;

$arFields = Array(
    "PRODUCT_ID" => $PRODUCT_ID,
    "CATALOG_GROUP_ID" => $PRICE_TYPE_ID,
    "PRICE" => 29.95,
    "CURRENCY" => "USD"
);

$res = CPrice::GetList(($o=""),
                       ($b=""),
                       Array("PRODUCT_ID"=>$PRODUCT_ID,
                             "CATALOG_GROUP_ID"=>$PRICE_TYPE_ID));

if ($arr = $res->Fetch())
{
    CPrice::Update($arr["ID"], $arFields);
}
else
{
    CPrice::Add($arFields);
}
?>