diff --git a/plugin/src/AlgoliaSync.php b/plugin/src/AlgoliaSync.php index 20b950e..8756c29 100644 --- a/plugin/src/AlgoliaSync.php +++ b/plugin/src/AlgoliaSync.php @@ -133,6 +133,13 @@ private function algoliaData(\Item $item): ?array /** @var Type $type */ $type = $item->getType(); + $config = new Registry($this->renderer->getConfig('root:plugins/system/zooalgolia/renderer/item')->get($application->getGroup() . '.' . $type->identifier . '.algolia')); + $config = $config->get('search', []); + + if (!count($config)) { + return null; + } + $this->categories = $application->getCategoryTree(); $data = [ 'id' => $item->id, @@ -155,9 +162,6 @@ private function algoliaData(\Item $item): ?array $data['url'][$lang] = $this->getItemUrls($item, $lang); }; - - $config = new Registry($this->renderer->getConfig('root:plugins/system/zooalgolia/renderer/item')->get($application->getGroup() . '.' . $type->identifier . '.algolia')); - $config = $config->get('search', []); foreach ($config as $elementConfig) { $element = $item->getElement($elementConfig['element']); @@ -307,6 +311,23 @@ private function elementValueFor(\Element $element, array $params) return $values ? array_shift($values) : null; } + if ($element instanceof \ElementRelatedItemsPro) { + $related_items = $element->getRelatedItems(true); + + $items = []; + + foreach ($related_items as $item) + { + $data = $this->algoliaData($item); + if ($data) { + $items[] = $this->algoliaData(($item)); + } + } + + return $items; + + } + if ($element instanceof \ElementOption) { $values = $element->get('option', []); diff --git a/plugin/zooalgolia.xml b/plugin/zooalgolia.xml index 6ce0fa2..808e970 100644 --- a/plugin/zooalgolia.xml +++ b/plugin/zooalgolia.xml @@ -1,7 +1,7 @@ ZOO - Algolia Integration - 2.0.1 + 2.1.0 October 2021 (C) 2021 Weble Srl GNU GPLv2 or later