Jump to content

Display an image for each color declination of the product


Recommended Posts

Hello,

Excuse me for my english.

I am kinda new to Prestashop development, I would like to display the first image of the color declination for each color declination, instead of only an input color.

I have to admit that I don't really know where to search... I firstly tried to modify src/Adapter/Image/ImageRetriever.php in this way : (line 105)

        foreach ($images as $image) {
            // if (in_array($productAttributeId, $image['associatedVariants'])) {
                $filteredImages[] = $image;
            // }
        }

And then tried this in product-variants.tpl line 42:

          {foreach from=$product.images item=image}
            <li class="thumb-container">
              {foreach from=$group.attributes key=id_attribute item=group_attribute}
              <input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
              <img
                class="thumb js-thumb"
                data-image-medium-src="{$image.bySize.medium_default.url}"
                data-image-large-src="{$image.bySize.large_default.url}"
                src="{$image.bySize.home_default.url}"
                alt="{$image.legend}"
                title="{$image.legend}"
                width="100"
                itemprop="image"
              >
              {/foreach}
            </li>
          {/foreach}

I know it won't work but still don't know where to start actually...

 

If you could help me a bit, I would appreciate that a lot.

Thank you

 

EDIT : I'm working on a Prestashop 1.7.5.1 and what I'm trying to do it's something like that: 

https://www.texet.fr/B2B - Texet France/Procut-by-Brand/Harvest/2145005-be2822ea/?initialcolorCode=490

Edited by JordanBTD (see edit history)

Share this post


Link to post
Share on other sites
  • 1 year later...

Hi Jordan,

I am also interested on this. Did you manage to solve it ?

Can you please share here what you did ?

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More