本文整理汇总了PHP中CIBlockElement::getIBlockByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement::getIBlockByID方法的具体用法?PHP CIBlockElement::getIBlockByID怎么用?PHP CIBlockElement::getIBlockByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElement
的用法示例。
在下文中一共展示了CIBlockElement::getIBlockByID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkByShipment
public function checkByShipment(\Bitrix\Sale\Shipment $shipment, array $restrictionParams, $deliveryId = 0)
{
if (!\Bitrix\Main\Loader::includeModule('iblock')) {
return array();
}
if (!\Bitrix\Main\Loader::includeModule('catalog')) {
return array();
}
$productIds = array();
/** @var \Bitrix\Sale\ShipmentItem $shipmentItem */
foreach ($shipment->getShipmentItemCollection() as $shipmentItem) {
/** @var \Bitrix\Sale\BasketItem $basketItem */
$basketItem = $shipmentItem->getBasketItem();
if ($basketItem->getField('MODULE') != 'catalog') {
continue;
}
$productId = intval($basketItem->getField('PRODUCT_ID'));
$iblockId = (int) \CIBlockElement::getIBlockByID($productId);
$info = \CCatalogSKU::getProductInfo($productId, $iblockId);
if (!empty($info['ID'])) {
$candidate = $info['ID'];
} else {
$candidate = $productId;
}
if (!in_array($candidate, $productIds)) {
$productIds[] = $candidate;
}
}
$categoriesIds = self::getGroupsIds($productIds);
return $this->check($categoriesIds, $restrictionParams, $deliveryId);
}
示例2: refresh
/**
* Common function, used to update/insert any product.
*
* @param int $productId Id of product.
* @param int $fuserId User basket id.
* @param string $siteId Site id.
* @param int $elementId Parent id.
* @param string $recommendationId Bigdata recommendation id.
*
* @return int Id of row.
*/
public static function refresh($productId, $fuserId, $siteId = SITE_ID, $elementId = 0, $recommendationId = '')
{
$connection = Application::getConnection();
$productId = (int) $productId;
if ($productId <= 0) {
return -1;
}
$fuserId = (int) $fuserId;
if ($fuserId <= 0) {
return -1;
}
if (!is_string($siteId) || strlen($siteId) <= 0) {
return -1;
}
$filter = array("FUSER_ID" => $fuserId, "SITE_ID" => $siteId);
if ($elementId > 0) {
$filter["ELEMENT_ID"] = $elementId;
// Delete parent product id (for capability)
if ($elementId != $productId) {
$connection->query("DELETE FROM\n\t\t\t\t\t\t\t\t\t\tb_catalog_viewed_product\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tPRODUCT_ID = " . intval($elementId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tFUSER_ID = " . intval($fuserId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tSITE_ID = '" . $connection->getSqlHelper()->forSql($siteId) . "'");
}
} else {
$iblockId = (int) \CIBlockElement::getIBlockByID($productId);
if ($iblockId <= 0) {
return -1;
}
$productInfo = \CCatalogSKU::getProductInfo($productId, $iblockId);
// Concrete SKU ID
if (!empty($productInfo)) {
$filter['PRODUCT_ID'] = array();
$siblings = array();
// Delete parent product id (for capability)
$connection->query("DELETE FROM\n\t\t\t\t\t\t\t\t\t\tb_catalog_viewed_product\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\tPRODUCT_ID = " . intval($productInfo['ID']) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tFUSER_ID = " . intval($fuserId) . "\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\tSITE_ID = '" . $connection->getSqlHelper()->forSql($siteId) . "'");
$skuInfo = \CCatalogSKU::getInfoByOfferIBlock($iblockId);
$skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $iblockId, 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
while ($oneSku = $skus->fetch()) {
$siblings[] = $oneSku['ID'];
}
$filter["PRODUCT_ID"] = $siblings;
} else {
$filter["PRODUCT_ID"] = $productId;
}
}
$iterator = static::getList(array("filter" => $filter, "select" => array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "SITE_ID", "VIEW_COUNT")));
if ($row = $iterator->fetch()) {
static::update($row["ID"], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1, "ELEMENT_ID" => $elementId, "RECOMMENDATION" => $recommendationId));
return $row['ID'];
} else {
$result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), "PRODUCT_ID" => $productId, "ELEMENT_ID" => $elementId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1, "RECOMMENDATION" => $recommendationId));
return $result->getId();
}
}
示例3: refresh
/**
* Common function, used to update/insert any product.
*
* @param int $productId Id of product.
* @param int $fuserId User basket id.
* @param string $siteId Site id.
*
* @return int Id of row.
*/
public static function refresh($productId, $fuserId, $siteId = SITE_ID)
{
$connection = Application::getConnection();
$productId = (int) $productId;
if ($productId <= 0) {
return -1;
}
$iblockID = (int) \CIBlockElement::getIBlockByID($productId);
if ($iblockID <= 0) {
return -1;
}
$productInfo = \CCatalogSKU::getProductInfo($productId, $iblockID);
$fuserId = (int) $fuserId;
if ($fuserId <= 0) {
return -1;
}
if (!is_string($siteId) || strlen($siteId) <= 0) {
return -1;
}
$filter = array("FUSER_ID" => $fuserId, "SITE_ID" => $siteId);
// Concrete SKU ID
if (!empty($productInfo)) {
$filter['PRODUCT_ID'] = array();
$siblings = array();
// Delete parent product id (for capability)
$connection->query("DELETE FROM b_catalog_viewed_product WHERE PRODUCT_ID = {$productInfo['ID']} AND FUSER_ID = {$fuserId} AND SITE_ID = '{$siteId}'");
$skuInfo = \CCatalogSKU::getInfoByOfferIBlock($iblockID);
$skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $iblockID, 'PROPERTY_' . $skuInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
while ($oneSku = $skus->fetch()) {
$siblings[] = $oneSku['ID'];
}
$filter["PRODUCT_ID"] = $siblings;
} else {
$filter["PRODUCT_ID"] = $productId;
}
$iterator = static::getList(array("filter" => $filter, "select" => array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "SITE_ID", "VIEW_COUNT")));
if ($row = $iterator->fetch()) {
static::update($row["ID"], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1));
return $row['ID'];
} else {
$result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new \Bitrix\Main\Type\DateTime(), "PRODUCT_ID" => $productId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1));
return $result->getId();
}
}
示例4: getProductDataToFillBasket
/**
* @param $productId
* @param $quantity
* @param $userId
* @param $LID
* @param $userColumns
* @param string $tmpId we can suggest that this mean the set_item
* @return array
* @throws Main\LoaderException
*/
protected function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
$isSetItem = $tmpId != "";
if (self::$catalogIncluded === null) {
self::$catalogIncluded = Main\Loader::includeModule('catalog');
}
if (!self::$catalogIncluded) {
return array();
}
$arParams = array();
static $proxyIblockElement = array();
static $proxyCatalogMeasure = array();
static $proxyParent = array();
static $proxyIblockProperty = array();
static $proxyProductData = array();
static $proxyCatalogProduct = array();
static $proxyCatalogMeasureRatio = array();
$productId = (int) $productId;
if ($productId <= 0) {
return $arParams;
}
if (!empty($proxyIblockElement[$productId])) {
$iblockId = $proxyIblockElement[$productId];
} else {
$iblockId = (int) \CIBlockElement::getIBlockByID($productId);
if ($iblockId > 0) {
$proxyIblockElement[$productId] = $iblockId;
}
}
if ($iblockId <= 0) {
return $arParams;
}
$arSku2Parent = array();
$arElementId = array();
$arElementId[] = $productId;
$proxyParentKey = $productId . "|" . $iblockId;
if (!empty($proxyParent[$proxyParentKey]) && is_array($proxyParent[$proxyParentKey])) {
$arParent = $proxyParent[$proxyParentKey];
} else {
$arParent = \CCatalogSku::getProductInfo($productId, $iblockId);
$proxyParent[$proxyParentKey] = $arParent;
}
if ($arParent) {
$arElementId[] = $arParent["ID"];
$arSku2Parent[$productId] = $arParent["ID"];
}
$arPropertyInfo = array();
$userColumns = (string) $userColumns;
$arUserColumns = $userColumns != '' ? explode(",", $userColumns) : array();
foreach ($arUserColumns as $key => $column) {
if (strncmp($column, 'PROPERTY_', 9) != 0) {
unset($arUserColumns[$key]);
} else {
$propertyCode = substr($column, 9);
if ($propertyCode == '') {
unset($arUserColumns[$key]);
continue;
}
if (!empty($proxyIblockProperty[$propertyCode]) && is_array($proxyIblockProperty[$propertyCode])) {
$arPropertyInfo[$column] = $proxyIblockProperty[$propertyCode];
} else {
$dbres = \CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
if ($arPropData = $dbres->GetNext()) {
$arPropertyInfo[$column] = $arPropData;
$proxyIblockProperty[$propertyCode] = $arPropData;
}
}
}
}
$arSelect = array_merge(array("ID", "NAME", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "XML_ID", "IBLOCK_XML_ID"), $arUserColumns);
$proxyProductDataKey = md5(join('|', $arElementId) . "_" . join('|', $arSelect));
if (!empty($proxyProductData[$proxyProductDataKey]) && is_array($proxyProductData[$proxyProductDataKey])) {
$arProductData = $proxyProductData[$proxyProductDataKey];
} else {
$arProductData = getProductProps($arElementId, $arSelect);
$proxyProductData[$proxyProductDataKey] = $arProductData;
}
$defaultMeasure = \CCatalogMeasure::getDefaultMeasure(true, true);
if (!empty($arProductData)) {
$arElementInfo = array();
foreach ($arProductData as $elemId => &$arElement) {
foreach ($arElement as $key => $value) {
if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE") {
$columnCode = str_replace("_VALUE", "", $key);
$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
}
}
}
unset($arElement);
if (isset($arProductData[$productId])) {
//.........这里部分代码省略.........