cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.1 module Magento_Swatches no longer defines "swatchRenderer" ID. Why?

Magento 2.1 module Magento_Swatches no longer defines "swatchRenderer" ID. Why?

Trying to extend mage.SwatchRenderer widget in Magento CE 2.1.0, I encountered problems, caused by missing "swatchRenderer" ID in module Magento_Swatches.

In short, now it is much harder (almost impossible for novices) to extend mage.SwatchRenderer widget. This is because, instead of ID, the file path was used in templates.

 

 

For example, let's look at the /vendor/magento/module-swatches/view/frontend/templates/product/listing/renderer.phtml template. In previous versions (at least, in CE 2.0.7), this template contained the following statement:

 

require(["jquery", "jquery/ui", "swatchRenderer"], function ($) {

where "swatchRenderer" was an ID, that could be EASILY changed by any custom module.

 

 

Now this statement looks like this:

require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($) {

We can see no ID, but strict path to the file, that can not be easily changed in custom module.

 

 

Complete description of this problem, comparing with easiness of $.mage.menu widget extending, could be found in this article.

 

I have only one question: "WHY you decided to make my life so much harder???" Smiley Happy

 

1 REPLY 1

Re: Magento 2.1 module Magento_Swatches no longer defines "swatchRenderer" ID. Why?

One more word.

Missing "swatchRenderer" ID, not only made my (and other's) life harder. It broke backward compatibility with those modules, that already using this ID, for instance, Aheadworks's module "Layered Navigation for Magento 2"