本文整理汇总了PHP中CPrice类的典型用法代码示例。如果您正苦于以下问题:PHP CPrice类的具体用法?PHP CPrice怎么用?PHP CPrice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPrice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
function Add($arFields, $boolRecalc = false)
{
global $DB;
$boolBase = false;
$arFields['RECALC'] = $boolRecalc === true;
foreach (GetModuleEvents("catalog", "OnBeforePriceAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
if (!CPrice::CheckFields("ADD", $arFields, 0)) {
return false;
}
if (isset($arFields['RECALC']) && $arFields['RECALC'] === true) {
CPrice::ReCountFromBase($arFields, $boolBase);
if (!$boolBase && $arFields['EXTRA_ID'] <= 0) {
return false;
}
}
$arInsert = $DB->PrepareInsert("b_catalog_price", $arFields);
$strSql = "INSERT INTO b_catalog_price(" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = (int) $DB->LastID();
if ($ID > 0 && $boolBase) {
CPrice::ReCountForBase($arFields);
}
foreach (GetModuleEvents("catalog", "OnPriceAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
// strange copy-paste bug
foreach (GetModuleEvents("sale", "OnPriceAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}
示例2: Add
function Add($arFields, $boolRecalc = false)
{
global $DB;
if (!CPrice::CheckFields("ADD", $arFields, 0)) {
return false;
}
$boolBase = false;
$arFields['RECALC'] = $boolRecalc === true ? true : false;
$events = GetModuleEvents("catalog", "OnBeforePriceAdd");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
if (!empty($arFields['RECALC']) && $arFields['RECALC'] === true) {
CPrice::ReCountFromBase($arFields, $boolBase);
}
$arInsert = $DB->PrepareInsert("b_catalog_price", $arFields);
$strSql = "INSERT INTO b_catalog_price(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$ID = IntVal($DB->LastID());
if ($ID > 0 && $boolBase == true) {
CPrice::ReCountForBase($arFields);
}
$events = GetModuleEvents("catalog", "OnPriceAdd");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
// strange copy-paste bug
$events = GetModuleEvents("sale", "OnPriceAdd");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array($ID, $arFields));
}
return $ID;
}
示例3: executeComponent
function executeComponent()
{
$arFilter = array('IBLOCK_ID' => $this->arParams['IBLOCK_ID'], 'ACTIVE' => 'Y');
if (true || $this->StartResultCache()) {
$CIBlockElement = new CIBlockElement();
$CFile = new \CFile();
$aElts = array();
$eltsSelectFields = array_merge(array('ID', 'NAME', 'CODE', 'PREVIEW_PICTURE', 'DETAIL_PICTURE', 'DETAIL_PAGE_URL'), $this->getIBlockProperties($this->arParams['IBLOCK_ID']));
$rsElts = $CIBlockElement->GetList(array('SORT' => 'asc', 'date_active_from' => 'DESC'), $arFilter, false, false, array('ID', 'NAME'));
if (intval($rsElts->SelectedRowsCount())) {
while ($arElt = $rsElts->Fetch()) {
$aElts[] = array('ID' => $arElt['ID'], 'NAME' => $arElt['NAME']);
}
$arElt = $CIBlockElement->GetList(array('SORT' => 'asc', 'ID' => 'DESC'), array_merge($arFilter, array('ID' => $aElts[0]['ID'])), false, false, $eltsSelectFields)->GetNext();
if ($arElt['DETAIL_PICTURE']) {
$arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['DETAIL_PICTURE']);
} elseif ($arElt['PREVIEW_PICTURE']) {
$arElt['DETAIL_PICTURE'] = $CFile->GetPath($arElt['PREVIEW_PICTURE']);
}
$arPrice = CPrice::GetList(array(), array("PRODUCT_ID" => $arElt['ID']))->Fetch();
$arElt['PRICE'] = $arPrice['PRICE'];
$this->arResult['ITEMS'] = $aElts;
$this->arResult['ITEM'] = $arElt;
$this->IncludeComponentTemplate();
}
}
}
示例4: loadFromDatabase
protected function loadFromDatabase()
{
if (!isset($this->fields)) {
$pricesList = \CPrice::getListEx(array(), array("=PRODUCT_ID" => $this->id, "+<=QUANTITY_FROM" => 1, "+>=QUANTITY_TO" => 1), false, false, array("PRICE", "CURRENCY", "CATALOG_GROUP_ID", "CATALOG_GROUP_CODE"));
$this->fields = array();
while ($priceInfo = $pricesList->fetch()) {
$price_id = $priceInfo["CATALOG_GROUP_ID"];
$price = \FormatCurrency($priceInfo["PRICE"], $priceInfo["CURRENCY"]);
$this->addField($price_id, $price_id, $price);
$this->addField($priceInfo["CATALOG_GROUP_CODE"], $price_id, $price);
}
}
return is_array($this->fields);
}
示例5: setExtra
private function setExtra($productId, $priceTypeId, $extraId)
{
$list = CPrice::GetList(array(), array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $priceTypeId), false, false, array('ID', 'EXTRA_ID'));
$arFields = array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $priceTypeId, 'EXTRA_ID' => $extraId, 'CURRENCY' => 'USD');
if ($res = $list->Fetch()) {
if ($res['EXTRA_ID'] != $extraId) {
CPrice::Update($res['ID'], $arFields, true);
}
} else {
CPrice::Add($arFields, true);
}
unset($list);
unset($res);
unset($resultUp);
}
示例6: Update
function Update($ID, $arFields)
{
global $DB;
$ID = intval($ID);
if (!CExtra::CheckFields('UPDATE', $arFields, $ID)) {
return false;
}
$strUpdate = $DB->PrepareUpdate("b_catalog_extra", $arFields);
$strSql = "UPDATE b_catalog_extra SET " . $strUpdate . " WHERE ID = '" . intval($ID) . "'";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!empty($arFields["RECALCULATE"]) && $arFields["RECALCULATE"] == "Y") {
CPrice::ReCalculate("EXTRA", $ID, $arFields["PERCENTAGE"]);
}
unset($GLOBALS["MAIN_EXTRA_LIST_CACHE"]);
return true;
}
示例7: add_element
function add_element($iblock_id, $section_id, $NAME, $PRICE_EUR, $P, $DETAIL_PICTURE)
{
$el = new CIBlockElement();
//test_dump($P);
$arFields = array("IBLOCK_ID" => $iblock_id, "NAME" => $NAME, "CODE" => $P["ARTNUMBER"], "ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $section_id, "DETAIL_TEXT" => $P["DESCRIPTION_TEXT"], "DETAIL_TEXT_TYPE" => "html", "PROPERTY_VALUES" => $P, "DETAIL_PICTURE" => $DETAIL_PICTURE);
if ($last_el_id = $el->Add($arFields)) {
echo "New ID: " . $last_el_id . "<br>";
$arFields = array("ID" => $last_el_id, "VAT_INCLUDED" => "Y");
if (CCatalogProduct::Add($arFields)) {
echo "Добавили параметры товара к элементу каталога " . $last_el_id . "<br>";
$arFields = array("PRODUCT_ID" => $last_el_id, "CATALOG_GROUP_ID" => 1, "PRICE" => $PRICE_EUR, "CURRENCY" => "EUR");
CPrice::Add($arFields);
} else {
echo "Ошибка добавления параметров товаров";
}
} else {
echo "Error: " . $el->LAST_ERROR . "<br>";
}
}
示例8: Update
function Update($ID, $arFields)
{
global $DB;
$ID = intval($ID);
if (0 >= $ID) {
return false;
}
if (!CExtra::CheckFields('UPDATE', $arFields, $ID)) {
return false;
}
$strUpdate = $DB->PrepareUpdate("b_catalog_extra", $arFields);
if (!empty($strUpdate)) {
$strSql = "UPDATE b_catalog_extra SET " . $strUpdate . " WHERE ID = " . $ID;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (isset($arFields['RECALCULATE']) && 'Y' == $arFields['RECALCULATE']) {
CPrice::ReCalculate('EXTRA', $ID, $arFields['PERCENTAGE']);
}
CExtra::ClearCache();
}
return true;
}
示例9: getFavoriteProducts
/**
* [getFavoriteProducts description]
* @param array $arFavorites
* @return array products
*/
function getFavoriteProducts($arFavorites)
{
global $USER;
foreach ($arFavorites as $key => $id) {
$arSelect = array();
$arFilter = array("IBLOCK_ID" => 17, "ACTIVE" => "Y", "ID" => $id);
$res = CIBlockElement::GetList(array(), $arFilter, false, false, $arSelect);
if ($ob = $res->GetNextElement()) {
$arItems = $ob->GetFields();
$arItems["PROPERTIES"] = $ob->GetProperties();
$dbPrice = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC", "SORT" => "ASC"), array("PRODUCT_ID" => $arItems["ID"]), false, false, array("ID", "CATALOG_GROUP_ID", "PRICE", "CURRENCY", "QUANTITY_FROM", "QUANTITY_TO"));
if ($arPrice = $dbPrice->Fetch()) {
$arDiscounts = CCatalogDiscount::GetDiscountByPrice($arPrice["ID"], $USER->GetUserGroupArray(), "N", SITE_ID);
$discountPrice = CCatalogProduct::CountPriceWithDiscount($arPrice["PRICE"], $arPrice["CURRENCY"], $arDiscounts);
$arPrice["DISCOUNT_VALUE"] = $discountPrice;
$arItems["PRICES"] = $arPrice;
}
}
if ($arItems) {
$arFav[] = $arItems;
}
}
return $arFav;
}
示例10: GetMessage
echo GetMessage("C2IT_PRICE");
?>
</td>
<td align="center"><?php
echo GetMessage("C2IT_CURRENCY");
?>
</td>
</tr>
</thead>
<tbody id="container3_<?php
echo $arCatalogGroup["ID"];
?>
">
<?php
$ind = -1;
$dbPriceList = CPrice::GetList(array("QUANTITY_FROM" => "ASC", "QUANTITY_TO" => "ASC"), array("PRODUCT_ID" => $PRODUCT_ID, "CATALOG_GROUP_ID" => $arCatalogGroup["ID"]));
$arPrice = $dbPriceList->Fetch();
for ($i = 0, $intCount = count($arPriceBoundaries); $i < $intCount; $i++) {
$boolExistPrice = false;
$ind++;
$str_CAT_QUANTITY_FROM = $arPriceBoundaries[$i]["FROM"];
$str_CAT_QUANTITY_TO = $arPriceBoundaries[$i]["TO"];
if ($arPrice && intval($arPrice["QUANTITY_FROM"]) == $arPriceBoundaries[$i]["FROM"]) {
$str_CAT_ID = $arPrice["ID"];
$str_CAT_EXTRA = $arPrice["EXTRA_ID"];
$str_CAT_PRICE = $arPrice["PRICE"];
$str_CAT_CURRENCY = $arPrice["CURRENCY"];
$arPrice = $dbPriceList->Fetch();
} else {
$str_CAT_ID = 0;
$str_CAT_EXTRA = 0;
示例11: array
$killed_lines++;
} else {
$bDeactivationStarted = true;
$el->Update($arr["ID"], array("ACTIVE" => "N", "TMP_ID" => $tmpid));
$killed_lines++;
}
if (!($bAllLinesLoaded = CSVCheckTimeout($max_execution_time))) {
break;
}
}
}
// delete 'not-in-file' element prices
if ($bAllLinesLoaded && $bIBlockIsCatalog && 'Y' == $bUpdatePrice && $outFileAction == "D") {
$res = CPrice::GetList(array(), array("ELEMENT_IBLOCK_ID" => $IBLOCK_ID, "!TMP_ID" => $tmpid), false, false, array("ID"));
while ($arr = $res->Fetch()) {
CPrice::Delete($arr["ID"]);
if (!($bAllLinesLoaded = CSVCheckTimeout($max_execution_time))) {
break;
}
}
}
if (!$bAllLinesLoaded) {
$bAllDataLoaded = false;
$INTERNAL_VARS_LIST = "tmpid,line_num,correct_lines,error_lines,killed_lines,arIBlockProperty,bThereIsGroups,arProductGroups,arIBlockPropertyValue,bDeactivationStarted,bUpdatePrice";
$SETUP_VARS_LIST = "IBLOCK_ID,URL_DATA_FILE,fields_type,first_names_r,delimiter_r,delimiter_other_r,first_names_f,metki_f,PATH2IMAGE_FILES,outFileAction,inFileAction,max_execution_time,IMAGE_RESIZE,USE_TRANSLIT,TRANSLIT_LANG,CLEAR_EMPTY_PRICE,CML2_LINK_IS_XML";
for ($i = 0; $i < $NUM_FIELDS; $i++) {
$SETUP_VARS_LIST .= ",field_" . $i;
}
$CUR_FILE_POS = $csvFile->GetPos();
}
}
示例12: array
elseif(!isset($CATALOG_EXTRA[$elID][$arCatalogGroup["ID"]]))
{
$arFields = array(
"PRODUCT_ID" => $elID,
"CATALOG_GROUP_ID" => $arCatalogGroup["ID"],
"PRICE" => $arPrice[$arCatalogGroup["ID"]],
"CURRENCY" => $arCurrency[$arCatalogGroup["ID"]],
"QUANTITY_FROM" => $CATALOG_QUANTITY_FROM[$elID][$arCatalogGroup["ID"]],
"QUANTITY_TO" => $CATALOG_QUANTITY_TO[$elID][$arCatalogGroup["ID"]]
);
if($arFields["PRICE"] < 0 || trim($arFields["PRICE"]) === '')
CPrice::Delete($CATALOG_PRICE_ID[$elID][$arCatalogGroup["ID"]]);
elseif(intval($CATALOG_PRICE_ID[$elID][$arCatalogGroup["ID"]])>0)
CPrice::Update(intval($CATALOG_PRICE_ID[$elID][$arCatalogGroup["ID"]]), $arFields);
elseif($arFields["PRICE"] >= 0)
CPrice::Add($arFields);
}
}
}
unset($arCatalogGroup);
}
}
}
}
}
// Handle actions here
if(($arID = $lAdmin->GroupAction()))
{
if($_REQUEST['action_target']=='selected')
示例13: array
{
$img = CFile::GetFileArray($viewed[$fields['ID']]['DETAIL_PICTURE']);
if($img)
$viewed[$fields['ID']]['DETAIL_PICTURE'] = $img['SRC'];
else
$viewed[$fields['ID']]['DETAIL_PICTURE'] = false;
}
else
{
$viewed[$fields['ID']]['DETAIL_PICTURE'] = false;
}
}
// Prices
$priceIterator = CPrice::getList(array(), array("PRODUCT_ID" => $filter['ID']), false, false, array("PRODUCT_ID", "PRICE", "CURRENCY"));
while($price = $priceIterator->fetch())
{
if(!isset($viewed[$price['PRODUCT_ID']]['PRICE']))
{
$viewed[$price['PRODUCT_ID']]['PRICE'] = $price['PRICE'];
$viewed[$price['PRODUCT_ID']]['CURRENCY'] = $price['CURRENCY'];
}
}
}
//
$arViewedResult = fDeleteDoubleProduct($viewed, $arFilterRecommended, 'N');
if (empty($arViewedResult["ITEMS"]))
$displayNoneViewed = "none";
$tabBasket = "tabs";
示例14: getPrices
protected function getPrices($productId, $siteId)
{
$minPrice = 0;
$minPriceRUR = 0;
$minPriceGroup = 0;
$minPriceCurrency = "";
$baseCurrency = \CCurrency::GetBaseCurrency();
$RUR = $this->getRub();
if ($this->xmlData['PRICE'] > 0) {
$rsPrices = \CPrice::GetListEx(array(), array('PRODUCT_ID' => $productId, 'CATALOG_GROUP_ID' => $this->xmlData['PRICE'], 'CAN_BUY' => 'Y', 'GROUP_GROUP_ID' => array(2), '+<=QUANTITY_FROM' => 1, '+>=QUANTITY_TO' => 1));
if ($arPrice = $rsPrices->Fetch()) {
if ($arOptimalPrice = \CCatalogProduct::GetOptimalPrice($productId, 1, array(2), 'N', array($arPrice), $siteId)) {
$minPrice = $arOptimalPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $baseCurrency;
$minPriceRUR = \CCurrencyRates::ConvertCurrency($minPrice, $baseCurrency, $RUR);
$minPriceGroup = $arOptimalPrice['PRICE']['CATALOG_GROUP_ID'];
}
}
} else {
if ($arPrice = \CCatalogProduct::GetOptimalPrice($productId, 1, array(2), 'N', array(), $siteId)) {
$minPrice = $arPrice['DISCOUNT_PRICE'];
$minPriceCurrency = $baseCurrency;
$minPriceRUR = \CCurrencyRates::ConvertCurrency($minPrice, $baseCurrency, $RUR);
$minPriceGroup = $arPrice['PRICE']['CATALOG_GROUP_ID'];
}
}
$result = array("MIN" => $minPrice, "MIN_RUB" => $minPriceRUR, "MIN_GROUP" => $minPriceGroup, "MIN_CURRENCY" => $minPriceCurrency);
return $result;
}
示例15: getSkuPrices
protected function getSkuPrices()
{
$result = array();
if ($this->offers) {
$ids = array();
foreach ($this->offers as $id => $offers) {
foreach ($offers as $offer) {
$ids[] = $offer['ID'];
}
}
if ($ids) {
$priceIds = $this->getVisiblePrices();
foreach ($priceIds as $id) {
$dbPrice = \CPrice::getList(array(), array('PRODUCT_ID' => $ids, 'CATALOG_GROUP_ID' => $id), false, false, array('PRODUCT_ID', 'PRICE', 'CURRENCY'));
while ($arPrice = $dbPrice->fetch()) {
$result[$id][$arPrice["PRODUCT_ID"]] = array('PRICE' => $arPrice['PRICE'], 'CURRENCY' => $arPrice['CURRENCY']);
}
}
}
}
return $result;
}