category names in search result

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
GülsümAkça
Posts: 57
Joined: 20 Nov 2020, 13:30

category names in search result

Post by GülsümAkça » 27 Feb 2021, 12:44

How can I show category names in search result?
Thank you

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

Re: category names in search result

Post by aimeos » 01 Mar 2021, 10:58

Yes, you can use this configuration to add the categories to the products:
https://aimeos.org/docs/2020.x/config/c ... s/#domains

Code: Select all

'client' => [
	'html' => [
		'catalog' => [
			'lists' => [
				'domains' => ['media', 'price', 'text', 'catalog' => ['text']]
			]
		]
	]
]
)
This will include the localized category name too. Then, you have to overwrite the product partial and add:

Code: Select all

<?php if( !( $categories = $productItem->getCatalogItems() )->isEmpty() ) : ?>
	<h3 class="category"><?= $enc->html( $categories->getName()->first(), $enc::TRUST ); ?></h3>
<?php endif ?>
at https://github.com/aimeos/ai-client-htm ... #L168-L170

How to overwrite templates:
https://aimeos.org/docs/2020.x/frontend ... templates/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
GülsümAkça
Posts: 57
Joined: 20 Nov 2020, 13:30

Re: category names in search result

Post by GülsümAkça » 02 Mar 2021, 15:20

thank you for your help,
But I guess I couldn't express myself correctly. sorry
If I search for a word, I can see the suggest products under the search bar without clicking the search button or press the enter.
just like this, if I search for a category name, I want to show the category as suggestion under the search bar.
Is it possible to do this?

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

Re: category names in search result

Post by aimeos » 04 Mar 2021, 13:11

There's currently no configuration option to enable such a behavior and you have to implement it yourself.
You can add a decorator for the catalog/suggest HTML client which searches for the text string in the "label" column in the "mshop_catalog" table:
https://github.com/aimeos/ai-client-htm ... #L310-L382

How to implement a decorator:
https://aimeos.org/docs/latest/frontend ... omponents/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply