Google Custom Search Engine (Site Search ~ CSE) Integration
Pimcore provides a simple interface to the Google Custom Search Engine which makes it easy to integrate a search engine into your website.
Setup in CSE Control Panel and Google Cloud Console
- Create and configure a new search engine at http://www.google.com/cse/ - for more information please visit: http://support.google.com/customsearch/ .
- Test your search engine first using the preview on the right hand side.
- If your results are as expected, go back to "Setup" (-> left navigation) and note the search engine ID
- You'll need it later in the code (parameter 'cx' in configuration):
- Once you are finished go to https://console.developers.google.com/
create a new project, then search for
Custom Search APIand click on
Custom Search APIshould now be listed under
Enabled APIsin your project overview.
- To get the necessary access keys, click on:
Server keyComplete the setup as described and note the server API key.
So now we got the search engine ID and a server API key which we need to finish the configuration in Pimcore.
Server API Key
Configure the API key in
simple_api_key config in config.yaml as follows:
pimcore: services: google: client_id: 73893596983.apps.googleusercontent.com email: firstname.lastname@example.org simple_api_key: AIzaSyCo9Wj49hYJWW2WgOju4iMYNTvdcBxmyQ8 browser_api_key: AIzaSyBJX16kWAmUVEz1c1amzp2iKqAfumbcoQQ
Search engine ID
The search engine ID is used in your controller/action to configure the search service:
The place of interest (parameter cx) is marked with a comment in the code example below.
Please note: These are examples from old demo application. Please adapt to the latest code style for implementation.
Partial View Script (includes/paging.php)