1

I am using text swatches for colour and size. These work fine in all listings where they're used (home page, product listing etc) but they are blank in layered navigation. For an example, see this page on my site: https://buylingerie.co.uk/buy-lingerie/bras.

I have no idea what's causing this, any suggestions?

1
  • Check you attribute configurations, in your site in the layered navigation the size filter does display the text 38 for one of the options, maybe that can hint you
    – SantiBM
    Commented Jun 5, 2019 at 11:19

2 Answers 2

1

I think I've tracked it down. In the file vendor/magento/module-swatches/view/frontend/templates/product/layered/renderer.phtml there's the line (69):

><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>

I don't know if it's because I migrated my site but all the entries in the table eav_attribute_option_swatch for my attributes have a value of null. So the code's doing what it's designed to do. I've changed the line to the following which resolves it. Whether it's the right way or not I don't know but it works. I'll be applying it to my live site later.

><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?: $label['label'] ?></div>
0

I just turned a select attribute (also migrated) into a text swatch attribute and had the same issue.

If I go in the attribute administration, the "swatch" column was all empty - it is not obvious that it needs filling at first glance because the word swatch is in it, so I had not noticed on conversion...

As soon as I put a value in it the swatches worked right

swatch column

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.