foreach ($measures as $measure) { $measureListItems[$measure['ID']] = $measure['SYMBOL']; } unset($measure); } unset($measures); $productID = isset($arParams['PRODUCT_ID']) ? intval($arParams['PRODUCT_ID']) : 0; if ($productID <= 0) { $productIDParName = isset($arParams['PRODUCT_ID_PAR_NAME']) ? strval($arParams['PRODUCT_ID_PAR_NAME']) : ''; if (strlen($productIDParName) == 0) { $productIDParName = 'product_id'; } $productID = isset($_REQUEST[$productIDParName]) ? intval($_REQUEST[$productIDParName]) : 0; } $arResult['PRODUCT_ID'] = $productID; $product = $productID > 0 ? CCrmProduct::GetByID($productID, true) : false; $arResult['CATALOG_ID'] = $catalogID = isset($product['CATALOG_ID']) ? intval($product['CATALOG_ID']) : CCrmCatalog::EnsureDefaultExists(); if (!$product) { ShowError(GetMessage('CRM_PRODUCT_NOT_FOUND')); @define('ERROR_404', 'Y'); if ($arParams['SET_STATUS_404'] === 'Y') { CHTTP::SetStatus("404 Not Found"); } return; } // Product properties $arPropUserTypeList = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'view'); $arResult['PROP_USER_TYPES'] = $arPropUserTypeList; $arProps = CCrmProductPropsHelper::GetProps($catalogID, $arPropUserTypeList); $arResult['PROPS'] = $arProps; $arResult['PRODUCT'] = $product;
private static function GetProductNameByID($ID) { $prod = CCrmProduct::GetByID($ID); return is_array($prod) && isset($prod['NAME']) ? $prod['NAME'] : '[' . $ID . ']'; }
LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_PRODUCT_LIST'], array('section_id' => isset($arResult['LIST_SECTION_ID']) ? $arResult['LIST_SECTION_ID'] : 0))); } } } } $productID = isset($arParams['PRODUCT_ID']) ? intval($arParams['PRODUCT_ID']) : 0; if ($productID <= 0) { $productIDParName = isset($arParams['PRODUCT_ID_PAR_NAME']) ? strval($arParams['PRODUCT_ID_PAR_NAME']) : ''; if (strlen($productIDParName) == 0) { $productIDParName = 'product_id'; } $productID = isset($_REQUEST[$productIDParName]) ? intval($_REQUEST[$productIDParName]) : 0; } $product = array(); if ($productID > 0) { if (!($product = CCrmProduct::GetByID($productID, true))) { ShowError(GetMessage('CRM_PRODUCT_NOT_FOUND')); @define('ERROR_404', 'Y'); if ($arParams['SET_STATUS_404'] === 'Y') { CHTTP::SetStatus('404 Not Found'); } return; } } if (isset($productFields['NAME'])) { $product['NAME'] = $productFields['NAME']; } if (isset($productFields['DESCRIPTION'])) { $product['~DESCRIPTION'] = $productFields['DESCRIPTION']; $product['DESCRIPTION'] = htmlspecialcharsbx($productFields['DESCRIPTION']); }
public static function processEvent(array $arParams, array $arHandler) { $eventName = $arHandler['EVENT_NAME']; switch (strtolower($eventName)) { case 'oncrmproductadd': case 'oncrmproductupdate': $ID = isset($arParams[0]) ? (int) $arParams[0] : 0; if ($ID <= 0) { throw new RestException("Could not find entity ID in fields of event \"{$eventName}\""); } $fields = CCrmProduct::GetByID($ID); $catalogID = is_array($fields) && isset($fields['CATALOG_ID']) ? (int) $fields['CATALOG_ID'] : 0; if ($catalogID !== CCrmCatalog::GetDefaultID()) { throw new RestException("Outside CRM product event is detected"); } return array('FIELDS' => array('ID' => $ID)); break; case 'oncrmproductdelete': $fields = isset($arParams[0]) && is_array($arParams[0]) ? $arParams[0] : array(); $ID = isset($fields['ID']) ? (int) $fields['ID'] : 0; if ($ID <= 0) { throw new RestException("Could not find entity ID in fields of event \"{$eventName}\""); } $catalogID = isset($fields['IBLOCK_ID']) ? (int) $fields['IBLOCK_ID'] : 0; if ($catalogID !== CCrmCatalog::GetDefaultID()) { throw new RestException("Outside CRM product event is detected"); } return array('FIELDS' => array('ID' => $ID)); break; default: throw new RestException("The Event \"{$eventName}\" is not supported in current context"); } }