skip to Main Content

I’m trying to upgrade my store from V2.3 to V2.3.1. I’m working on my local development version and have got almost everything working. I use text swatches which work fine in V2.3 but in V2.3.1 all I see in the swatch is “null”. I know the correct text is being sent to the page as I see it when I hover over the swatch (see the image below where you can see the second colour swatch has the value Grey). I suspect something isn’t working with the javascript but I’ve no idea where to start looking. There are no errors in the console log btw.

Anyone able to suggest where the problem might be?
enter image description here

3

Answers


  1. Chosen as BEST ANSWER

    I've tracked the problem down to something in swatch-renderer.js. The V2.3 version has the following line at 517:

    value = optionConfig[id].hasOwnProperty('value') ? optionConfig[id].value : '';
    

    The version V2.3.1 has changed this to the following:

    value = optionConfig[id].hasOwnProperty('value') ? $('<i></i>').text(optionConfig[id].value).html() : '';
    

    and the value is then used in the following statement to put the text into the html:

    html += '<div class="' + optionClass + ' text" ' + attr + '>' + (value ? value : label) + '</div>';
    

    I used alert() to see the content of value before and after each variant of this statement as well as its type. Before it's undefined, after it's null for both variants yet changing this back to the old version resolves the problem! That's probably because before in V2.3 it's of type object whereas in V2.3.1 it's of type string (and presumably has the value "null"!).

    I'll be honest, my knowledge of javascript is fairly limited. Does this look like an error? If so, what would be the best way to fix it (I presume test for the sting "null")?


    1. Stores > Attributes > Product > Edit and save the text swatch values
    2. php bin/magento indexer:reindex
    Login or Signup to reply.
  2. Please update Product Attribute "Admin" Columns From Backend. Then perform Reindexing.

    Product Attribute - Edit

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search