Catalog objects are created with
This involves both product and product groups, or any other type of elements that are part of the catalog.
Sometimes projects need to extend this class to provide additional functionality or logic to the catalog elements.
Catalog objects have default properties and a data map with additional fields. This data map is flexible and enables adding new custom properties to objects, such as file objects, arrays of files, images, custom values based on standard values, flags, etc.
The following example shows how to extend
EcontentCatalogFactory to enable adding a video to the product data map.
Step 1: Create a class¶
Create a new class
MyProjectEcontentCatalogFactory that extends
1 2 3 4 5 6
Step 2: Register the class a service¶
services.yml, add the new class that you just created.
If you are not overriding the constructor, it is enough to add only the parameter with the original key and the new class:
Step 3: Create an extraction method¶
Create a new extraction method for the video. For this example, assume that the object has one video and its name is the SKU with the mp4 extension.
Every new element that is added to the catalog element must be placed in its data map.
The catalog element data map supports different Field objects as its elements.
You can find the available Field elements in
This example uses the File Field object and the Symfony finder object to support file system access.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Step 4. Call your method from the data map¶
Add the call to
fillCatalogElementDataMap() method is responsible for generating the data map of the catalog element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Your catalog element now should have a video file in its data map.
You can also add arrays of fields to the data map. In such a case the object will be an
ArrayField, and its contents will be Field objects.
You can have an Array Field with different file fields, text fields or any other kind of defined field.