%ses-brand uses own fields to store ecommerce related data, e.g for the catalog or basket.
The shop provides a flexible way to store data using concrete instances of classes implementing the FieldInterface
and inheriting from the AbstractField
class. Fields are used for fixed attributes of a product/catalog and flexible attributes (property "dataMap
" in CatalogElement
).
Each instance of a concrete Field will provide the following methods:
Method | Description |
---|---|
getTypeIdentifier() | Returns the identifier of the Field (e.g. "sesimage") |
isSearchable() | Returns true, if the Field is searchable |
isEmptyValue() | Returns true, if the value of the Field is empty |
getEmptyValue() | Returns an empty version of the Field |
toHash() | Returns a associative array (hash) from the Field |
fromHash($hash) | Returns a created instance of the Field by associative array (hash) |
toString() | Returns the value of the Field as string |
All AbstractField objects can be serialized, if you are using the methods toHash() and fromHash() before/after (un)serialize method.
|
Type | Used for | identifier |
---|---|---|
TextLineField | A simple String without HTML-Code | sestextline |
TextBlockField | A rich text field containing HTML code | sestextblock |
ImageField | An image contains a path to an image and an alternative text | sesimage |
ArrayField | A structured array | sesarray |
PriceField | An instance of the Price class | sesprice |
For each concrete Field
a templates has to be provided in order to render the Field
in the template.
The templates have to be provided in the folder FieldTypes
. The name of the template has to start with the identifier of the Field
, e.g.
ImageField.html.twig
TextBlockField.html.twig
TextLineField.html.twig
PriceField.html.twig
The renderer provides a parameter $field
providing the object of the given field.
Call from a twig template, via ses_render_field:
{{ ses_render_field(catalogElement, 'longDescription')|raw }} |