Page 1 of 1

add search filter by store rating

Posted: 15 Jun 2022, 16:54
by ahmed31916
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.

Re: add search filter by store rating

Posted: 16 Jun 2022, 11:13
by ahmed31916
the filter searches for a product according to the store rating.

Re: add search filter by store rating

Posted: 17 Jun 2022, 08:37
by aimeos
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()

Re: add search filter by store rating

Posted: 17 Jun 2022, 16:56
by ahmed31916
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?

Re: add search filter by store rating

Posted: 20 Jun 2022, 07:47
by aimeos
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.