Stop simple product images overriding main product gallery after clicking swatches Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Link configurable swatches to appropriate simple productChange More product images on color swatch selectSimple product images on product page, search/category and basket pagesConfigurable swatches on category page showing Out Of Stock ProductsSwatches update gallery but only with the first productSimple product images in cartConfigurable Products: Update Media Gallery - Not Just Base ImageProduct gallery disappear after page loadHide Configurable product images from details page when color swatch is selectedConfigurable product doesn't show simple product images
Import keychain to clean macOS install?
Does using the inspiration rules for character defects tend to encourage players to display MGS?
Why is ArcGIS Pro not symbolizing my entire range of values?
Why did Europeans not widely domesticate foxes?
Can this water damage be explained by lack of gutters and grading issues?
Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?
What could prevent concentrated local exploration?
Protagonist's race is hidden - should I reveal it?
Pointing to problems without suggesting solutions
Can the van der Waals coefficients be negative in the van der Waals equation for real gases?
How to ask rejected full-time candidates to apply to teach individual courses?
Magento 2 Editing phtml files in Production Mode
When speaking, how do you change your mind mid-sentence?
Can Deduction Guide have an explicit(bool) specifier?
lm and glm function in R
Lights are flickering on and off after accidentally bumping into light switch
What documents does someone with a long-term visa need to travel to another Schengen country?
Can a Wizard take the Magic Initiate feat and select spells from the Wizard list?
Do chord progressions usually move by fifths?
Book about a teenager and alien
What kind of capacitor is this in the image?
false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'
Alternative to "rest in peace" (RIP)
“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?
Stop simple product images overriding main product gallery after clicking swatches
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Link configurable swatches to appropriate simple productChange More product images on color swatch selectSimple product images on product page, search/category and basket pagesConfigurable swatches on category page showing Out Of Stock ProductsSwatches update gallery but only with the first productSimple product images in cartConfigurable Products: Update Media Gallery - Not Just Base ImageProduct gallery disappear after page loadHide Configurable product images from details page when color swatch is selectedConfigurable product doesn't show simple product images
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've upgraded from 2.1.9 to 2.2.3. Now on a configurable product page when a swatch is selected the product page gallery images get overridden by the simple product image for each swatch.
This didn't used to happen and I can't find a way to stop this behaviour. I only want the configurable product images to show as in the past. I actually only have thumbnails associated with simple products to show at the checkout.
configurable-product magento2.2 simple-product swatches gallery
add a comment |
I've upgraded from 2.1.9 to 2.2.3. Now on a configurable product page when a swatch is selected the product page gallery images get overridden by the simple product image for each swatch.
This didn't used to happen and I can't find a way to stop this behaviour. I only want the configurable product images to show as in the past. I actually only have thumbnails associated with simple products to show at the checkout.
configurable-product magento2.2 simple-product swatches gallery
add a comment |
I've upgraded from 2.1.9 to 2.2.3. Now on a configurable product page when a swatch is selected the product page gallery images get overridden by the simple product image for each swatch.
This didn't used to happen and I can't find a way to stop this behaviour. I only want the configurable product images to show as in the past. I actually only have thumbnails associated with simple products to show at the checkout.
configurable-product magento2.2 simple-product swatches gallery
I've upgraded from 2.1.9 to 2.2.3. Now on a configurable product page when a swatch is selected the product page gallery images get overridden by the simple product image for each swatch.
This didn't used to happen and I can't find a way to stop this behaviour. I only want the configurable product images to show as in the past. I actually only have thumbnails associated with simple products to show at the checkout.
configurable-product magento2.2 simple-product swatches gallery
configurable-product magento2.2 simple-product swatches gallery
edited Apr 18 '18 at 10:16
Mukesh Prajapati
1,263416
1,263416
asked Apr 18 '18 at 10:00
SilkSpinSilkSpin
407
407
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product.
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">prepend</var>
</vars>
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
add a comment |
If you would like to alter the behavior of how the gallery switching happens, I think the function you are looking for is in
vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
called processUpdateBaseImage
This is completely untested, but you can create a mixin and change that function's behavior, something like:
Namespace/Module/view/frontend/requirejs-config.js -
var config =
config:
mixins:
'Magento_Swatches/js/swatch-renderer':
'Namespace_Module/js/swatch-renderer-mixin': true
,
;
Namespace/Module/view/web/js/swatch-renderer-mixin.js -
define(['jquery'], function ($)
'use strict';
var mixin =
/**
* Update [gallery-placeholder] or [product-image-photo]
* @param Array images
* @param jQuery context
* @param Boolean isInProductView
* @param Object gallery
*/
processUpdateBaseImage: function (images, context, isInProductView, gallery)
var justAnImage = images[0],
initialImages = this.options.mediaGalleryInitial,
imagesToUpdate,
isInitial;
if (isInProductView)
imagesToUpdate = images.length ? this._setImageType($.extend(true, [], images)) : [];
isInitial = _.isEqual(imagesToUpdate, initialImages);
if (this.options.gallerySwitchStrategy === 'prepend' && !isInitial)
imagesToUpdate = imagesToUpdate.concat(initialImages);
imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);
if (isInitial)
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();
else
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents(
selectedOption: this.getProduct(),
dataMergeStrategy: this.options.gallerySwitchStrategy
);
gallery.first();
else if (justAnImage && justAnImage.img)
context.find('.product-image-photo').attr('src', justAnImage.img);
;
return function (target)
return target.extend(mixin);
);
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f222804%2fstop-simple-product-images-overriding-main-product-gallery-after-clicking-swatch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product.
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">prepend</var>
</vars>
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
add a comment |
By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product.
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">prepend</var>
</vars>
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
add a comment |
By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product.
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">prepend</var>
</vars>
By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product.
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">prepend</var>
</vars>
answered Apr 20 '18 at 9:44
SilkSpinSilkSpin
407
407
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
add a comment |
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
I would still like to find a way to stop the simple product image appearing in the configurable product gallery altogether? I don't need separate photos for each simple product. I only have thumbnails associated with the simple products but they are being shown in the gallery when the swatch image is clicked on. Even though Hide from Product Page is checked.
– SilkSpin
Apr 20 '18 at 22:52
add a comment |
If you would like to alter the behavior of how the gallery switching happens, I think the function you are looking for is in
vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
called processUpdateBaseImage
This is completely untested, but you can create a mixin and change that function's behavior, something like:
Namespace/Module/view/frontend/requirejs-config.js -
var config =
config:
mixins:
'Magento_Swatches/js/swatch-renderer':
'Namespace_Module/js/swatch-renderer-mixin': true
,
;
Namespace/Module/view/web/js/swatch-renderer-mixin.js -
define(['jquery'], function ($)
'use strict';
var mixin =
/**
* Update [gallery-placeholder] or [product-image-photo]
* @param Array images
* @param jQuery context
* @param Boolean isInProductView
* @param Object gallery
*/
processUpdateBaseImage: function (images, context, isInProductView, gallery)
var justAnImage = images[0],
initialImages = this.options.mediaGalleryInitial,
imagesToUpdate,
isInitial;
if (isInProductView)
imagesToUpdate = images.length ? this._setImageType($.extend(true, [], images)) : [];
isInitial = _.isEqual(imagesToUpdate, initialImages);
if (this.options.gallerySwitchStrategy === 'prepend' && !isInitial)
imagesToUpdate = imagesToUpdate.concat(initialImages);
imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);
if (isInitial)
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();
else
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents(
selectedOption: this.getProduct(),
dataMergeStrategy: this.options.gallerySwitchStrategy
);
gallery.first();
else if (justAnImage && justAnImage.img)
context.find('.product-image-photo').attr('src', justAnImage.img);
;
return function (target)
return target.extend(mixin);
);
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
If you would like to alter the behavior of how the gallery switching happens, I think the function you are looking for is in
vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
called processUpdateBaseImage
This is completely untested, but you can create a mixin and change that function's behavior, something like:
Namespace/Module/view/frontend/requirejs-config.js -
var config =
config:
mixins:
'Magento_Swatches/js/swatch-renderer':
'Namespace_Module/js/swatch-renderer-mixin': true
,
;
Namespace/Module/view/web/js/swatch-renderer-mixin.js -
define(['jquery'], function ($)
'use strict';
var mixin =
/**
* Update [gallery-placeholder] or [product-image-photo]
* @param Array images
* @param jQuery context
* @param Boolean isInProductView
* @param Object gallery
*/
processUpdateBaseImage: function (images, context, isInProductView, gallery)
var justAnImage = images[0],
initialImages = this.options.mediaGalleryInitial,
imagesToUpdate,
isInitial;
if (isInProductView)
imagesToUpdate = images.length ? this._setImageType($.extend(true, [], images)) : [];
isInitial = _.isEqual(imagesToUpdate, initialImages);
if (this.options.gallerySwitchStrategy === 'prepend' && !isInitial)
imagesToUpdate = imagesToUpdate.concat(initialImages);
imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);
if (isInitial)
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();
else
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents(
selectedOption: this.getProduct(),
dataMergeStrategy: this.options.gallerySwitchStrategy
);
gallery.first();
else if (justAnImage && justAnImage.img)
context.find('.product-image-photo').attr('src', justAnImage.img);
;
return function (target)
return target.extend(mixin);
);
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
If you would like to alter the behavior of how the gallery switching happens, I think the function you are looking for is in
vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
called processUpdateBaseImage
This is completely untested, but you can create a mixin and change that function's behavior, something like:
Namespace/Module/view/frontend/requirejs-config.js -
var config =
config:
mixins:
'Magento_Swatches/js/swatch-renderer':
'Namespace_Module/js/swatch-renderer-mixin': true
,
;
Namespace/Module/view/web/js/swatch-renderer-mixin.js -
define(['jquery'], function ($)
'use strict';
var mixin =
/**
* Update [gallery-placeholder] or [product-image-photo]
* @param Array images
* @param jQuery context
* @param Boolean isInProductView
* @param Object gallery
*/
processUpdateBaseImage: function (images, context, isInProductView, gallery)
var justAnImage = images[0],
initialImages = this.options.mediaGalleryInitial,
imagesToUpdate,
isInitial;
if (isInProductView)
imagesToUpdate = images.length ? this._setImageType($.extend(true, [], images)) : [];
isInitial = _.isEqual(imagesToUpdate, initialImages);
if (this.options.gallerySwitchStrategy === 'prepend' && !isInitial)
imagesToUpdate = imagesToUpdate.concat(initialImages);
imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);
if (isInitial)
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();
else
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents(
selectedOption: this.getProduct(),
dataMergeStrategy: this.options.gallerySwitchStrategy
);
gallery.first();
else if (justAnImage && justAnImage.img)
context.find('.product-image-photo').attr('src', justAnImage.img);
;
return function (target)
return target.extend(mixin);
);
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
If you would like to alter the behavior of how the gallery switching happens, I think the function you are looking for is in
vendor/magento/module-swatches/view/frontend/web/js/swatch-renderer.js
called processUpdateBaseImage
This is completely untested, but you can create a mixin and change that function's behavior, something like:
Namespace/Module/view/frontend/requirejs-config.js -
var config =
config:
mixins:
'Magento_Swatches/js/swatch-renderer':
'Namespace_Module/js/swatch-renderer-mixin': true
,
;
Namespace/Module/view/web/js/swatch-renderer-mixin.js -
define(['jquery'], function ($)
'use strict';
var mixin =
/**
* Update [gallery-placeholder] or [product-image-photo]
* @param Array images
* @param jQuery context
* @param Boolean isInProductView
* @param Object gallery
*/
processUpdateBaseImage: function (images, context, isInProductView, gallery)
var justAnImage = images[0],
initialImages = this.options.mediaGalleryInitial,
imagesToUpdate,
isInitial;
if (isInProductView)
imagesToUpdate = images.length ? this._setImageType($.extend(true, [], images)) : [];
isInitial = _.isEqual(imagesToUpdate, initialImages);
if (this.options.gallerySwitchStrategy === 'prepend' && !isInitial)
imagesToUpdate = imagesToUpdate.concat(initialImages);
imagesToUpdate = this._setImageIndex(imagesToUpdate);
gallery.updateData(imagesToUpdate);
if (isInitial)
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents();
else
$(this.options.mediaGallerySelector).AddFotoramaVideoEvents(
selectedOption: this.getProduct(),
dataMergeStrategy: this.options.gallerySwitchStrategy
);
gallery.first();
else if (justAnImage && justAnImage.img)
context.find('.product-image-photo').attr('src', justAnImage.img);
;
return function (target)
return target.extend(mixin);
);
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 3 hours ago
Pawan
2,2912720
2,2912720
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 3 hours ago
asdfasdfasfasdfasdfasf
1
1
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asdfasdfasf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f222804%2fstop-simple-product-images-overriding-main-product-gallery-after-clicking-swatch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown