Attribute size should not change the image

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!
robert63
Posts: 25
Joined: 03 Nov 2021, 13:38

Attribute size should not change the image

Post by robert63 » 24 Nov 2023, 13:29

I have a select article with 6 different colors and 4 different sizes. These are 24 articles. When selecting the color I want to show the image of the article in this color. When selecting the size it should not have any effect on the image.

1) I put the image with the color in all 4 of the variant articles: This has the effect that I have 4 identical images that are shown in the slider.
2) I put the image with the color in only one of the variant article. Lets say just in the one of the size small. Then I have each color only once in the slider, but when I select first the color and then the size then the image changes to the wrong color when selecting size.

So it would be necessary to be able to define if an attribute can change the image. Is this somehow possible? Or to be able to define that 4 identical images are not shown in the slider.

robert63
Posts: 25
Joined: 03 Nov 2021, 13:38

Re: Attribute size should not change the image

Post by robert63 » 24 Nov 2023, 14:06

I modified aimeos.js line 453... to:

/**
* Shows the images associated to the variant attributes
*/
onImageVariant() {
$(document).on("change", ".product .selection .select-list", ev => {

const elem = $(ev.currentTarget);
const type = elem.data("type");
const value = elem.find(".select-option:checked").val();

// Check if type is the Attribut 'size'
if (type !== 'size') {
elem.closest(".product").find(".image-single .item").each((idx, el) => {
if($(el).data("variant-" + type) == value) {
swiffyslider.slideTo($(el).closest(".swiffy-slider")[0], idx)
}
});
}
});
},

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

Re: Attribute size should not change the image

Post by aimeos » 26 Nov 2023, 09:21

Thanks for investigating and finding a solution! :-)
Can you please create a pull request here so we can merge your changes into the core?
https://github.com/aimeos/ai-client-html
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply