- Модуль: catalog
- Путь к файлу: ~/bitrix/modules/catalog/lib/product/sku.php
- Класс: BitrixCatalogProductSku
- Вызов: Sku::getOfferState
static function getOfferState($productId, $iblockId = 0)
{
$result = self::OFFERS_ERROR;
$productId = (int)$productId;
if ($productId <= 0)
return $result;
$iblockId = (int)$iblockId;
if ($iblockId <= 0)
$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
if ($iblockId <= 0)
return $result;
$result = self::OFFERS_NOT_EXIST;
$offerList = CCatalogSku::getOffersList($productId, $iblockId, array(), array('ID', 'ACTIVE'));
if (!empty($offerList[$productId]))
{
$result = self::OFFERS_NOT_AVAILABLE;
$activeOffers = array_filter($offerList[$productId], 'BitrixCatalogProductSku::filterActive');
if (!empty($activeOffers))
{
$existOffers = CatalogProductTable::getList(array(
'select' => array('ID', 'AVAILABLE'),
'filter' => array('@ID' => array_keys($activeOffers), '=AVAILABLE' => CatalogProductTable::STATUS_YES),
'limit' => 1
))->fetch();
if (!empty($existOffers))
$result = self::OFFERS_AVAILABLE;
unset($existOffers);
}
unset($activeOffers);
}
unset($offerList);
return $result;
}