Prestashop: Ignore cover image when choosing combination on product page

34 Views Asked by At

I sell T-shirts. The products are a combination of color and size.

I assigned more than one image to a certain combination in the admin and selected one as the cover image:enter image description here

The cover image is displayed on the product thumbnail (expected behavior)

The cover image is also displayed in the detailed product view (also expected behavior).

However, on the product page, I would like the cover image not to be prioritized when selecting a new combination (size or color). enter image description here enter image description here

When the user selects a new combination, the first image that is NOT the cover image should appear, with the cover image still remaining as an option to see the print enlarged.

My knowledge of web development is limited. I don't even know which .php or .js file to start looking into.

Version 1.7.8.8, default theme.

1

There are 1 best solutions below

0
Nedudgi On

Commenting the line below the one I marked 'COMMENT THE FOLLOWING LINE LIKE THIS' in src\Adapter\Presenter\Product\ProductLazyArray.php also does the trick. In version 1.7.7.8 it's line 669.

Here's the surrounding code for context:

private function fillImages(array $product, Language $language): void
    {
        // Get all product images, including potential cover
        $productImages = $this->imageRetriever->getAllProductImages(
            $product,
            $language
        );

        // Get filtered product images matching the specified id_product_attribute
        $this->product['images'] = $this->filterImagesForCombination($productImages, $product['id_product_attribute']);

        // Get default image for selected combination (used for product page, cart details, ...)
        $this->product['default_image'] = reset($this->product['images']);
        foreach ($this->product['images'] as $image) {
            // If one of the image is a cover it is used as such
            if (isset($image['cover']) && null !== $image['cover']) {
                //COMMENT THE FOLLOWING LINE LIKE THIS
                //$this->product['default_image'] = $image;

                break;
            }
        }