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.

2 Answers 2

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>
5
  • use this code in phtml file to call your attribute
    – IZANOVA
    May 11, 2022 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, 2022 at 8:38
  • please let us know when you find your answer
    – IZANOVA
    May 13, 2022 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
    May 18, 2022 at 8:42
  • In the end we had to create a module to achieve this.
    – Andyjw
    Jan 26 at 9:55
0

So in the end we created a custom module which you could call the attributes via a widget into page builder or any content blocks.

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.