CATALOG / CATEGORY SORT BY SPECIFIC ATTRIBUTE

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
David Haška
Posts: 10
Joined: 30 Aug 2018, 17:08

CATALOG / CATEGORY SORT BY SPECIFIC ATTRIBUTE

Post by David Haška » 30 Aug 2018, 17:15

Hi,

how can I sort a list of products in catalog / category by a specific attribute?

My problem:
We have cloth for winter and summer seasons so i created two attributes with code 'season' (winter and summer). The target is to sort product by this attribute by default (customer cannot see that it is sorted by this attribute si customer cannot change it). It will be changed by settings in config file - in winter it will be set for 'winter' attribute and in summer it will be set for 'summer' attribute.

Can I extend this? If i can, so how?

Thank you so much.

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

Re: CATALOG / CATEGORY SORT BY SPECIFIC ATTRIBUTE

Post by aimeos » 30 Aug 2018, 21:12

Sorting by attributes isn't available and filtering by attribute is used for the faceted search but not done automatically based on your configuration.

Why don't you simply create two categories (summer and winter), add the products to these categories in the order you want and disable the category which doesn't belong to the current season? You can even define the active category to be the root of the category tree via configuration.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

David Haška
Posts: 10
Joined: 30 Aug 2018, 17:08

Re: CATALOG / CATEGORY SORT BY SPECIFIC ATTRIBUTE

Post by David Haška » 31 Aug 2018, 06:34

Thank you for your answer.

I also thought about creating two categories like summer and winter but the first problem is that we have already some categories like 'for men', 'for women', 'for children' and we dont want to divide it by seasons.

And the second problem with two categories is that we want all products in all categories like 'for men' etc., sort by season attribute beacause we want the customer to see all products (not only summer or winter) in each category but prefered by season - in summer, products with summer attribute are first and other products are behind them. And same for winter, but opposite. We simply want the customer to see product prefered by season atribute - not only in root and summer / winter category.

Is there really no chance of implementing it in any way?

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

Re: CATALOG / CATEGORY SORT BY SPECIFIC ATTRIBUTE

Post by aimeos » 01 Sep 2018, 19:58

Here's a possible solution:
- Extend the index attribute manager and add a sort function (e.g. sort:index.attribute.season()) that sorts the result set by the season attribute: https://github.com/aimeos/aimeos-core/b ... rd.php#L24
- Add that sort function to all filters created by the product controller: https://github.com/aimeos/ai-controller ... d.php#L192

If you make the direction configurable, then you can change it depending on the season
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

David Haška
Posts: 10
Joined: 30 Aug 2018, 17:08

Re: CATALOG / CATEGORY SORT BY SPECIFIC ATTRIBUTE

Post by David Haška » 05 Sep 2018, 15:44

Is there any recipe how to extend the index attribute manager? A tried everything, but not succesfuly. And where are all filters where i have to put that function?

Thank you.

Post Reply