Forums › Forums › OroPlatform › OroPlatform – Programming Questions › Search Engine: Exclude Entity
This topic contains 3 replies, has 2 voices, and was last updated by manuel.distefano 7 years, 9 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- July 13, 2016 at 11:48 pm #34230
Hello folks,
there is any way to exclude some entities from search via configuration?
Tnx
- CreatorTopic
- AuthorReplies
- July 14, 2016 at 12:51 am #34231
Plus, this drive me crazy, i cant get a working search.
I’m running this code in a symfony application, and other call work like a charm.
I get following error
LESS1{"code":500,"message":"Wrong \"from\" statement of the expression. around position 5."}That’s my class
PHP123456789101112131415161718192021222324252627282930313233343536<?phpnamespace Luiss\CrmBundle\Service;/*** Class CrmRequestAlumnusSearchManager* @package Luiss\CrmBundle\Service*/class CrmRequestAlumnusSearchManager extends CrmRequestManager{const ADVANCED_QUERY = "?query=from oro_user";public function __construct($apiUsername, $apiKey, $apiBaseUrl){parent::__construct($apiUsername, $apiKey, $apiBaseUrl);}public function advancedSearch(){$result = null;$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $this->apiBaseUrl . "/latest/search/advanced.json" . $this::ADVANCED_QUERY);curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);curl_setopt($curl, CURLOPT_HTTPHEADER, $this->getHeader());$result = curl_exec($curl);curl_close($curl);return $result;}}July 14, 2016 at 8:02 am #34232Hi,
You can create custom search listener and unset certain entity
PHP123456789101112131415161718<?phpnamespace Custom\Bundle\OroBundle\EventListener;use Oro\Bundle\SearchBundle\Event\SearchMappingCollectEvent;class SearchListener{/*** @param SearchMappingCollectEvent $event*/public function collectEntityMapEvent(SearchMappingCollectEvent $event){$mapConfig = $event->getMappingConfig();unset($mapConfig['OroCRM\Bundle\AccountBundle\Entity\Account']);$event->setMappingConfig($mapConfig);}}services.yml
PHP12345678parameters:custom_oro.listener.search_listener.class: Custom\Bundle\OroBundle\EventListener\SearchListenerservices:custom_oro.listener.search_listener:class: %custom_oro.listener.search_listener.class%tags:- { name: kernel.event_listener, event: oro_search.search_mapping_collect, method: collectEntityMapEvent }July 15, 2016 at 12:01 am #34233Tnx Mike, i will use it for sure.
And i solved the other problem too. I’ts a url encode problem.
- AuthorReplies
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.