简体   繁体   中英

Product image and thumbnail display behavior of Magento 2

I am having some trouble to understand the product images/thumbnails concept of Magento 2. My Magento version is 2.1.1.

Case 1: I added a configurable product via admin panel and assigned some simple products to them with two attributes(Size and Color) for configurations. I have assigned two images (to a configurable product) and assigned one image to each simple products. In the product page, I am seeing two thumbnails (which is assigned to a configurable product). Which is absolutely fine. Now, when i select the available options (color and size), i am seeing the extra thumbnail has been added (the image which i assigned to that simple product). Which presents here as a repeated thumbnail.(screenshots attached)

Case 2: I removed the images assigned to all the simple products for that same configurable product. So now, Only configruable product has the images. Now, product details page, showing two thumbnails like previous and when i selected the available options (Size and Color), the product image is gone. Because i removed all the assigned simple product images.(screenshots attached)

So, In magento 2, is it compulsory to add the images to all simple products? otherwise it will not show the product image when selecting the options. Can't it work like the way it was doing in magento 1.

Is there any way to hide that extra thumbnail added when selecting the options?? because its showing like a repeated thumbnail.

I tried my best to show this concern comprehensible. Prior apology if it still shows unclear at some point.

Any suggestion/help would be greatly appreciated.

屏幕截图1-显示额外的缩略图

屏幕截图2-产品图片消失了

After a really long research on different forums I found a solution to this issue. Just a simple workaround : 1) Go to this file and open it : vendor/magento/theme-frontend-luma/etc/view.xml 2) Find this code :

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

and replace "propend" with "replace" .. so :

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

3) That's all! Just re-upload the file and delete all the Magento cache.

Hope this works for you. bye

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM