Search

Page tree
Skip to end of metadata
Go to start of metadata


Used fields in the frontend

Product list

NoAttribute ProductNodeNote
1catalogElement.name
2catalogElement.sku
3catalogElement.text
4Price from priceengine
5catalogElement.mainImage


Product detailpage

NoAttribute ProductNodeNote
1catalogElement.mainImageThe main image or the imageList might come from the filesystem directly
2catalogElement.imageList
3catalogElement.sku
4catalogElement.unit
4a
catalogElement.packagingUnit
If not present label is hidden
4bCountry of OriginIf not present label is hidden
5catalogElement.text
6catalogElement.shortDescription
7variants
8catalogElement.longDescriptionIf not present tab is hidden
9

catalogElement.manufacturer

catalogElement.manufacturerSku

catalogElement.specification

catalogElement.dataMap.color

This tab contains several attributes from the product. If a attribute is not present it will be not displayed (inc. the label)
10catalogElement.dataMap.video



Template list

The templates for the catalog have to be located in the views/Catalog folder. Depending on the "viewtype" different templates have to be provided (configuration see Templates for catalog):

Path

Description

product.html.twig
catalog.html.twig
productType.html.twig

The templates have access to the catalog node provided by the controller.

URLs will be provided by special methods:

  • SEO URL {{ catalogElement.seoUrl }}
  • Permantent URL {{ catalogElement.permanentUrl }}

Since these URLs contain the prefix defined in the routing table as well the path() function of Twig cannot be used!

eZ Commerce provides a special rendering function for Twig templates and data from the catalog.

Example

{{ ses_render_field(catalogElement, 'longDescription') }}


The renderer uses predefined templates for each Field. The templates are located in the folder "FieldTypes".

Configuration for templates

The configuration for choosing templates is stored in a yml file silver.eshop.yml:

parameters:
  
  silver_eshop.default.catalog_factory.sis_category: createCatalogNode
  silver_eshop.default.catalog_factory.sis_product: createOrderableProductNode

  silver_eshop.default.catalog_template.CatalogNode: Catalog:catalog.html.twig
  silver_eshop.default.catalog_template.OrderableProductNode: Catalog:product.html.twig

Show all attributes of a CatalogElement

To show all available attributes the method getAttributeNames() is given.

{{ catalogElement.attributeNames|json_encode }}


{# returns a JSON (because of Twig filter "json_encode":
{
    "propertyName": {
        "name": "propertyName",
        "fromDataMap": false,
        "hasValue": bool,
        "type": <type>
    },
    ...
    "dataMap": {
        "dataMapAttributeName": {
            "name": "dataMapAttributeName",
            "type": <realisation of FieldInterface>,
            "fromDataMap": true,
            "hasValue": bool
        },
    }
}


Number of loaded products

You can define the number of products that are loaded in one time.

silver.eshop.yml
#will be loaded in the beginning when the page is rendered for the first time
silver_eshop.default.catalog_product_list_limit: 6
#will be loaded dynamic via ajax later on
silver_eshop.default.catalog_product_list_limit_ajax: 3 


  • No labels