How To

Magento 2 – Hide Configurable Parent Product Image from Details Page When Color Swatch is Selected

Hello Magento Friends,

In this tutorial, I am going to explain How to Hide the Configurable Parent Product Image when any Swatch is selected in Magento 2.

Magento default supports various product types to help store merchants manage their catalogs. One of them is configurable products. You can create configurable products in Magento 2 with the help of the following two ways:

Configurable products have one parent product and various child products. Configurable products have swatches to provide different color or size options to users. Configure Color Swatches in Magento 2

By default, the parent product image is displayed when no swatch is selected. But when a user selects any swatch, it will also show the parent product along with the related swatch images.

To hide parent product image of configurable products from the product details page when the swatch is selected, follow the below steps

Steps to Hide Configurable Parent Product Image when Swatch is Clicked in Magento 2:

The Luma Theme default value is prepend.

Replace “prepend” with “replace” for  gallery_switch_strategy

For that move to the below path

app\design\frontend\Themes\Yourtheme\etc\view.xml

Then, modify the code as follows

<vars module="Magento_ConfigurableProduct">
      <var name="gallery_switch_strategy">replace</var>
</vars>

Conclusion:

Thai way you can hide parent configurable product image when the user selects any swatch option in Magento 2. If you have any doubt, feel free to reach me via the comment section. Share the blog with others and stay tuned for more.

Happy Coding!

Click to rate this post!
[Total: 6 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

2 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

4 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

4 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

5 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

6 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

1 week ago