Categories
CMS Development Magento

Add block to bundle fieldset

I am trying to add a block to the configure screen of bundled products in the create order form of admin.

I added this layout file: My/Module/view/adminhtml/layout/catalog_product_view_type_bundle.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product.composite.fieldset.bundle">
            <block class="My\Module\Block\Adminhtml\FooBar" name="product.composite.fieldset.bundle.foobar" template="My_Module::foobar.phtml" after="-"/>
        </referenceBlock>
    </body>
</page>

I added this block file: My/Module/Block/Adminhtml/FooBar.php

<?php
namespace My\Module\Block\Adminhtml;

class FooBar extends \Magento\Framework\View\Element\Template
{
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context
    ) {
        parent::__construct($context);
    }

    public function sayHello()
    {
        return __('hello');
    }
}

I added this template file: My/Module/view/adminhtml/templates/foobar.phtml

<?php echo "<h1>HELLO HELLO HELLO</h1>"; ?>

And finally I clear the cache and compile:

magento c:c
magento s:d:c

But I don’t see any big-ole HELLOs in the page. What am I doing wrong?

Leave a Reply

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