本文整理汇总了PHP中CCatalogSKU::getInfoByIblock方法的典型用法代码示例。如果您正苦于以下问题:PHP CCatalogSKU::getInfoByIblock方法的具体用法?PHP CCatalogSKU::getInfoByIblock怎么用?PHP CCatalogSKU::getInfoByIblock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCatalogSKU
的用法示例。
在下文中一共展示了CCatalogSKU::getInfoByIblock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProductToBasket
/**
* Process Puy Product.
*
* @param int $productID
* @param float $quantity
* @param array $values
* @param array $arRewriteFields
* @throws void|Bitrix\Main\SystemException
*/
protected function addProductToBasket($productID, $quantity, $values = array(), $arRewriteFields = array())
{
$productProperties = array();
$productID = (int) $productID;
$intProductIBlockID = (int) CIBlockElement::GetIBlockByID($productID);
if ($intProductIBlockID > 0) {
$productCatalogInfo = CCatalogSKU::getInfoByIblock($intProductIBlockID);
$isOffer = CCatalogSKU::TYPE_OFFERS == $productCatalogInfo['CATALOG_TYPE'];
if ($this->arParams['ADD_PROPERTIES_TO_BASKET'] == 'Y') {
// Is not offer
if (!$isOffer) {
// Props not empty
if (!empty($this->arParams['CART_PROPERTIES'][$intProductIBlockID])) {
$productProperties = CIBlockPriceTools::CheckProductProperties($intProductIBlockID, $productID, $this->arParams['CART_PROPERTIES'][$intProductIBlockID], $values, $this->arParams['PARTIAL_PRODUCT_PROPERTIES'] == 'Y');
if (!is_array($productProperties)) {
throw new SystemException(Loc::getMessage("CVP_PARTIAL_BASKET_PROPERTIES_ERROR"));
}
}
} else {
if (!empty($this->arParams['CART_PROPERTIES'][$intProductIBlockID])) {
$productProperties = CIBlockPriceTools::GetOfferProperties($productID, $productCatalogInfo['PRODUCT_IBLOCK_ID'], $this->arParams['CART_PROPERTIES'][$intProductIBlockID]);
}
}
}
if (0 >= $quantity) {
$rsRatios = CCatalogMeasureRatio::getList(array(), array('PRODUCT_ID' => $productID), false, false, array('PRODUCT_ID', 'RATIO'));
if ($arRatio = $rsRatios->Fetch()) {
$intRatio = (int) $arRatio['RATIO'];
$dblRatio = (double) $arRatio['RATIO'];
$quantity = $dblRatio > $intRatio ? $dblRatio : $intRatio;
}
}
if (0 >= $quantity) {
$quantity = 1;
}
} else {
throw new SystemException(Loc::getMessage('CVP_CATALOG_PRODUCT_NOT_FOUND') . ".");
}
if (!Add2BasketByProductID($productID, $quantity, $arRewriteFields, $productProperties)) {
throw new SystemException(Loc::getMessage("CVP_CATALOG_ERROR2BASKET") . ".");
}
}