- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/lib/component/base.php
- Класс: BitrixIblockComponentBase
- Вызов: Base::getBestSellersFilter
protected function getBestSellersFilter()
{
$filter = array();
if (!empty($this->arParams['FILTER']))
{
$filter = array('=LID' => $this->getSiteId());
$subFilter = array('LOGIC' => 'OR');
$statuses = array(
'CANCELED' => true,
'ALLOW_DELIVERY' => true,
'PAYED' => true,
'DEDUCTED' => true
);
if ($this->arParams['PERIOD'] > 0)
{
$date = ConvertTimeStamp(AddToTimeStamp(array('DD' => '-'.$this->arParams['PERIOD'])));
if (!empty($date))
{
foreach ($this->arParams['FILTER'] as $field)
{
if (isset($statuses[$field]))
{
$subFilter[] = array(
'>=DATE_'.$field => $date,
'='.$field => 'Y'
);
}
else
{
if (empty($this->storage['ORDER_STATUS']) || in_array($field, $this->storage['ORDER_STATUS']))
{
$subFilter[] = array(
'=STATUS_ID' => $field,
'>=DATE_UPDATE' => $date,
);
}
}
}
unset($field);
}
}
else
{
foreach ($this->arParams['FILTER'] as $field)
{
if (isset($statuses[$field]))
{
$subFilter[] = array(
'='.$field => 'Y'
);
}
else
{
if (empty($this->storage['ORDER_STATUS']) || in_array($field, $this->storage['ORDER_STATUS']))
{
$subFilter[] = array(
'=STATUS_ID' => $field,
);
}
}
}
unset($field);
}
$filter[] = $subFilter;
}
return $filter;
}