本文整理汇总了PHP中CPrice::SetBasePrice方法的典型用法代码示例。如果您正苦于以下问题:PHP CPrice::SetBasePrice方法的具体用法?PHP CPrice::SetBasePrice怎么用?PHP CPrice::SetBasePrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPrice
的用法示例。
在下文中一共展示了CPrice::SetBasePrice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setBasePrice
public function setBasePrice($price, $currencyId = 'RUB')
{
if (!class_exists('\\CPrice')) {
\CModule::IncludeModule('catalog');
}
return \CPrice::SetBasePrice($this->id, $price, $currencyId);
}
示例2: foreach
foreach($fields as $code => $field) {
if($_REQUEST[$code]) {
$arUpdate[$code] = $_REQUEST[$code];
}
}
foreach ($props as $prop) {
if($_REQUEST['props'][$prop["ID"]]) {
CIBlockElement::SetPropertyValuesEx($ID, $IBLOCK_ID, array($prop["ID"] => $_REQUEST['props'][$prop["ID"]]));
}
}
if($bCatalog && $_REQUEST['base_price_multiplier'] && isset($_REQUEST['base_price_add']) ) {
$arr = CPrice::GetBasePrice($ID);
$price = $arr["PRICE"];
$price = $price * $_REQUEST['base_price_multiplier'];
$price = $price + $_REQUEST['base_price_add'];
CPrice::SetBasePrice($ID, $price, $arr["CURRENCY"]);
}
if(count($arUpdate)) {
$el = new CIBlockElement;
$el->Update($ID, $arUpdate);
}
break;
case "delete":
if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_delete")) {
@set_time_limit(0);
$DB->StartTransaction();
$APPLICATION->ResetException();
if (!CIBlockElement::Delete($ID)) {
$DB->Rollback();
if ($ex = $APPLICATION->GetException())
$lAdmin->AddGroupError(GetMessage("IBLOCK_DELETE_ERROR") . " [" . $ex->GetString() . "]", $ID);
示例3: importElement
private function importElement($arItems, $IBLOCK_ID = 0, $event = 'element')
{
if (!$IBLOCK_ID)
{
$IBLOCK_ID = $this->CATALOG_ID;
}
$arResult = array();
$arOffers = array();
$el = new \CIBlockElement;
foreach ($arItems as $arItem)
{
if (!strlen($arItem['XML_ID']))
{
throw new \Exception('Empty element XML ID '.$arItem['name']);
}
$boolUpdate = true;
if (!strlen($arItem['CODE']))
{
$arItem['CODE'] = \CUtil::translit($arItem['NAME'], 'ru', array(
"replace_space" => '-',
"replace_other" => '-'
));
}
$arLoadProduct = array(
'ACTIVE' => $arItem['ACTIVE'],
'XML_ID' => $arItem['XML_ID'],
'NAME' => $arItem['NAME'],
'CODE' => $arItem['CODE'],
'DETAIL_TEXT' => $arItem['DESCRIPTION'],
);
$params = array(
'select' => array('ID', 'ACTIVE'),
'filter' => array(
'=IBLOCK_ID' => $IBLOCK_ID,
'=XML_ID' => $arItem['XML_ID']
)
);
$arElem = ElementTable::getRow($params);
if ($arElem['ID'] > 0)
{
$boolUpdate = !App::compareHash($arItem);
if ($boolUpdate || $arItem['ACTIVE'] !== $arElem['ACTIVE'])
{
$el->Update($arElem['ID'], $arLoadProduct);
Report::update($event);
}
}
else
{
$arSection = $this->getSectionByXML($arItem['SECTION_XML_ID'], $IBLOCK_ID);
if (!$arSection['ID'])
{
throw new \Exception('Cant find section with XML ID: '.$arItem['SECTION_XML_ID']);
}
$arLoadProduct = array_merge($arLoadProduct, array(
'IBLOCK_SECTION_ID' => $arSection['ID'],
'IBLOCK_ID' => $IBLOCK_ID
));
$arElem['ID'] = $el->Add($arLoadProduct);
App::compareHash($arItem);
Report::create($event);
}
// если элемент не нашли и не создали, выплюнем эксепшен
if (!$arElem['ID'])
{
throw new \Exception('Cant create element');
}
$arResult[$arItem['XML_ID']] = $arElem['ID'];
if ($boolUpdate)
{
$arCatalogProduct = array(
"ID" => $arElem['ID'],
"WEIGHT" => $arItem['WEIGHT']
);
\CCatalogProduct::Add($arCatalogProduct); // добавим элемент в каталог
\CPrice::SetBasePrice($arElem['ID'], $arItem['PRICE'], "RUB"); // установим базовую цену
$arOfferProp = array();
if (!empty($arItem['MODIFIERS']))
{
foreach ($arItem['MODIFIERS'] as $arMod)
{
$arOfferProp[] = array(
'XML_ID' => $this->defaultSectionID,
'VALUE_XML_ID' => $arMod['XML_ID'],
'REQUIRED' => $arMod['REQUIRED']
);
}
}
if (!empty($arItem['GROUP_MODIFIERS'])) // тут то же самое, только нужно создать ТП из всего свойства, а не из конкретного значения
{
foreach ($arItem['GROUP_MODIFIERS'] as $arMod)
{
$arOfferProp[] = array(
'XML_ID' => $arMod['XML_ID'],
//.........这里部分代码省略.........