magentomagento2magento2.4

Create Widget Using Page Builder In Magento2


I already created a widget and it's working fine. But there is no option to add widgets using page builder. What should I do?

Thanks


Solution

  • You have a couple of options. The simplest is using the Text content type to include the widget using the standard TinyMCE widget feature.

    Your other option is to create a new content type that wraps your widget in a Page Builder content type. Our Products content type does exactly this, it's just an interface for the Catalog Product List widget.

    products.xml contains a mass converter to create the widget directive:

    view/adminhtml/pagebuilder/content_type/products.xml

    <converters>
        <converter component="Magento_PageBuilder/js/content-type/products/mass-converter/widget-directive" name="widget_directive">
            <config>
                <item name="html_variable" value="html"/>
            </config>
        </converter>
    </converters>
    

    You can refer to the detailed answer here.