Overwrite a core element by adding a new defaultConfig field

I will do an example with the product listing cms and add a new field name is hungMac.

In my plugin, I will create an index.js file at src/Resources/app/administration/src/module/sw-cms/elements/product-listing/index.js

const cmsElements = Shopware.Service('cmsService').getCmsElementRegistry();

// Get the cms element of product-listing cms
const cmsElProductListing = cmsElements['product-listing'];

// Check the field named HungMac does not exist yet
if (!cmsElProductListing.defaultConfig.hungMac) {
    cmsElProductListing.defaultConfig = {
        hungMac: {
            source: 'static',
            value: 'this is my data'

Note: after adding, you should remove the old element in your layout and then add it again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Shopware & Symfony developer
Danang, Vietnam

Social Media