From 288193475b7ea4310cc5da9a3d8ce36deebbb082 Mon Sep 17 00:00:00 2001 From: Richard BAYET Date: Wed, 16 Oct 2019 18:24:46 +0200 Subject: [PATCH] Fixes #1583 deleting optimizer w/query limitation from grid with FPC active. Minor cosmetic changes on the read handler. --- .../Model/Optimizer/Limitation/Identities.php | 2 +- .../Optimizer/Limitation/ReadHandler.php | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/Identities.php b/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/Identities.php index e9453e667..fcada3f3f 100644 --- a/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/Identities.php +++ b/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/Identities.php @@ -112,7 +112,7 @@ private function getSearchQueryIdentities() if (!empty($data['quick_search_container']['query_ids'])) { foreach ($data['quick_search_container']['query_ids'] as $query) { - $queryIds[] = $query['id']; + $queryIds[] = $query['id'] ?? $query; } } diff --git a/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/ReadHandler.php b/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/ReadHandler.php index b28a622b3..860b8fe79 100644 --- a/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/ReadHandler.php +++ b/src/module-elasticsuite-catalog-optimizer/Model/Optimizer/Limitation/ReadHandler.php @@ -47,22 +47,22 @@ public function execute($entity, $arguments = []) { if ($entity->getId()) { $searchContainers = $entity->getResource()->getSearchContainersFromOptimizerId($entity->getId()); - $this->getCategoryLimitation($entity, $searchContainers); - $this->getSearchQueryLimitation($entity, $searchContainers); + $this->setCategoryLimitation($entity, $searchContainers); + $this->setSearchQueryLimitation($entity, $searchContainers); } return $entity; } /** - * Retrieve category ids limitation for the current optimizer, if any. + * Retrieve and set category ids limitation for the current optimizer, if any. * - * @param OptimizerInterface $entity The optimizer being saved + * @param OptimizerInterface $entity The optimizer being read * @param array $searchContainers Search Containers data for the current optimizer. * - * @return array + * @return void */ - private function getCategoryLimitation($entity, $searchContainers) + private function setCategoryLimitation($entity, $searchContainers) { $applyTo = (bool) ($searchContainers['catalog_view_container'] ?? false); @@ -77,14 +77,14 @@ private function getCategoryLimitation($entity, $searchContainers) } /** - * Retrieve query ids limitation for the current optimizer, if any. + * Retrieve and set query ids limitation for the current optimizer, if any. * - * @param OptimizerInterface $entity The optimizer being saved + * @param OptimizerInterface $entity The optimizer being read * @param array $searchContainers Search Containers data for the current optimizer. * - * @return array + * @return void */ - private function getSearchQueryLimitation($entity, $searchContainers) + private function setSearchQueryLimitation($entity, $searchContainers) { $applyTo = (bool) ($searchContainers['quick_search_container'] ?? ($searchContainers['catalog_product_autocomplete'] ?? false)); @@ -97,7 +97,5 @@ private function getSearchQueryLimitation($entity, $searchContainers) } $entity->setData('quick_search_container', $containerData); } - - return $entity; } }