0

I need to be able to reference product attributes inside a cms block or page builder, I am not wanting to create any template files I am wanting to call it like you can call a variable.

So here is one of Magento's standard variables which outputs the base url from the config.

{{config path="web/unsecure/base_url"}}

What I need to know is there anyway you can do this for product attributes.

Or if someone knows how to create a set of custom variables which call the data from a product attribute would be great.

1 Answer 1

0

use this code in phtml file to call your attribute –

<?php
/**
 * @var Magento\Catalog\Block\Product\View $block
 */
$product = $block->getProduct();
?>
<h1 style="color: #1979c3">Brand:<?php echo $product->getData('brand'); ?></h1>
4
  • use this code in phtml file to call your attribute May 11 at 13:46
  • As per my question I don't want this done in a phtml file but inside a cms block as I already know how to achieve this in a phtml file, but thanks for the response.
    – Andyjw
    May 12 at 8:38
  • please let us know when you find your answer May 13 at 6:00
  • seems like I am going to have to make a module to achieve this, would have thought you would be able to call these easily.
    – Andyjw
    2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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