Sorting by attribute type

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
DembeRed
Posts: 1
Joined: 05 Oct 2019, 22:39

Sorting by attribute type

Post by DembeRed » 05 Oct 2019, 22:41

Hello everyone,,
how can I sort a list of products by a specific attribute? E.g. sort list by countries which is a attribute of type country on every product?
I see name, relevace and price.
Can I extend this?

Greetings

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

Re: Sorting by attribute type

Post by aimeos » 07 Oct 2019, 09:02

To extend Aimeos to be able to sort by attribute type/values a few steps must be taken:

1.) Extend the indext attribute manager (https://github.com/aimeos/aimeos-core/b ... rd.php#L62) by

Code: Select all

		'index.attribute:code' => array(
			'code' => 'index.attribute:code()',
			'internalcode' => 'mindat."listtype" = $1 AND mindat."type" = $2 AND mindat."code"',
			'label' => 'Attribute code, parameter(<list type code>,<type code>)',
			'type' => 'string',
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
			'public' => false,
		),
		'sort:index.attribute:code' => array(
			'code' => 'sort:index.attribute:code()',
			'internalcode' => 'mindat."code"',
			'label' => 'Sort by attribute code, parameter(<list type code>,<type code>)',
			'type' => 'string',
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
			'public' => false,
		)
2.) Extend the sort method of the product frontend controller (https://github.com/aimeos/ai-controller ... d.php#L335) by a key e.g. "a_<type>" and add the condition and sorting

3.) Add the new sorting in the pagination template (https://github.com/aimeos/ai-client-htm ... andard.php)

If everything works, a pull request with your changes is very welcome :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply