Why does eZ Commerce offers a NavigationService?
eZ Commerce supports mixing of catalog elements (products) provided by a storage engine and content from CMS eZ Platform. As long as product would be stored in eZ Platform the menu could be build by eZ twig functions and controllers.
Since eZ Commerce offers a flexible way to store products (DataProviders) a universal NavigationService ensures that the dataproviders are used to load the categories for the menu.
How to "inject" a product catalogue?
A product catalogue has to be setup in the backend using a object (product catalog) which introduces the products for the shop (here named as "Product Catalog"). The reason is that product may come from different sources (aka dataproviders).
eZ Commerce navigation supports different scenarios:
The new navigation does not support product catalogs and categories with several locations. If you want to have e.g. the same categories on several places, you would need to copy the content. Products can be assigned to one or more categories.
Navigation is using eZ search in order to fetch the eZ content and a custom search service to fetch to catalog data directly from solr. Every dataprovider must ensure, that the data is indexed in the correct format. These data must be indexed at least.
Additionally every data provider is able to extend the search query before the catalog data is fetched from solr. Read more in the cookbook about it.
The name used for the navigation can be defined by configuration. The parameter "label_fields" contains a list of attribute names (Solr names) which will be taken as name used in the menu. The first attribute which is available will be used.
The navigation elements are sorted by location priority.
The navigation is cached in 2 different ways:
The left menu is cached in the same way.
When a content is modified which belongs to the navigation a contentmodficationhandler will be triggered. Please make sure that a cronjob is activated which refresh the cache if required:
php bin/console silversolutions:cache:refresh --env=prod
When the product catalog is accessible and the navigation is build, for a special ez content type
ses_productcatalog the catalog elements are injected. The object of the type
ses_productcatalog is the root node for the catalog. You can place as many product catalogs (on any level), as you wish.
A new product catalog can be assigned to a content tree in eZ Platform using a special Content Type (ses_productcatalog).
If you are using eZ as dataprovider, you have to place your categories and products directly under your ses_productcatalog and then configure the root_node id, so it points to itself.
If you are using econtent as dataprovider, you just have to configure the root_node it, so it matches the node id of the root element in the sve_object table.
Following fields are defined in the
|Name||Name of the product catalog for the Navigation|
|Root node||Root node of the product catalog in the storage engine|
|Depth||The depth of the product catalog. The navigation will be build using this parameter. A depth of 1 means that there will be just one level starting at "Root node"|
Currently there are two concrete implementations for dataproviders:
Catalog Data CMS eZ
products can be edited in the CMS
good for up to 20.000 products
import of products costs time
customer has no PIM system
and the amount of roducts
Catalog Data eContent
allws more than 1 million products
currently no edit interface in the backend of the CMS
The customer is using a PIM system
or the ERP provides all the product information
Please keep in mind that Navigation is really connected with a lot of different modules in our shop. Be sure to check these out:
If you want to build navigation without product catalog, you need to change the configuration.
If you want to fetch only the content, where the priority is higher than 0, you need to change the configuration.
This is possible if you have an image stored in your eZ content. Then you can additionally store the image in the navigation node and output it in the frontend.
You need to adapt the template to render the image instead of the label. Example:
The sort order can be configured.
For the sorting the priority is used. This is either the priority of the catalog elements (if you are using econtent), or the location priority for eZ.
Please edit the Product catalog in the backend and change the settings for Depth. In prod mode you might have to clear the cache.
The Navigation is using a list of templates which can be overridden if required.
Find recipes in cookbook...
If for some reason the whole catalog should not be visible in the navigation there is a simple way to do that without going into the eZ Backend. We just need to set the parameter below to false.
If you want to change the time that navigation is cached, you can adjust a parameter below to any value you want (in seconds).
The parameter below is an entry root location point for the whole navigation in eZ Backend. Most commonly this value should be set to 2 as it is a location of the content structure.
This parameter is responsible for the main navigation depth. Only until this depth the content from eZ Backend will be fetched. This does not include the product catalog, which has it's own depth specified.
By default only sorting by priority is available. The user can choose to sort ascending or descending
It may happen in the project that some additional content type needs to be fetched and put into navigation like "blog". In this case we need to extend the parameter below:
It can happen in the project that different sections id's are present. In order to fetch them modify parameter
In some projects there is a need to fetch all content types, even if they can priority set to 0. If the parameter below is set to false, then this content will not be fetched:
If you want to modify the name, so different field is displayed as a navigation node label, you should change the parameter below. It has to exist in solr indexed data.
If in project some additional information is necessary to fullfill the requirements then it can be added as additional field. It has to exist in solr indexed data.
Example how to use the navigation helper in order to build a navigation.