13 votes
Accepted

"Undefined Index Notice" in EavAttribute.php when adding a swatch option

Looks like problem in server settings. Please try increase max_input_vars setting to 100000 and try reproduce problem.
KAndy's user avatar
  • 20.8k
12 votes

Execute JavaScript code after swatches are displayed in category view

I used the event 'swatch.initialized' to fire a function after swatches are loaded in the product page: $(document).on('swatch.initialized', function() { // do something }) The event is triggered ...
Guillem Lorman's user avatar
11 votes
Accepted

Create Visual Swatch Attribute

Disclaimer: Parts of this code were taken from Magento_SwatchesSampleData core module. Also you might not need colorMap but I just put it there. This code was tested on Magento 2.1.4. I assume you ...
Konstantin Gerasimov's user avatar
10 votes
Accepted

Magento 2: How to change image size of swatches?

You have to apply changes under app/design/frontend/{Package}/{themename}/etc/view.xml file. For changes value of swatches you have to add your tag inside view.xml files <media> <...
Rakesh Jesadiya's user avatar
10 votes
Accepted

How to display swatches on homepage Magento 2

Create simple module for display swatches in configurable product in homepage. You have to follow below steps to get swatches on homepage product collection, app/code/Test/Homeslider/registration....
Rakesh Jesadiya's user avatar
9 votes
Accepted

Magento 2 replace a core javascript

Try below code in your requirejs-config.js var config = { map: { '*': { swatchRenderer: 'Muaw_CustomSwatches/js/SwatchRenderer' } }};
Shaheer Ali's user avatar
  • 2,355
9 votes
Accepted

Don't display swatches on product listing in Magento 2

Finally I found the answer to my question, and I'm going to share it because maybe it helps somebody in the future: 1.- Enter to admin panel 2.- Stores (left menu) 3.- Product (under attribute ...
Alex's user avatar
  • 811
8 votes

Magento 2: How to change image size of swatches?

1) Copy and create template vendor/magento/module-swatches/etc/view.xml into your theme app/design/frontend/[Vendor]/[Theme Name]/Magento_Swatches/etc/view.xml 2) Clear cache : php bin/magento cache:...
Sondre's user avatar
  • 343
8 votes

Magento 2 replace a core javascript

The code works for me on Magento 2.1.5 var config = { map: { '*': { 'Magento_Swatches/js/swatch-renderer':'Vendor_Module/js/swatch-renderer' } } };
Bhupendra Jadeja's user avatar
8 votes

Don't display swatches on product listing in Magento 2

Make sure in your theme you have a directory & file inside of your theme, this will overwrite the core code. Like so. Vender/Theme/Magento_Catalog/Layout/catalog_category_view.xml Once you ...
Suresh Chikani's user avatar
8 votes
Accepted

Stop simple product images overriding main product gallery after clicking swatches

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. <...
SilkSpin's user avatar
  • 182
7 votes
Accepted

Magento 2: Get image from the swatch id

You can get swatch Image from this, $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $swatch = $objectManager->create('Magento\Swatches\Helper\Data')->...
Keyur Shah's user avatar
6 votes
Accepted

Magento 1.9 preselect of configurable options (swatches)

Assuming you are using rwd theme, it can also be achieved by adding below jQuery code to your catalog/product/view.phtml file. <script type="text/javascript"> jQuery(document).ready(function(){ ...
Jaimin Sutariya's user avatar
6 votes
Accepted

How to add swatch data in Layered navigation aggregations in graphql?

I have override aggregations GraphQL API. Below code is working for me File:-Custom/Module/registration.php use Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register( ...
Devidas's user avatar
  • 3,328
5 votes
Accepted

How can I stop other attributes changing my swatch image?

Facing with the same problem, today I wrote the following fix, it works both with attribute selectors and configurable swatches. $j(document).ready(function() { if (typeof ConfigurableMediaImages ...
bencergazda's user avatar
5 votes
Accepted

Configurable product image not switching with swatch change

After another day of digging I did get this working. I was on the right path to finding out what was broken, I was just in the wrong file. In the end, the JS that drives the image swap is the object ...
circlesix's user avatar
  • 4,263
5 votes

Magento 2 create custom swatch attribute programmatically

This is similar to Magento 1, with a few differences. Step 1 Start by creating a basic setup script for it, if you don't already have one. <?php namespace Package\Module\Setup; use Magento\...
mimarcel's user avatar
  • 340
5 votes

Visual swatches for attribute with input type multiselect

Let me preface this by saying the solution below is far more invasive than I initially thought it would have needed to be. Most notably the total overwrite of Magento_Swatches/js/product-attributes. ...
Pmclain's user avatar
  • 2,568
5 votes

How to get visual swatch image from attribute_id?

Use Below code to get swatch image. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $swatchHelper=$objectManager->get("Magento\Swatches\Helper\Media"); $...
Dinesh Yadav's user avatar
  • 6,397
5 votes
Accepted

How to display Swatches into product list page into custom modules with add to cart functionality

Solution : Vendor/Module/registration.php put below code. <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, '...
Charvi Parikh's user avatar
4 votes

Magento 2: How to change image size of swatches?

I have investigated this issue. In file: Magento\Swatches\Helper\Media, we have this method: vendor/magento/module-swatches/Helper/Media.php /** * Merged config from view.xml * * @return array */...
De Nguyen's user avatar
  • 401
4 votes

Configurable swatches

The swatch extensions I know, as well as the 1.9 core module, use images of the simple products, so there is no way around duplicating the images. But you can avoid duplicating the actual image files ...
Fabian Schmengler's user avatar
4 votes

Enterprise 1.14.1 Swatches causing 35 sec plus load time on category pages

Additional way to improve performance configurable swatches when you have a lot of attribute options. For example if you have 2000 options and show 36 products in catalog list, in this case method ...
Yaroslav Voronoy's user avatar
4 votes

Change configurable swatches order in Magento 2

You have to edit configurable product, in configurable tab (product edit page) you can view option for Edit Configurations. Click on Edit Configurations, you can see select attribute screen, go to ...
Suresh Chikani's user avatar
4 votes

Magento 2 create custom swatch attribute programmatically

Recently tried below code for creating visual swatch attribute options pro-grammatically. Created file within root "import-visual-swatch.php" with below code: Place your all image into &...
deepakd's user avatar
  • 123
4 votes

How to handle click event on configurable product attribute swatch on product page?

Please replace your code below code. If possible add code in /var/www/html/mage2/vendor/magento/module-catalog/view/frontend/templates/product/view/options/wrapper.phtml <script type="text/...
Nits's user avatar
  • 2,476
4 votes
Accepted

Magento 2 : Display dropdown attribute with its label in product listing page

For that, you need to override renderer.phtml file and need to change onlySwatches and enableControlLabel attributes value. Go to app/design/frontend/<VendorName>/<themeName>/...
Rohan Hapani's user avatar
  • 17.3k
3 votes

Magento 2 replace a core javascript

There is an Easy way out for that when you do that changes while creating a custom Theme, Firstly override the template File in which the Js is being called i.e module-swatches/view/frontend/...
Shashank's user avatar
  • 238
3 votes

RWD swatches not changing images

The reason behind this is the function ConfigurableMediaImages.arrayIntersect. The problem here is that the function must take in two already sorted arrays. Unfortunately the theme does not guarantee ...
David Manners's user avatar
3 votes

Configurable Swatches not working after 1.9.3 Upgrade

To expand upon the previous answer, you are probably overriding catalog.xml in your theme and there was a change to catalog.xml in this update. They removed some functionality from varien/product.js ...
Mike's user avatar
  • 81

Only top scored, non community-wiki answers of a minimum length are eligible