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.
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 ...
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 ...
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>
<...
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....
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'
}
}};
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 ...
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:...
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'
}
}
};
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 ...
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.
<...
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')->...
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(){
...
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(
...
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 ...
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 ...
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\...
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. ...
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");
$...
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,
'...
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
*/...
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 ...
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 ...
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 ...
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 &...
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/...
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>/...
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/...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
swatches × 261magento2 × 120
configurable-product × 87
color-swatches × 59
magento-1.9 × 55
attributes × 24
configurable-swatches × 19
magento-2.1 × 18
magento2.3 × 17
product × 15
javascript × 11
product-images × 11
ce-1.9.1.0 × 11
product-attribute × 10
magento2.2 × 5
layered-navigation × 5
product-list × 5
rwd-theme × 5
visualswatch × 5
ce-1.9.0.1 × 4
product-view × 4
import × 3
custom-options × 3
magento2.4 × 3
simple-product × 3