Colors on the category page

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!
karpati
Posts: 14
Joined: 08 Feb 2022, 20:42

Colors on the category page

Post by karpati » 02 May 2022, 15:06

Hello Aimeos!

What solution do you suggest if I want to display the colors (icons) of the product on the category page (Laravel)?
Is there a simple solution?
Thank you very much!
aimeos00001.jpg
aimeos00001.jpg (47.27 KiB) Viewed 970 times
these colors:
aimeos2.jpg
aimeos2.jpg (194.96 KiB) Viewed 972 times

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

Re: Colors on the category page

Post by aimeos » 03 May 2022, 15:48

Add this to the ./config/shop.php file in your Laravel application:

Code: Select all

'client' => [
	'html' => [
		'catalog' => [
			'lists' => [
				'domains' => ['attribute', 'media', 'price', 'product', 'text']
			]
		]
	]
],
This fetches the attributes of the variant products too and you can add them in your template.
See also: https://aimeos.org/docs/latest/config/c ... s/#domains

If you enable this setting and switch to the alternative list view, you will see what you want out of the box:
https://aimeos.org/docs/latest/config/c ... basket-add
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

karpati
Posts: 14
Joined: 08 Feb 2022, 20:42

Re: Colors on the category page

Post by karpati » 13 Jun 2022, 19:03

Hi!
Thanks for the help.
Unfortunately, I can't extract attributes from $productItem.

It does not work:

Code: Select all

$productItem->getRefItems( 'attribute', null, 'variant' );
Can you help me?

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

Re: Colors on the category page

Post by aimeos » 14 Jun 2022, 19:27

The variant attributes are attached to the variant articles, not to the selection product itself:

Code: Select all

foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $articleItem )
{
	foreach( $articleItem->getRefItems( 'attribute', 'color', 'variant' ) as $attrItem ) {
		echo $attrItem->getRefItems( 'media', 'icon' )->getPreview()->first();
	}
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply