How to sort event products by start date in the frontend?

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!
claude27
Posts: 9
Joined: 25 Jul 2024, 11:24

How to sort event products by start date in the frontend?

Post by claude27 » 25 Jul 2024, 11:42

Hi,

I would like to sort event products by default by start date in the frontend catalog list automatically. At the moment they are sorted by relevance and this seems to be sorted by creation date but I need a default sorting by start date.

At the moment I have no idea which file(s) I have to edit or which code I have to add. Perhaps the pagination.php file?

Thanks.

Aimeos version: 24.4.2 (TYPO3)

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

Re: How to sort event products by start date in the frontend?

Post by aimeos » 28 Jul 2024, 10:00

Add these lines in your custom product controller:
https://github.com/aimeos/ai-controller ... #L591-L593

We've added it to the aimeos/ai-controller-frontend controller package too and it will be part of the next LTS release.

Furthermore, you need to add a new sort option in the pagination partial for sorting by "start" date/time:
https://github.com/aimeos/ai-client-htm ... nation.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

claude27
Posts: 9
Joined: 25 Jul 2024, 11:24

Re: How to sort event products by start date in the frontend?

Post by claude27 » 29 Jul 2024, 21:52

Wonderful, thank you very much for your answer! It helped me a lot.

Because I didn't manage to change the default sorting by manipulating the partial pagination (and on the home page I don't use a pagination) I added also these lines in the file
/vendor/aimeos/aimeos-typo3/Configuration/FlexForms/CatalogList.xml
...
<numIndex index="7" type="array">
<numIndex index="0">LLL:EXT:aimeos/Resources/Private/Language/plugins.xlf:catalog-list.sort-start</numIndex>
<numIndex index="1">start</numIndex>
</numIndex>
...

and the translation, e.g. for german:
...
/vendor/aimeos/aimeos-typo3/Resources/Private/Language/de.plugins.xlf
<trans-unit id="catalog-list.sort-start" xml:space="preserve">
<source>Start time</source>
<target>Startzeit</target>
</trans-unit>
...

Perhaps you can also add this to the lts version.

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

Re: How to sort event products by start date in the frontend?

Post by aimeos » 30 Jul 2024, 06:56

Are you able to create a pull request with your changes in the Github repository?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

claude27
Posts: 9
Joined: 25 Jul 2024, 11:24

Re: How to sort event products by start date in the frontend?

Post by claude27 » 16 Sep 2024, 10:26

I've created now a pull request. As it's the first time I pull to an official package I hope I made it right. Unfortunately I didn't manage to put the 2 commits in one pull request, so you will see 2 pull requests.

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

Re: How to sort event products by start date in the frontend?

Post by aimeos » 16 Sep 2024, 13:02

Thanks a lot, they are merged now :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply