Product::listAction

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. Product
  4. listAction
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/product.php
  • Класс: BitrixCatalogControllerProduct
  • Вызов: Product::listAction
public function listAction(PageNavigation $pageNavigation, array $select = [], array $filter = [], array $order = []): ?Page
{
	$r = $this->checkPermissionIBlockElementList($filter['IBLOCK_ID']);
	if($r->isSuccess())
	{
		$result = [];

		$select = empty($select)? array_merge(['*'], $this->getAllowedFieldsProduct()):$select;
		$order = empty($order)? ['ID'=>'ASC']:$order;

		$groupFields = $this->splitFieldsByEntity(
			array_flip($select)
		);
		$allProperties = isset($groupFields['elementFields']['PROPERTY_*']);
		if ($allProperties)
		{
			unset($groupFields['elementFields']['PROPERTY_*']);
		}

		$productFields = array_keys($groupFields['productFields']);
		$elementFields = array_keys($groupFields['elementFields']);
		$propertyFields = $groupFields['propertyFields'];

		$propertyFields = $this->preparePropertyFields($propertyFields);
		$propertyIds = array_keys($propertyFields);
		$list = self::perfGetList(array_merge($productFields, $elementFields), $filter, $order, self::getNavData($pageNavigation->getOffset()));

		if (!empty($list))
		{
			if ($allProperties || !empty($propertyIds))
			{
				$this->attachPropertyValues($list, (int)$filter['IBLOCK_ID'], $propertyIds);
			}

			foreach ($list as $row)
			{
				$result[] = $row;
			}
		}

		return new Page($this->getServiceListName(), $result, function() use ($filter)
		{
			return (int)CIBlockElement::GetList([], $filter, []);
		});
	}
	else
	{
		$this->addErrors($r->getErrors());
		return null;
	}
}

Добавить комментарий