Download the PHP package bestit/commercetools-filter-bundle without Composer
On this page you can find all versions of the php package bestit/commercetools-filter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bestit/commercetools-filter-bundle
More information about bestit/commercetools-filter-bundle
Files in bestit/commercetools-filter-bundle
Package commercetools-filter-bundle
Short Description Commerce tools filter and search implementation
License MIT
Informations about the package commercetools-filter-bundle
bestit/commercetools-filter-bundle
Add filter and search implementation for commerce tools. It still uses the commmercetools/php-sdk under the hood.
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
Step 3: Configure the Bundle
Minimum configuration (only all required fields)
Maximum configuration (all required and optional fields)
Usage
Listing
Just execute the listing method of the filter manager in your listing controller. It need the Symfony Request object and the current listing category (Commercetools Object) for creating the listing request.
Example:
Search
Just execute the search method of the filter manager in your listing controller. It need the Symfony Request object and the search string for creating the search request.
Example:
Product Normalizer
In most cases, products need to be normalized for the frontend. You can choose one of the base normalizer from filter bundle or use your own if you implement the ProductNormalizerInterface and add the service id to the app config. The filter bundle contains two base normalizer:
- ArrayProductNormalizer: Converts the ProductProjection object to array.
- EmptyProductNormalizer: Just return the ProductProjection without normalization
EmptyProductNormalizer will be use if you don't fill the _product_normalizerid Parameter (@ config.yml).
Term Normalizer
There are cases where you have to normalize facet terms. Commercetools only ships enum keys and categories id for example, which aren't enough for your frontend. This bundle contains two default normalizers:
- CategoryNormalizer: Converts category id's to their real name
- EnumAttributeNormalizer: Converts enum keys to their label
But you can define your own TermNormalizer as well. Just implement the TermNormalizerInterface and add the tag best_it_commercetools_filter.term_normalizer
to your service. Remember to disable the default normalizer in your config.
If you want to skip a term, just throw a SkipTermException
. No further normalizer will be applied and the term will not be shown at frontend.
Config Provider id
You can add you own filter config provider. Just implement the FacetConfigProviderInterface and add your service id to _config_providerid (@ config.yml). The filter bundle default provider will be use if you don't fill the _config_providerid Parameter (@ config.yml), which returns no filters.
Url generator
The filter bundle need to create urls, but the route names can vary between projects. So you can add your own url generator for creating the correct urls with the _url_generatorid parameter. The generator need to implement the FilterUrlGeneratorInterface. The bundle will use his own default generator if you do not fill the field.
Events
Request events
You can modify the commercetools client request with the filter and suggest post events. Check all events @ SuggestEvent and FilterEvent class.
Example usage: Extend request
All versions of commercetools-filter-bundle with dependencies
symfony/symfony Version ^3.1
commercetools/php-sdk Version ^1.2.1 || ^2.0
amstaffix/pagination Version ^1.1@dev