Magento 2 Get Attribute Swatch color hashcode by option id

We can get hash code value of specific visual swatch by swatch option id.
We have created Color Product attribute from Stores -> Attributes -> Product.
Color attribute code with Catalog Input Type for Store Owner set to Visual swatch.

Now We can get the color hash code by color option id using below code snippet.

Call getAtributeSwatchHashcode() function from template,

The result will be like color Red hashcode is #FF0000

Leave a Reply

Your email address will not be published. Required fields are marked *