2017 © Pedro Peláez
 

library google-custom-search

Implements Google Search into the Spryker Suite

image

fond-of-spryker/google-custom-search

Implements Google Search into the Spryker Suite

  • Monday, July 23, 2018
  • by DerCalli
  • Repository
  • 2 Watchers
  • 0 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

fond-of-spryker/google-custom-search

license, (*1)

Implements Google Search into the Spryker Suite, (*2)

Install

composer require fond-of-spryker/google-custom-search

Configuration

First, you should complete the configuration of the Google API in your configuration, e.g. under config/shared/config_default.php, (*3)

$config[GoogleCustomSearchConstants::API_KEY] = 'YOUR_API_KEY';
$config[GoogleCustomSearchConstants::CX_KEY] = 'SEARCH_ENGINE_KEY';
$config[GoogleCustomSearchConstants::CONFIG_TIMEOUT] = 5.0;
$config[GoogleCustomSearchConstants::RESULT_ITEMS_PER_PAGE] = 10;

For more information, see the official documentation at https://developers.google.com/custom-search/json-api/v1/overview, (*4)

You can add different CX_KEYs for locales by extending the key with the locale, in example:, (*5)

$config[GoogleCustomSearchConstants::CX_KEY . '_fr_FR']

Dont forget the underscore between the key and locale!, (*6)

The default route for search is localed with /de, you change this in the GoogleCustomSearchControllerProvider. If you dont need any localized route just remove the language parameter in URL., (*7)

->value(
    GoogleCustomSearchConstants::ROUTE_SEARCH_URL_VARIABLE,
    '/de/' . GoogleCustomSearchConstants::ROUTE_SEARCH_URL_VARIABLE
);

Add GoogleCustomSearchWidget::class to ShopApplicationDependencyProvider, (*8)

protected function getGlobalWidgets(): array
    {
        return [
            ...
            GoogleCustomSearchWidget::class,
        ];
    }

Add GoogleCustomSearchControllerProviderPlugin to RouterDependencyProvider, (*9)

protected function getRouteProvider(): array
    {
        return [
            ...
            new GoogleCustomSearchControllerProviderPlugin(),
        ];
    }

Render the form

To render the search form use the following code. If you want to change the routes, expand the module as you like using the Spryker workflow, (*10)

{% widget 'GoogleCustomSearchWidget' only %}{% endwidget %}

Results

The search results are displayed under the URL, (*11)

/search (route name google-search-results).

If you need a different route, just expand the module how you like, (*12)

Under /Yves/Theme/default/ search you will find two example templates. Feed free to implement your own., (*13)

Changelog

2.0.0 - added Support for Spryker 202001.0, (*14)

use {% widget 'GoogleCustomSearchWidget' only %}{% endwidget %} instead of {{ render(path('gcs/form')) }}
use new router FondOfSpryker\Yves\GoogleCustomSearch\Plugin\Router\GoogleCustomSearchControllerProviderPlugin instead of FondOfSpryker\Yves\GoogleCustomSearch\Plugin\Provider\GoogleCustomSearchControllerProvider }}

The Versions

23/07 2018

dev-master

9999999-dev

Implements Google Search into the Spryker Suite

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Fischer

23/07 2018

1.1.1

1.1.1.0

Implements Google Search into the Spryker Suite

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Fischer

23/07 2018

1.1

1.1.0.0

n/a

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Fischer

23/07 2018

dev-feature/locales

dev-feature/locales

n/a

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Fischer

10/07 2018

1.0

1.0.0.0

n/a

  Sources   Download

MIT

The Requires

 

The Development Requires

by Pascal Fischer