本文整理汇总了PHP中CIBlockElement::GetById方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement::GetById方法的具体用法?PHP CIBlockElement::GetById怎么用?PHP CIBlockElement::GetById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElement
的用法示例。
在下文中一共展示了CIBlockElement::GetById方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
public static function Update($ID, $arFields)
{
if (!CModule::IncludeModule('catalog')) {
return false;
}
global $DB;
if (!self::CheckFields('UPDATE', $arFields, $ID)) {
return false;
}
if (isset($arFields['NAME']) || isset($arFields['SECTION_ID']) || isset($arFields['SORT']) || isset($arFields['ACTIVE']) || isset($arFields['DETAIL_PICTURE']) || isset($arFields['DESCRIPTION']) || isset($arFields['DESCRIPTION_TYPE']) || isset($arFields['PREVIEW_PICTURE']) || isset($arFields['PREVIEW_TEXT']) || isset($arFields['PREVIEW_TEXT_TYPE']) || isset($arFields['ORIGINATOR_ID']) || isset($arFields['ORIGIN_ID']) || isset($arFields['XML_ID']) || isset($arFields['PROPERTY_VALUES'])) {
$element = new CIBlockElement();
$obResult = $element->GetById($ID);
if ($arElement = $obResult->Fetch()) {
// files
$arElement['PREVIEW_PICTURE'] = CFile::MakeFileArray($arElement['PREVIEW_PICTURE']);
$arElement['DETAIL_PICTURE'] = CFile::MakeFileArray($arElement['DETAIL_PICTURE']);
if (isset($arFields['NAME'])) {
$arElement['NAME'] = $arFields['NAME'];
}
if (isset($arFields['SECTION_ID'])) {
$arElement['IBLOCK_SECTION_ID'] = $arFields['SECTION_ID'];
}
if (isset($arFields['SORT'])) {
$arElement['SORT'] = $arFields['SORT'];
}
if (isset($arFields['ACTIVE'])) {
$arElement['ACTIVE'] = $arFields['ACTIVE'];
}
if (isset($arFields['DETAIL_PICTURE'])) {
$arElement['DETAIL_PICTURE'] = $arFields['DETAIL_PICTURE'];
}
if (isset($arFields['DESCRIPTION'])) {
$arElement['DETAIL_TEXT'] = $arFields['DESCRIPTION'];
}
if (isset($arFields['DESCRIPTION_TYPE'])) {
$arElement['DETAIL_TEXT_TYPE'] = $arFields['DESCRIPTION_TYPE'];
}
if (isset($arFields['PREVIEW_PICTURE'])) {
$arElement['PREVIEW_PICTURE'] = $arFields['PREVIEW_PICTURE'];
}
if (isset($arFields['PREVIEW_TEXT'])) {
$arElement['PREVIEW_TEXT'] = $arFields['PREVIEW_TEXT'];
$arElement['PREVIEW_TEXT_TYPE'] = 'text';
}
if (isset($arFields['PREVIEW_TEXT_TYPE'])) {
$arElement['PREVIEW_TEXT_TYPE'] = $arFields['PREVIEW_TEXT_TYPE'];
}
if (isset($arFields['XML_ID'])) {
$arElement['XML_ID'] = $arElement['EXTERNAL_ID'] = $arFields['XML_ID'];
} else {
if (isset($arFields['ORIGINATOR_ID']) || isset($arFields['ORIGIN_ID'])) {
if (strlen($arFields['ORIGINATOR_ID']) > 0 && strlen($arFields['ORIGIN_ID']) > 0) {
$arElement['XML_ID'] = $arFields['ORIGINATOR_ID'] . '#' . $arFields['ORIGIN_ID'];
} else {
$delimiterPos = strpos($arElement['XML_ID'], '#');
if (strlen($arFields['ORIGINATOR_ID']) > 0) {
if ($delimiterPos !== false) {
$arElement['XML_ID'] = $arFields['ORIGINATOR_ID'] . substr($arElement['XML_ID'], $delimiterPos);
} else {
$arElement['XML_ID'] = $arFields['ORIGINATOR_ID'];
}
} else {
if ($delimiterPos !== false) {
$arElement['XML_ID'] = substr($arElement['XML_ID'], 0, $delimiterPos) . $arFields['ORIGIN_ID'];
} else {
$arElement['XML_ID'] = '#' . $arFields['ORIGINATOR_ID'];
}
}
}
}
}
if (isset($arFields['PROPERTY_VALUES'])) {
$arElement['PROPERTY_VALUES'] = $arFields['PROPERTY_VALUES'];
}
if (!$element->Update($ID, $arElement)) {
self::$LAST_ERROR = $element->LAST_ERROR;
return false;
}
}
}
// update VAT
$CCatalogProduct = new CCatalogProduct();
$arCatalogProductFields = array();
if (isset($arFields['VAT_INCLUDED'])) {
$arCatalogProductFields['VAT_INCLUDED'] = $arFields['VAT_INCLUDED'];
}
if (isset($arFields['VAT_ID']) && !empty($arFields['VAT_ID'])) {
$arCatalogProductFields['VAT_ID'] = $arFields['VAT_ID'];
}
if (isset($arFields['MEASURE']) && !empty($arFields['MEASURE'])) {
$arCatalogProductFields['MEASURE'] = $arFields['MEASURE'];
}
if (count($arCatalogProductFields) > 0) {
$CCatalogProduct->Update($ID, $arCatalogProductFields);
}
if (isset($arFields['PRICE']) && isset($arFields['CURRENCY_ID'])) {
self::setPrice($ID, $arFields['PRICE'], $arFields['CURRENCY_ID']);
} else {
if (isset($arFields['PRICE']) || isset($arFields['CURRENCY_ID'])) {
$CPrice = new CPrice();
//.........这里部分代码省略.........
示例2: ShowError
return;
}
if (!\Bitrix\Main\Loader::includeModule("sale")) {
ShowError('Module sale is not loaded');
return;
}
// check fields
if (!empty($_REQUEST['productid'])) {
$productid = (int) $_REQUEST['productid'];
}
if (empty($productid)) {
ShowError('$_REQUEST["productid"] is empty');
return;
}
// get product name
$arProduct = CIBlockElement::GetById($productid)->Fetch();
if (!$arProduct) {
ShowError('$arProduct is empty');
true;
}
// get product price
$arPrice = CCatalogProduct::GetOptimalPrice($arProduct['ID'], 1, $USER->GetUserGroupArray());
if (empty($arPrice['PRICE']['PRICE'])) {
ShowError('$arPrice["PRICE"]["PRICE"] is empty');
}
// add product to basket
$arBasket = array('PRODUCT_ID' => $arProduct['ID'], 'PRODUCT_PRICE_ID' => $arPrice['PRICE']['ID'], 'PRICE' => $arPrice['PRICE']['PRICE'], 'CURRENCY' => $arPrice['PRICE']['CURRENCY'], 'LID' => $arProduct['LID'], 'DELAY' => 'Y', 'NAME' => $arProduct['NAME']);
$result = CSaleBasket::Add($arBasket);
// answer to ajax
echo (int) $result;
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
示例3: GetMessage
?>
<br /> -->
<?endif?>
<!-- <strong><?php
echo GetMessage('SPOL_BASKET');
?>
:</strong> -->
<table style="width: 100%">
<?foreach ($order["BASKET_ITEMS"] as $item): ?>
<?
$product = CCatalogSku::GetProductInfo($item['PRODUCT_ID']);
if (false === $product) {
$element = CIBlockElement::GetById($item['PRODUCT_ID'])->Fetch();
} else {
$element = CIBlockElement::GetById($product['ID'])->Fetch();
}
$item['DETAIL_PAGE_URL'] = '/butik/' . $element['CODE'] .'/';
$item['PREVIEW_PICTURE'] = CFile::ResizeImageGet($element['PREVIEW_PICTURE'], array('width' => 100, 'height' => 100));
?>
<tr>
<td style="width: 30%">
<a href="<?php
echo $item["DETAIL_PAGE_URL"];
?>
" target="_blank">
<img src="<?php
echo $item['PREVIEW_PICTURE']['src'];
?>
">
</a>
示例4: getImage
/**
* Возвращает путь до картинки
*/
function getImage($arProperty)
{
$current = self::getCurrent($arProperty);
$image = null;
$p = strtoupper($arProperty['USER_TYPE_SETTINGS']['PROPERTY_NAME']);
$link = strtoupper($arProperty['USER_TYPE_SETTINGS']['PROPERTY_LINK']);
if ($link && !empty($current[$link])) {
//узнаем инфоблок привязанного свойства
if ($link === 'IBLOCK_SECTION_ID') {
$res = \CIBlockSection::GetById($current[$link]);
if ($ob = $res->Fetch()) {
$image = isset($ob[$p]) ? $ob[$p] : null;
}
} else {
$res = \CIBlockElement::GetById($current[$link]);
if ($ob = $res->Fetch()) {
if (strpos($p, 'PROPERTY_') === 0) {
$pres = \CIBlockElement::GetProperty($ob['IBLOCK_ID'], $ob['ID'], [], ['CODE' => substr($p, 9)]);
if ($pob = $pres->Fetch()) {
$image = $pob['VALUE'];
}
} else {
$image = isset($ob[$p]) ? $ob[$p] : null;
}
}
}
} elseif (!empty($current[$p])) {
$image = $current[$p];
}
if ($image && is_numeric($image)) {
$image = \CFile::GetPath($image);
}
return $image;
}
示例5: array
<?php
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$req = $_REQUEST;
CModule::IncludeModule("sale");
CModule::IncludeModule("iblock");
//_show_array($req);
if (!empty($req['id']) && !empty($req['width']) && !empty($req['height']) && !empty($req['quantity']) && !empty($req['price'])) {
$rsProd = CIBlockElement::GetById($req['id']);
if ($arProd = $rsProd->Fetch()) {
$arFields = array("PRODUCT_ID" => $arProd['ID'], "PRICE" => $req['price'], "CURRENCY" => "RUB", "WEIGHT" => !empty($req['weight']) && $req['weight'] != '' ? $req['weight'] : 'Нет', "QUANTITY" => $req['quantity'], "LID" => LANG, "DELAY" => "N", "CAN_BUY" => "Y", "NAME" => $arProd['NAME']);
$arProps = array();
$arProps[] = array("NAME" => "Объем", "CODE" => "VOLUME", "VALUE" => !empty($req['volume']) && $req['volume'] != '' ? $req['volume'] : 'Нет');
$arProps[] = array("NAME" => "Цвет", "CODE" => "COLOR", "VALUE" => !empty($req['color']) && $req['color'] != '' ? $req['color'] : 'Нет');
$arProps[] = array("NAME" => "Ширина", "CODE" => "WIDTH", "VALUE" => $req['width'] . ' мм');
$arProps[] = array("NAME" => "Высота", "CODE" => "HEIGHT", "VALUE" => $req['height'] . ' мм');
$arFields["PROPS"] = $arProps;
// _show_array($arFields);
$basketId = CSaleBasket::Add($arFields);
}
}
//!empty($basketId) ? _show_array(CSaleBasket::GetById($basketId)) : _show_array('А вот хрен тебе! :Р');