Jump to content

[SOLVED] Ignore cover image when choosing combination on product page


nedudgi

Recommended Posts

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 (see attachment)

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, I would like the cover image not to be prioritized when selecting a new combination (size or color). (See attachment).

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.

Help is appreciated.

cover1.jpg

cover2.jpg

cover3.jpg

Edited by nedudgi
solved (see edit history)
Link to comment
Share on other sites

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;
            }
        }           

 

Link to comment
Share on other sites

  • nedudgi changed the title to [SOLVED] Ignore cover image when choosing combination on product page

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...