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

Improving Error Handling and Transition Management in Remix with useRouteError and useViewTransitionState

In modern web development, seamless navigation and state management are crucial for delivering a smooth…

6 days ago

Magento Open Source 2.4.8-Beta Release Notes

Magento Open Source 2.4.8 beta version released on October  8, 2024. The latest release of…

1 week ago

How to Create Catalog Price Rule in Magento 2 Programmatically?

Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…

1 week ago

Top 10 Tips to Hire Shopify Developers

As the world of eCommerce continues to thrive, Shopify has become one of the most…

2 weeks ago

Managing Browser Events and Navigation in Shopify Remix: useBeforeUnload, useHref, and useLocation Hooks

Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…

2 weeks ago

Ultimate Guide to Hiring a Top Shopify Development Agency

Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…

2 weeks ago