Adding a Custom Field as Extension

Shopware 6′ custom fields is a very powerful yet easy to use mechanism to customize the standard data model and functionality. Custom fields for an entity are stored in a pre-defined json field with that entity. This mechanism is very flexible, and allows even out-of-the-box translations for custom fields, however it has two major flaws:

First, it creates some inevitable performance overhead. If you need to search that field (say an ERP product id) from a PHP script, be aware that, since it is wrapped in an SQL json field, there is no related database index.

Second, it relies on a pre-defined json field being defined for that entity. If the makers of Shopware decided to leave that off for an entity, that’s it – no custom fields for this entity.

Luckily, there is a simple alternative to custom fields provided in Shopware’s Data Access Layer (DAL) entity extensions. While it needs a litte bit more code than a simple custom field, there is no big magic behind it. Read and learn here how to create additional fields for any entity in Shopware 6.

Continue reading “Adding a Custom Field as Extension”