eZ Commerce 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 "
Each instance of a concrete Field will provide the following methods:
|Returns the identifier of the Field (e.g. "sesimage")|
|Returns true, if the Field is searchable|
|Returns true, if the value of the Field is empty|
|Returns an empty version of the Field|
|Returns a associative array (hash) from the Field|
|Returns a created instance of the Field by associative array (hash)|
|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.
|A simple String without HTML-Code|
|A rich text field containing HTML code|
|An image contains a path to an image and an alternative text|
|A structured array|
|An instance of the Price class|
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
The renderer provides a parameter
$field providing the object of the given field.
Call from a twig template, via ses_render_field:
TextLineFieldis the representative implementation of
AbstractFieldfor a single line of text.
TextLineField can be created using the following data:
TextBlockFieldis the representative implementation of
AbstractFieldfor a multi line text (or DOMDocument).
TextBlockField can be created using the following data:
TextBlockField object can be reliable serialized, such it implements the magic __sleep() and __wakeup() methods.
ImageFieldis the representative implementation of
AbstractFieldfor an image. An image is identified and initiated by a given path and an optional alternative text.
ImageField can be created using the following data:
ArrayFieldis the representative implementation of
AbstractFieldfor a structured array.
ArrayField can be created using the following data:
PriceFieldis the representative implementation of
PriceField can be created using the following data:
Please refer to Rendering for prices to see the possibilities of outputting a PriceField using the
It is also possible to render a priceField with a twig function ses_render_price(). The difference see in the table below:
more general -
renders also other FieldInterface $fields from $catalogElement
like TextBlockField, ImageField, PriceField
renders only PriceField $price