CustomFields, Properties and Entity Extensions for Shopware 6
When you start working with Shopware 6 it can be hard to know what to use for what. So this guide will explain you the different aspects of CustomFields, Properties and Entity Extensions in Shopware 6. Disclaimer: This definition is maybe not correct in all parts, it is more less a guide to give you a feeling what to use when. Because you can solve same tasks in very different ways and maybe both will work. So feel free to comment when you think something should be changed or written in another way. Let's checkout the differences between CustomFields, Properties and Entity Extensions.
Content
CustomFields
A CustomField is always assigned to a CustomFieldSet. Look at the CustomFieldsSetEntity and the CustomFieldEntity to know what functions are available. See also the official documentation about CustomFields. You can assign CustomFields to your own entities. You can also create CustomFields via code and assign the CustomFields to existing entities. User Documentation: How to create CustomFields via Admin.
Possible CustomField Types (Core)
- Select (SingleSelectField, MultiSelectField)
- Entity (SingleEntitySelectField, MultiEntitySelectField)
- Text (TextField)
- TextEditor (TextAreaField)
- Media (MediaSelectionField)
- Number (IntField, FloatField)
- Date (DateTimeField)
- Checkbox (BoolField)
- Switch (BoolField)
- Colorpicker (ColorPickerField)
- Price (PriceField)
Links to field definitions are only used by the Shopware 6 app system.
But to get an idea what you can do with which field I linked them here.
CustomFields Feature Overview
- CRUD via Admin (Admin > Settings > System > Custom Fields)
- Can also be created, updateded and deleated via Migration.
- Can be hidden and can be set to global (no edit via Admin possible).
- Can be assigned to different entities (Products, Categories, Customers ...).
- Saved in a JSON-Field in the database.
- Can NOT be used for filtering on category page.
- Can NOT be used for associations.
- Can easily be used to display informations in frontend via twig.
Properties
Properties are assigned to Products, to describe the Product or to use them to create Variants. Every PropertyGroupOptionEntity is assigned to a PropertyGroupEntity. Properties can also be used on a Category Page for filtering. You can read more about the concept of Properties in the Shopware 6 Docu. User Documentation: How to create Properties via Admin.
Possible Property display types (Core)
- Image
- Text
- Dropdown
- Colour
Properties Feature Overview
- CRUD via Admin (Admin > Catalouges > Properties)
- Can also be created, updateded and deleated via Migration.
- Used for filtering on category page.
- Used for the creation of variation products.
- The dropdown can be used as single or multi select.
- Can NOT be used for associations (is already an association).
Entity Extensions
In Shopware 6 you can extend every Entity (e.g. Product, Order, Category) and this is also called Entity Extension. There is a really good guide how you can "Adding complex data to existing entities", you have two options to extend entites, with or without a database field. Sometimes it is also useful to extend without a database field for example if you need live data from some other API or when you read data from filesystem. If you need relations between entities and maybe want to filter, search and so on these entities you should choose an Entity Extensions because CustomFields just scalar types (ugly DX for filtering, search and slow with many data).
Entity Extensions Feature
- NO out of the box CRUD via Admin.
- The Entity must be created programmatically.
- The Entity-Table must be created via Migration.
- Can be used for associations.
- For CRUD Actions you need to build your own UserInterface.
- You can use Admin Extension SDK to easy build your UserInterface.
Simple Overview: CustomFields, Properties and Entity Extensions
Maybe I should add some media gallery
You can right click, open the image in new tab, to see it in full width.
---
Something wrong, outdated or missing in this post? Tell me via comment. Thx.