- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/helper.php
- Класс: BitrixSaleTradingPlatformHelper
- Вызов: Helper::getProductById
static function getProductById($productId, $quantity, $siteId)
{
$result = array();
if(CModule::IncludeModule('catalog'))
{
//TODO: change to new provider
if ($productProvider = CSaleBasket::GetProductProvider(array(
"MODULE" => "catalog",
"PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider"))
)
{
global $USER;
$bTmpUserCreated = false;
if (!CCatalog::IsUserExists())
{
$bTmpUserCreated = true;
if (isset($USER))
{
$USER_TMP = $USER;
unset($USER);
}
$USER = new CUser();
}
$result = $productProvider::GetProductData(array(
"PRODUCT_ID" => $productId,
"RENEWAL" => "N",
"QUANTITY" => $quantity,
"SITE_ID" => $siteId
));
$result["MODULE"] = "catalog";
$result["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";
$dbIblockElement = CIBlockElement::GetList(array(), array("ID" => $productId), false, false, array('XML_ID', 'IBLOCK_EXTERNAL_ID'));
if($IblockElement = $dbIblockElement->Fetch())
{
if($IblockElement["XML_ID"] <> '')
$result["PRODUCT_XML_ID"] = $IblockElement["XML_ID"];
if($IblockElement["IBLOCK_EXTERNAL_ID"] <> '')
$result["CATALOG_XML_ID"] = $IblockElement["IBLOCK_EXTERNAL_ID"];
}
if ($bTmpUserCreated)
{
unset($USER);
if (isset($USER_TMP))
{
$USER = $USER_TMP;
unset($USER_TMP);
}
}
}
}
else
{
throw new BitrixMainSystemException("Can't include module "Catalog"!");
}
return $result;
}