diff --git a/src/Search/Meilisearch.php b/src/Search/Meilisearch.php index 70be81e..7ed55c3 100755 --- a/src/Search/Meilisearch.php +++ b/src/Search/Meilisearch.php @@ -309,6 +309,9 @@ class Meilisearch if ($product === null) { return null; } + if ($product->getOwner()->isInVacation()) { + return null; + } // enrich with the distance to the geoPoint if it is available if (\array_key_exists('_geoDistance', $hit)) { diff --git a/tests/Integration/Search/Command/IndexProductsCommandTest.php b/tests/Integration/Search/Command/IndexProductsCommandTest.php index f491e67..4d8b49b 100644 --- a/tests/Integration/Search/Command/IndexProductsCommandTest.php +++ b/tests/Integration/Search/Command/IndexProductsCommandTest.php @@ -64,5 +64,16 @@ final class IndexProductsCommandTest extends KernelTestCase $searchDto->q = 'jumeles'; $results = $meilisearch->search($searchDto); 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()); } }