feat: multiple storage pids for product teasers and search

This commit is contained in:
Björn Fromme
2024-10-23 16:00:38 +02:00
parent 03258262b1
commit 11018fd804
2 changed files with 21 additions and 16 deletions
@@ -101,10 +101,11 @@ class ProductRepository extends AbstractRepository
);
}
if (null !== $filterSettings['productsPid']) {
$qb->andWhere($qb->expr()->eq(
if ($filterSettings['productsPid']) {
$productsPid = $filterSettings['productsPid'];
$qb->andWhere($qb->expr()->in(
'date.product_pid',
$qb->createNamedParameter($filterSettings['productsPid'], Connection::PARAM_INT))
$qb->createNamedParameter($productsPid, Connection::PARAM_INT_ARRAY))
);
}
@@ -144,14 +145,16 @@ class ProductRepository extends AbstractRepository
->addGroupBy('date.nights')
->having('available > 0')
->orderBy('important', 'DESC')
->addOrderBy('new', 'DESC')
->addOrderBy('concept_sorting')
->addOrderBy('date_start')
;
if (null !== $filterSettings['productsPid']) {
$qb->andWhere($qb->expr()->eq(
if ($filterSettings['productsPid']) {
$productsPid = (array) $filterSettings['productsPid'];
$qb->andWhere($qb->expr()->in(
'date.product_pid',
$qb->createNamedParameter($filterSettings['productsPid'], Connection::PARAM_INT))
$qb->createNamedParameter($productsPid, Connection::PARAM_INT_ARRAY))
);
}
@@ -226,10 +229,11 @@ class ProductRepository extends AbstractRepository
)
;
if (null !== $filterSettings['productsPid']) {
$qb->andWhere($qb->expr()->eq(
if ($filterSettings['productsPid']) {
$productsPid = (array) $filterSettings['productsPid'];
$qb->andWhere($qb->expr()->in(
'date.product_pid',
$qb->createNamedParameter($filterSettings['productsPid'], Connection::PARAM_INT))
$qb->createNamedParameter($productsPid, Connection::PARAM_INT_ARRAY))
);
}
@@ -278,10 +282,11 @@ class ProductRepository extends AbstractRepository
->groupBy('date.date_start')
;
if (null !== $filterSettings['productsPid']) {
$qb->andWhere($qb->expr()->eq(
if ($filterSettings['productsPid']) {
$productsPid = (array) $filterSettings['productsPid'];
$qb->andWhere($qb->expr()->in(
'date.product_pid',
$qb->createNamedParameter($filterSettings['productsPid'], Connection::PARAM_INT))
$qb->createNamedParameter($productsPid, Connection::PARAM_INT_ARRAY))
);
}
@@ -20,7 +20,7 @@ class FilterService implements SingletonInterface
{
$optionsResolver = new OptionsResolver();
$optionsResolver->setDefaults([
'productsPid' => null,
'productsPid' => [],
'priceRanges' => [],
'countryUids' => [],
'regionUids' => [],
@@ -37,12 +37,12 @@ class FilterService implements SingletonInterface
'pax' => 0,
'bus' => null,
]);
foreach (['productsPid', 'hotelUid', 'productUid', 'nights', 'pax'] as $key) {
foreach (['hotelUid', 'productUid', 'nights', 'pax'] as $key) {
$optionsResolver->setNormalizer($key, function (Options $options, $value) {
return null !== $value ? (int)$value : null;
});
}
foreach (['priceRanges', 'countryUids', 'regionUids', 'cityUids', 'conceptUids', 'boardTypes', 'hotelTypes', 'roomTypes'] as $key) {
foreach (['productsPid', 'priceRanges', 'countryUids', 'regionUids', 'cityUids', 'conceptUids', 'boardTypes', 'hotelTypes', 'roomTypes'] as $key) {
$optionsResolver->setNormalizer($key, function (Options $options, $value) {
if (empty($value)) {
return [];
@@ -62,7 +62,7 @@ class FilterService implements SingletonInterface
$typoScriptSettings = $this->getTypoScriptSettings();
if (is_array($typoScriptSettings) && isset($typoScriptSettings['productsPid'])) {
$filterSettings['productsPid'] = $typoScriptSettings['productsPid'];
$filterSettings['productsPid'] = GeneralUtility::trimExplode(',', $typoScriptSettings['productsPid'], true);
}
return $filterSettings;