Add fields to Search widget

I would like to use the Search Widget to search Product/Variants for Attributes. Is there a way to add fields which can then be searched?

This is in version 5.0.4 (Debian 10.3)


Search widged shows all the fields that are included on the treeview. So in order to add your field to the search view you should extend the product variants tree view to include the attributes field.

If you do not want to show the field no the tree view but only include it on the search, you can make it invisible by setting the tree_invisible="1" attribute on your field definition.

Is this to be done in Administration/User Interface/Views ?

I did not see any existing entries there like product.variants

Yes but I realized that the field is included by default on newer versions and probably it won’t be shown correctly on 5.0 series the widget for searching on Dict fields was added on 5.2 series.

So probably the best option is to upgrade your server to latest available series (5.4)

Note that 5.2 is also a valid option, but as it’s support will end the next month I will not recommend using it for now.

Ok, I will look into updating to 5.4

Thank you for your help.

I have updated to version 5.4 but I do not see any entries in Administration/User Interface/Views like product.variants.

Should I create this entry?

Could you provide a simple example of what the information might look like?

You should search product.product instead product.variants

Thanks for that information but unfortunately, that is not enough for me to move forward. Examining the various other views does not give me any clear understanding of how they work or the naming conventions used.

I have been unable to find other documentation as to how the views work.

If you updated to the 5.4 version you should be able to see the Attributes filter on the Product - > Products -> Variants menu

Here is the documentation about views and here the documentation on how to extend a view.

1 Like

Yes, I see “Attribute Set” and “Attributes” in the Search. I can get “Attribute Set” to work but not Attributes.

I will examine the documentation.

Thank you.

Could you explaing what is not working on the Attributes?
Maybe there is some bug that needs to be reported and then fixed.

For testing I
defined two “Product/Attribute Sets/Attributes” like

Name		String		Type
ohm		ohm		Numeric
footprint	footprint	Char

defined one “Product/Attribute Sets” named “resistor” and added the two attributes above to it.

defined one product in “Product/Products” named “PRODUCT_resistor” and
added “resistor” to the “Attribute Set”

added one “Product/Variants” using “PRODUCT_resistor” and set the Attributes on footprint to 0603

Using the Search, if I enter “resistor” in the “Attribute Set” it lists the the variant
if I enter “footprint” or “0603” in “Attributes” it returns nothing.
Maybe that is not the correct format.

Could someone please say if my search criteria is correct or not?

It should match for the attribute value.

Are you using postgresql or sqlite?

I am using postgresql.

“0603” is a value set on “footprint”.

I suppose this type of search works for others so I must have made a mistake somewhere.

Or maybe there is a bug that we should fix it.

For me it should match the footpring value, so there is something wrong.

Thank you for checking.
I will wait for Development to have a closer look.

I think that it is trying to do a comparison between the contents of the attributes column and the value “0603”, and so isn’t finding it, e.g.:

‘{“footprint”:“0603”}’ == ‘0603’

Perhaps the Dict field needs to be added to the list of fields that use the like operator by default?

I think if you type “Attributes.footprint: 0603” in the product variants search bar it should find the product.

Yes, “Attributes.footprint: 0603” works.

Maybe worth noting, I also made a entry for ohm (numeric, 2 places). When I made the entry, it showed as 20.00 (as expected)

But, when I tried searching for it with “Attributes.ohm:20” it did not find it. If I entered as “Attributes.ohm:20.00” it found it. Curiously it also changed the search entry back to “Attributes.ohm:20”

Could I expect this will be addressed in a future version or do I need to open a bug report somewhere?