1

I am trying to find way to add additional template into "Catalog products list" widget. I can do this from inside vendor but its not a good practice to do it. How to do this without changing anything on vendor folder. Should i need to build custom module link its mentioned here in article to add new custom widget

https://store.magenest.com/blog/how-to-create-custom-widget-magento-2/

Or is their other way to add additional template to existing widget "Catalog products list"

Right now default template and path can be overide by moving file into this path

<Vendor>/<YourTheme>/Magento_CatalogWidget/templates/product/widget/content/grid.phtml

if i need to add additional template, how will i do this.

1

Ok, i just found the solution after some research, if anyone come it to same situation that will be helpful.

To add new template into "Catalog Products List" You have to make this path in your custom template

app/design/frontend/[Vendor]\[Theme]/etc/widget.xml

and add the following code to override only Additional template section and adding new template into it.

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
*/
-->
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
<widget id="products_list" class="Magento\CatalogWidget\Block\Product\ProductsList" is_email_compatible="true"
        placeholder_image="Magento_CatalogWidget::images/products_list.png" ttl="86400">
    <label translate="true">Catalog Products List</label>
    <description translate="true">List of Products</description>
    <parameters>
        <parameter name="template" xsi:type="select" required="true" visible="true">
            <label translate="true">Template</label>
            <options>
                <option name="default" value="Magento_CatalogWidget::product/widget/content/grid.phtml" selected="true">
                    <label translate="true">Products Grid Templates</label>
                </option>
                <option name="alternative-option" value="Magento_CatalogWidget::product/widget/content/new_option.phtml" selected="true">
                    <label translate="true">Alternative Option Text</label>
                </option>
            </options>
        </parameter>
    </parameters>
   </widget>
</widgets>

and after that go to

/app/design/frontend/Vendor/theme/Magento_CatalogWidget/templates/product/widget/content/new_option.phtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.