Image not changing with Variant Selection

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
syedaliiftikhar
Posts: 11
Joined: 19 Apr 2024, 18:29

Image not changing with Variant Selection

Post by syedaliiftikhar » 29 Apr 2024, 17:01

When I choose a variant, the corresponding image doesn't change.
In my case variant attribute is color.
Price is changing but image isn't.

Additionally, I'd like to inquire whether a main product without an assigned image will automatically fetch the variant image or not?

Laravel 11.4.0
Aimeos 2024.4
PHP 8.3.6
Ubuntu 20.04.3 LTS

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

Re: Image not changing with Variant Selection

Post by aimeos » 30 Apr 2024, 09:22

syedaliiftikhar wrote: 29 Apr 2024, 17:01 When I choose a variant, the corresponding image doesn't change.
In my case variant attribute is color.
Price is changing but image isn't.
Tested that and works as expected. Did you upload the images for the variant articles in the admin backend? The variant attributes need to be assigned to the uploaded images and the admin backend does that automatically. For imported articles, this isn't the case.
syedaliiftikhar wrote: 29 Apr 2024, 17:01 Additionally, I'd like to inquire whether a main product without an assigned image will automatically fetch the variant image or not?
No, due to performance reasons.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

syedaliiftikhar
Posts: 11
Joined: 19 Apr 2024, 18:29

Re: Image not changing with Variant Selection

Post by syedaliiftikhar » 30 Apr 2024, 15:12

"The variant attributes need to be assigned to the uploaded images and the admin backend does that automatically. "

Could you please provide further details or perhaps a demo video regarding the process you mentioned?

I'm utilizing ai-woocommerce, so if it's not automatically being acquired, I assume I'll need to take additional steps. Could you share more information, such as an SQL query for accomplishing this task, or specify which manager is responsible for it and which table it's linked to?

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

Re: Image not changing with Variant Selection

Post by aimeos » 30 Apr 2024, 15:54

The relevant code in the admin interface is available here:
https://github.com/aimeos/ai-admin-jqad ... #L244-L259

In the migration scripts, the code for assigning variant attributes to products is here:
https://github.com/aimeos/ai-woocommerc ... #L191-L192

When assigning the images to the products, the variant attributes of the products should be also assigned to the media items here too:
https://github.com/aimeos/ai-woocommerc ... #L335-L341

You can get the variant attributes of a product using:

Code: Select all

$listItems = $product->getListItems( 'attribute', 'variant', null, false );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

Re: Image not changing with Variant Selection

Post by aimeos » 01 May 2024, 08:55

We've added the necessary code to the migration but are not able to test it at the moment:
https://github.com/aimeos/ai-woocommerc ... 9b8062b968

Can you check if it does the job now?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

syedaliiftikhar
Posts: 11
Joined: 19 Apr 2024, 18:29

Re: Image not changing with Variant Selection

Post by syedaliiftikhar » 01 May 2024, 14:10

Actually I have customized that script for my own need. This code was missing and yesterday I figured that out.
I will say yes It is working. As it worked for my script, it will work for ai-woocommerce as well.

Post Reply