add search filter by store rating

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
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

add search filter by store rating

Post by ahmed31916 » 15 Jun 2022, 16:54

Hello Aimeos,

If I want to add a new column for a store rating in mshop_locale_site table (in multi vendor case).
How can I include it to the searching filter of the product?

In other words, I need to add a new filter to the product filter, to search for a product by it's store rating.

User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Re: add search filter by store rating

Post by ahmed31916 » 16 Jun 2022, 11:13

the filter searches for a product according to the store rating.

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

Re: add search filter by store rating

Post by aimeos » 17 Jun 2022, 08:37

You can't add a locale/site condition directly when searching for products because both tables have no connection between them.

The only way to solve this in a performant way is to add a new mshop_index_site table and the appropriate index/site sub-manager. The manager can then add the records to its index table during index rebuild and offer the search configuration you need to filter products by vendor rating.

Have a look at the existing index sub-managers how to implement one for the site data:
https://github.com/aimeos/aimeos-core/b ... er/Catalog

The files contain a lot of documentation but the actual code to write isn't that much.
Add this configuration to your own ./config/mshop.php file:

Code: Select all

'index' => [
	'manager' => [
		'domains' => [
			'locale/site' => 'locale/site',
		],
		'submanagers => [
			'site' => 'site',
		]
	]
]
Also see: https://github.com/aimeos/aimeos-core/b ... #L519-L534

You can get the site item for products using:

Code: Select all

$product->getSiteItem()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Re: add search filter by store rating

Post by ahmed31916 » 17 Jun 2022, 16:56

First, I'm wondering, why aimeos created twice text tables (mshop_text and index_text)? Is it not possible to add a secondary foreign key to the mshop_text table to indicate which product, so we have dispensed with the index_text table?

Second, where can I add the manager code of the new mshop_index_site in my extension?

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

Re: add search filter by store rating

Post by aimeos » 20 Jun 2022, 07:47

ahmed31916 wrote: 17 Jun 2022, 16:56 First, I'm wondering, why aimeos created twice text tables (mshop_text and index_text)? Is it not possible to add a secondary foreign key to the mshop_text table to indicate which product, so we have dispensed with the index_text table?
No, it's not possible because the mshop_text table can contain texts from several domains too, e.g. categories or services and the table can be stored in another database.
ahmed31916 wrote: 17 Jun 2022, 16:56 Second, where can I add the manager code of the new mshop_index_site in my extension?
In the ./src/MShop/Manager/Index/ directory of your extension.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply