diff --git a/lib/Byng/Pimcore/Elasticsearch/Processor/Element/SelectElementProcessor.php b/lib/Byng/Pimcore/Elasticsearch/Processor/Element/SelectElementProcessor.php index 44946ea..810ccb7 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Processor/Element/SelectElementProcessor.php +++ b/lib/Byng/Pimcore/Elasticsearch/Processor/Element/SelectElementProcessor.php @@ -16,6 +16,8 @@ use Pimcore\Model\Document\Tag\Multiselect; use Pimcore\Model\Document\Tag\Select; use Pimcore\Model\Document\Tag\Input; +use Byng\Pimcore\Elasticsearch\Filter\FilterInterface; +use Pimcore\Model\Object\AbstractObject; /** * Select Element Processor @@ -25,6 +27,11 @@ */ final class SelectElementProcessor { + /** + * @var FilterInterface + */ + protected $filter; + /** * @var InputElementProcessor */ @@ -34,10 +41,12 @@ final class SelectElementProcessor /** * Constructor * + * @param FilterInterface $filter * @param InputElementProcessor $fallbackProcessor */ - public function __construct(InputElementProcessor $fallbackProcessor) + public function __construct(FilterInterface $filter, InputElementProcessor $fallbackProcessor) { + $this->filter = $filter; $this->fallbackProcessor = $fallbackProcessor; } @@ -57,9 +66,22 @@ public function processElement( ) { $elementData = trim($select->getData()); + if ( + is_numeric(($elementData = trim($elementData))) + && ($object = AbstractObject::getById($elementData)) instanceof AbstractObject + ) { + $rawElementData = $object->getKey(); + + $body[$key] = [ + $elementData, + $this->filter->filter($rawElementData) + ]; + + return ($body[$key . '-collated'] = $rawElementData); + } + $input = new Input(); $input->text = $elementData; - return $body[$key] = $this->fallbackProcessor->processElement($input); } diff --git a/lib/Byng/Pimcore/Elasticsearch/Processor/Page/PageProcessorFactory.php b/lib/Byng/Pimcore/Elasticsearch/Processor/Page/PageProcessorFactory.php index f5e7b8a..87681d7 100644 --- a/lib/Byng/Pimcore/Elasticsearch/Processor/Page/PageProcessorFactory.php +++ b/lib/Byng/Pimcore/Elasticsearch/Processor/Page/PageProcessorFactory.php @@ -43,7 +43,7 @@ public function build(FilterInterface $filter = null) return new PageProcessor( $elementProcessor, new DateElementProcessor(), - new SelectElementProcessor($inputProcessor), + new SelectElementProcessor($filter, $inputProcessor), $inputProcessor ); }