本文整理匯總了PHP中CCatalogProduct::isAvailable方法的典型用法代碼示例。如果您正苦於以下問題:PHP CCatalogProduct::isAvailable方法的具體用法?PHP CCatalogProduct::isAvailable怎麽用?PHP CCatalogProduct::isAvailable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CCatalogProduct
的用法示例。
在下文中一共展示了CCatalogProduct::isAvailable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getProductIds
protected function getProductIds()
{
$ids = array();
if (!empty($this->ajaxItemsIds)) {
$recommendationId = Main\Context::getCurrent()->getRequest()->get('RID');
$ids = $this->ajaxItemsIds;
} else {
$bestsellers = parent::getProductIds();
if (!empty($bestsellers)) {
$recommendationId = 'bestsellers';
$ids = Main\Analytics\Catalog::getProductIdsByOfferIds($bestsellers);
}
if (empty($ids)) {
$recommendationId = 'mostviewed';
$dublicate = array();
// top viewed
$result = CatalogViewedProductTable::getList(array('select' => array('ELEMENT_ID', new Main\Entity\ExpressionField('SUM_HITS', 'SUM(%s)', 'VIEW_COUNT')), 'filter' => array('=SITE_ID' => $this->getSiteId(), '>ELEMENT_ID' => 0), 'order' => array('SUM_HITS' => 'DESC'), 'limit' => $this->arParams['PAGE_ELEMENT_COUNT']));
while ($row = $result->fetch()) {
if (!isset($dublicate[$row['ELEMENT_ID']])) {
$ids[] = $row['ELEMENT_ID'];
}
$dublicate[$row['ELEMENT_ID']] = true;
}
unset($row, $result, $dublicate);
}
}
if (!empty($ids) && $this->arParams['HIDE_NOT_AVAILABLE'] == 'Y') {
$filter = count($ids) > 1000 ? array('ID' => $ids) : array('@ID' => $ids);
$ids = array_fill_keys($ids, true);
$productIterator = CCatalogProduct::GetList(array(), $filter, false, false, array('ID', 'QUANTITY', 'QUANTITY_TRACE', 'CAN_BUY_ZERO'));
while ($product = $productIterator->Fetch()) {
if (isset($ids[$product['ID']]) && !CCatalogProduct::isAvailable($product)) {
unset($ids[$product['ID']]);
}
}
unset($product, $productIterator, $filter);
$ids = array_keys($ids);
}
$ids = array_slice($ids, 0, $this->arParams['PAGE_ELEMENT_COUNT']);
// remember recommendation id
$this->arResult['RID'] = $recommendationId;
return $ids;
}