Files
kupshop/bundles/KupShop/CatalogElasticBundle/SectionRequest.php
2025-08-02 16:30:27 +02:00

66 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace KupShop\CatalogElasticBundle;
use KupShop\CatalogBundle\BaseFilterParams;
use KupShop\CatalogBundle\CategorySort;
use KupShop\CatalogBundle\Enum\OrderDirection;
use KupShop\CatalogBundle\Enum\ProductOrder;
use KupShop\CatalogBundle\ProductList\DynamicFilterAttributes;
use KupShop\CatalogBundle\View\CategoryRequestHandler;
use KupShop\RestrictionsBundle\Entity\RestrictionsFilterParams;
class SectionRequest
{
public function __construct(
// Filtering
/** @var \FilterParams $filterParams FilterParams with both $baseFilterParams and dynamic & indexed filter (parsed filterData) */
public \FilterParams $filterParams,
/** @var \FilterParams $baseFilterParams categoryId | producerId | campaign | listParameterValueId */
public \FilterParams $baseFilterParams,
public ?RestrictionsFilterParams $restrictionsFilterParams = null,
public DynamicFilterAttributes $dynamicFilterAttributes = new DynamicFilterAttributes(),
// Sorting
/** @var CategorySort|null $categorySort Sorting from category $dbcfg */
public ?CategorySort $categorySort = null,
// Override of default sorting in $categorySort -> $_GET['order']
public ?ProductOrder $orderBy = null,
public OrderDirection $orderDir = OrderDirection::ASC,
// Miscellaneous
public ?\Pager $pager = null,
/**
* @var bool $fetchAllFilters whether to create a query without filters to fetch all available filters in category
* (first request to a non-filtered category)
*/
public bool $fetchAllFilters = false,
) {
}
public function isSearchRequest(): bool
{
$baseFilter = BaseFilterParams::wrap($this->baseFilterParams);
return $baseFilter->getSectionId() === CategoryRequestHandler::SEARCH_CATEGORY_ID;
}
/**
* Tell the "query compiler" to not fetch any products. Useful for wanting to fetch only aggregations.
*/
public function setNoProducts(): void
{
if (!$this->pager) {
$this->pager = new \Pager();
}
$this->pager->setOnPage(-1);
}
}