fix: remove products from search if vacationMode (#746)
This commit is contained in:
parent
030eb6c805
commit
11cfd01872
2 changed files with 14 additions and 0 deletions
|
|
@ -309,6 +309,9 @@ class Meilisearch
|
||||||
if ($product === null) {
|
if ($product === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if ($product->getOwner()->isInVacation()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// enrich with the distance to the geoPoint if it is available
|
// enrich with the distance to the geoPoint if it is available
|
||||||
if (\array_key_exists('_geoDistance', $hit)) {
|
if (\array_key_exists('_geoDistance', $hit)) {
|
||||||
|
|
|
||||||
|
|
@ -64,5 +64,16 @@ final class IndexProductsCommandTest extends KernelTestCase
|
||||||
$searchDto->q = 'jumeles';
|
$searchDto->q = 'jumeles';
|
||||||
$results = $meilisearch->search($searchDto);
|
$results = $meilisearch->search($searchDto);
|
||||||
self::assertSame(1, $results->getHitsCount());
|
self::assertSame(1, $results->getHitsCount());
|
||||||
|
|
||||||
|
// test vacation
|
||||||
|
|
||||||
|
$searchDto->user = null;
|
||||||
|
$searchDto->q = '';
|
||||||
|
$user16 = $this->getUserRepository()->get(TestReference::USER_16);
|
||||||
|
$user16->setVacationMode(true);
|
||||||
|
$this->getUserManager()->save($user16);
|
||||||
|
$results = $meilisearch->search($searchDto);
|
||||||
|
// two objects are now hidden
|
||||||
|
self::assertSame(TestReference::PRODUCTS_VISIBLE_COUNT - 3, $results->getHitsCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue