Show all images of products even if combination is selected

Hi, I've bought the Combinations Tab Pro module and I have a question about product images. I have a product with 2 combinations. The product has 4 images, one for each of the 2 combinations and 2 general images. I would like all 4 images to show for the product (as thumbnails) and for one of the two general images to be used as the main (cover) image. The table of combinations should use the image relevant to each combination. Is there any way to do this? I can see that I can duplicate the images and then link a group of 4 to each combination, but then my main (cover) image becomes the 'combination' image. I appreciate that this question is not really about your module, but any advice would be appreciated. Thanks.


Show all pictures of product, not only images associated with combination

Hello,
I am not sure what's the prestashop version you use, but from your description i see that it is probaly prestashop 1.7.x. So my answer will be based on this PrestaShop version.
(i think so because in ps 1.7 when you will access to product page that has combinations, product page will show pictures that are associated with viewed combination only)


The product has 4 images, one for each of the 2 combinations and 2 general images. I would like all 4 images to show for the product (as thumbnails) and for one of the two general images to be used as the main (cover) image
In PrestaShop you can mark one from the images as a cover of product: https://i.imgur.com/oMj7n4r.png - So, this picture will appear as a cover of the product. Do it, selected picture will appear as a product cover photo.
Then it will be required to modify PrestaShop's core code. Please open file: src/adapter/image/ImageRetrievier.php

there is a code: (somewhere near ~50 line)
public function getProductImages(array $product, Language $language)
    {
        $productAttributeId = $product['id_product_attribute'];
        $productInstance = new Product(
            $product['id_product'],
            false,
            $language->id
        );
alter it to:
public function getProductImages(array $product, Language $language)
    {
        $productAttributeId = 0;
        $productInstance = new Product(
            $product['id_product'],
            false,
            $language->id
        );
Thanks to this change product page will show all product pictures, not only pictures associated with viewed combination

hope that this is what you are looking for ;)


The table of combinations should use the image relevant to each combination. Is there any way to do this?
'combinations table' module near each combination shows cover image of according combination. So in context of the module - there is nothing to 'fix' or 'improve' because it behaves like you described by default :)

Share on Google Plus

About VEKIA

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

5 comments:

  1. Hello Vekia,
    This method does not work very well. It can actually display all the pictures, but the change of picture when choosing a variant does not work after that. How to make both work together?
    Best regards,

    ReplyDelete
  2. assign default combination and the select image/images u want to show then save it.

    ReplyDelete
  3. This modification ALWAYS DISPLAYS ALL PICTURES, even if you will select combination

    ReplyDelete
  4. Hi Vekia.

    There is no way to show all the images (like the code does) but also change the image to the one of the combination checked?

    Even with a module, but I need to solve this!

    ReplyDelete
  5. Hi, u have tuto for 1.7.8 ?:D

    ReplyDelete