本文整理汇总了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;
}