cancel
Showing results for 
Search instead for 
Did you mean: 

Correct way to customize a widget?

SOLVED

Correct way to customize a widget?

Right now, there is the Magento widget of “Catalog Product List”, and template of “Product Grid Template”. This widget allows for me to set conditions of attribute and category to select products I want to display. On the front end it Shows the image, Price, Add to cart, and rating. I want to change what is shown on the front end based of the Attribute set and also display it in more of a list/table style.

 

For example

Attribute Set 1 has Attributes of 1,2,3,4

Attribute Set 2 has Attributes of 3,5,6,7

 

 

In one instance of the widget I want to display products from Attribute Set 1 with this widget but only wish to show the data in the list of SKU, Attribute 1, Attribute 3, Attribute 4 and a Button with link to the product page.

 

The next instance of the widget I want to display Attribute set 2 Items that are also only within category “X”. But when listing Items from Attribute set 2 I only want to show the data in the list of SKU, Attribute 5, Attribute 6 and a Button with link to the product page

 

 

The data being display for each attribute set won't change, from one widget instance to the next. Attribute set 2 will always only display SKU, Attribute 5, Attribute 6 and a Button with link to the product page.. I don't want to select each attribute that is displayed every time I create an instance of this widget. 

 

Can this be achieved by creating a new template file and placing it in my theme, or would I need to create a custom module with my own widget and widget theme file? Am I able to use If statements within the theme file to adjust what displays based on the Attribute set of the product? If I have to create my own module can I extend off the product list widget to change what product information is pulled from the database based on attribute set select when creating the instance of the widget on a cms page in the admin panel? 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Correct way to customize a widget?

Hello @Intwire

 

You can do two way

1) After insert widget into page edit that template file name manually for each attribute set wise.

2) Create module and extend default magento widget 

 

I think 1 one easy solution for you.

 

Hope it will help you.

 

If it will work then mark as solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

2 REPLIES 2

Re: Correct way to customize a widget?

Hello @Intwire

 

You can do two way

1) After insert widget into page edit that template file name manually for each attribute set wise.

2) Create module and extend default magento widget 

 

I think 1 one easy solution for you.

 

Hope it will help you.

 

If it will work then mark as solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Correct way to customize a widget?

 

No more questions at this time, Thanks for the help I am trying out option 1 right now. 

 

thanks