Sorting by attribute type
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!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Sorting by attribute type
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
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
Re: Sorting by attribute type
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
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
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,
)
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, give us a star
If you like Aimeos, give us a star