Skip to content

Add a button inside the “Product Name” attribute of a product in my Magento AdminPanel

I would like to add a button to the ‘Product Name’ attribute within the product information tab, but I’m unsure of how to achieve this. Below is my product_form.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">product_form.product_form_data_source</item>
            <item name="namespace" xsi:type="string">product_form</item>
        </item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
        <item name="childrenFromMeta" xsi:type="boolean">true</item>
    </argument>
    <settings>
        <reloadItem>product-details.attribute_set_id:value</reloadItem>
        <buttons>
            <button name="save" class="MagentoCatalogBlockAdminhtmlProductEditButtonSave"/>
            <button name="addAttribute" class="MagentoCatalogBlockAdminhtmlProductEditButtonAddAttribute"/>
            <button name="back" class="MagentoCatalogBlockAdminhtmlProductEditButtonBack"/>
            <button name="ai" class="ImprooveTaskBlockAdminhtmlProductEditButtonCustomButton"/>
        </buttons>
        <deps>
            <dep>product_form.product_form_data_source</dep>
        </deps>
    </settings>
    <dataSource name="product_form_data_source">
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
            </item>
        </argument>
        <dataProvider class="MagentoCatalogUiDataProviderProductFormProductDataProvider" name="product_form_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>entity_id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <htmlContent name="gallery" sortOrder="22">
        <argument name="data" xsi:type="array">
            <item name="wrapper" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">Images</item>
                <item name="collapsible" xsi:type="boolean">true</item>
                <item name="opened" xsi:type="boolean">false</item>
            </item>
        </argument>
        <settings>
            <wrapper>
                <canShow>true</canShow>
                <componentType>fieldset</componentType>
            </wrapper>
        </settings>
        <block name="gallery" class="MagentoCatalogBlockAdminhtmlProductHelperFormGallery">
            <block class="MagentoCatalogBlockAdminhtmlProductHelperFormGalleryContent" as="content">
                <arguments>
                    <argument name="config" xsi:type="array">
                        <item name="parentComponent" xsi:type="string">product_form.product_form.block_gallery.block_gallery</item>
                    </argument>
                </arguments>
                <block class="MagentoProductVideoBlockAdminhtmlProductEditNewVideo" name="new-video" template="Magento_ProductVideo::product/edit/slideout/form.phtml"/>
            </block>
        </block>
    </htmlContent>
</form>

What do I need to do?