I'd like to display the unit of measurement after each product attribute with some dimension (mm, g, …).
To prevent duplicated code in each PHTML template file that probably displays a product with attributes, I thought it might be a good idea, to add a handler to the output helper, which could append those units.
For example attributes.phtml
uses <?= $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
to output the attributes value. I guess the sense behind using $_helper->productAttribute
instead of simply outputting $_data['value']
, is that the value might be translated to another format or something similar.
From the code in the Magento\Catalog\Helper\Output
-helper, I figured out, that one might add handlers to the output helper. But I couldn't find any documentation on how to do so or where to add such a handler.