Make attributes and properties "searchable"

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
TobiasMadsen
Posts: 14
Joined: 04 Dec 2020, 09:57

Make attributes and properties "searchable"

Post by TobiasMadsen » 29 Dec 2020, 10:36

Is there any way to make product attributes and more importantly properties searchable?

I would like to show the user all products with at certain attribute = something
I also have a supplier productcode as a propertie, which the user might search for.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: Make attributes and properties "searchable"

Post by aimeos » 30 Dec 2020, 15:09

Attributes and properties are not included in the full text search, it's only for texts but attributes can be filtered by the faceted search by default. The easiest solution is to add the properties you want to search for in an hidden text.

You can also extend the catalog/lists component and overwrite creating the search filter here:
https://github.com/aimeos/ai-client-htm ... #L697-L708

You can use the property() method of the product controller to search for properties too:
https://github.com/aimeos/ai-controller ... e.php#L138
Be aware that all conditions are combined using AND!
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

ttyy
Posts: 10
Joined: 02 Apr 2021, 16:31

Re: Make attributes and properties "searchable"

Post by ttyy » 20 Apr 2021, 13:41

Be aware that all conditions are combined using AND!
I just stumbled upon this issue, where i have faceted search, also have a group of attributes (ie. color)
each attribute has it's own id. Once I select lets say red and blue (id 2 and 3) I'm getting 0 results since it's all AND condition, and there is no product with red and blue together.

What would be a best approach to change this behaviour? There are few of such groups that will be used in the future.
I was thinking of a decorator that would group similar groups in the array and then do a IN search for product attribute.

This may work as alternative. - public function oneOf( $attrIds ) : Iface
Or maybe there is a simpler way to do this?

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: Make attributes and properties "searchable"

Post by aimeos » 24 Apr 2021, 09:00

The oneOf() method is the right way and you can already configure which attribute types should be OR-combined:
https://aimeos.org/docs/2020.x/config/c ... ypes-oneof
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply