I'm looking to add custom product attributes to the product page. Basically adding a block under the title to list product attributes.

I looked at echoing out the attributes in


file but that seemed messy. So I was hoping there'd be a way to add a custom block to the xml and then rendering my own .phtml file? That way I'm keeping the core code seperate from my own (obviously I'm adding all this into my own theme files and not touching the vendor files.)

Would this be possible and/or the best way?


In app\code\Namespace\Modulename\view\frontend\layout\catalog_product_view.xml add like below code. You can use your required referenceContainer

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="alert.urls">
            <block class="Namespace\Modulename\Block\Catalog\Product\View\Module" name="textblock" as="textblock" after="-" template="catalog/product/view/textblock.phtml" />

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.