0

I want to setup a method to get image URLs for category icons like pub/catalog/images/offer.png

What do I have to do for it?

This is what I am trying to build:

enter image description here

And this is the URL I need:

$vdrawMainMenu = str_replace('Phones, Tablets & Accessories', '<img src="http://localhost/kikinben/pub/static/frontend/Alothemes/default/en_US/Magento_Catalog/images/mobile.png" style="width:20px">Phones, Tablets & Accessories', $vdrawMainMenu);
1

1 Answer 1

0

In a template, you can use

$block->getViewFileUrl('Magento_Catalog::images/offer.png');

If you do it in a block method, use $this instead of $block

2

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.