cancel
Showing results for 
Search instead for 
Did you mean: 

How to add custom filter in Magento2

How to add custom filter in Magento2

Hello Everyone

 

I am new in Magento and currently working with magento version 2.0.7, My requirement is I want to add filter on Homepage.

I need to create my custom attribute programatically. But Now I am trying directly by adding attribute from admin section of Magento for product. I have created attribute with Dropdown and added options then it shows "option value" as "id" and "label" as "name" in selectbox.
My requirement is bit different. What I need is, 
value should be string and label also. So In this case can we create a filter ? (I don't want drop-down compulsory, you can suggest me anything that works or suites to my requirement)

For eg. I have Companies - Nokia, Samsung, Apple - Those Are coming from database (Pre-added) with id and value hence it is working in filter.

But I also want Models for those companies for eg. iphone7 for Apple, J7 for Samsung - Which will be entered by user, And I want to create filter for those models.

Models can be different so in this case can we add filter of varchar or text ?

 

Please help me to resolve this issue.

 

Thank you all in advanced!

- Prashant