Custom order in product manager
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!
Custom order in product manager
I am fetching products by a comma separated list of product codes. When passing this list to the product manager, the order is lost and instead the products are ordered by product id. How can I ensure the order of my list is respected?
This is the relevant code in my Decorator:
This is the relevant code in my Decorator:
Code: Select all
$codesArray = explode(',', $codes);
$manager = \Aimeos\MShop::create($context, 'product');
$search = $manager->filter()->add( ['product.code' => $codesArray] )->slice( 0, count( $codesArray ) );
$result = $manager->search( $search );
$cntl = \Aimeos\Controller\Frontend::create($context, 'product');
return $cntl
->uses($domains)
->product($result->keys()->toArray())
->search();
Re: Custom order in product manager
You have to sort the result set using the PHP Map "uasort()" method before returning the result:
https://php-map.org/#uasort
https://php-map.org/#uasort
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