0

enter image description here

I want to add some text to the admin product view in Magento 2 please help me, someone.check the screeshot where i want to show some info.

0

You can make use of After plugin to achieve your goal. Below are the general steps to follow (I assume that you know how to create a custom module from scratch):

Step 1. Create a custom module (Say: Stack_ProductPlugin) and define a plugin in app/code/Stack/ProductPlugin/etc/di.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery">
        <plugin name="add_gallery_text" type="Stack\ProductPlugin\Plugin\Gallery" sortOrder="-1" />
    </type>
</config>

Step 2: Create the plugin file Gallery.php at app/code/Stack/ProductPlugin/Plugin path and add the following code:

<?php
namespace Stack\ProductPlugin\Plugin;
class Gallery
{
    public function afterGetElementHtml(\Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery $subject, $result) {
        return "my custom text".$result;
    }
}

After refreshing the cache, you should be able to see the text my custom text above gallery.

| improve this answer | |

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.