1

Magento 2.0.7: How to create a custom module that will add a new tab on product edit page, right under Basic Settings and i want to display my custom phtml page. ?

view\adminhtml\layout\catalog_product_new.xml

<?xml version="1.0"?>
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
  <referenceBlock name="product_tabs">
   <block class="Magento2\Tutorial9\Block\Adminhtml\Product\Edit\Tab\Welcome" name="product.welcome" as="custom-tab" >
    <arguments>
     <argument name="config" xsi:type="array">
      <item name="label" xsi:type="string" translate="true">Product Welcome</item>
      <item name="collapsible" xsi:type="boolean">true</item>
      <item name="opened" xsi:type="boolean">true</item>
      <item name="sortOrder" xsi:type="string">2</item>
      <item name="canShow" xsi:type="boolean">true</item>
      <item name="componentType" xsi:type="string">fieldset</item>
     </argument>
    </arguments>
  </block>
</referenceBlock>

Block\Adminhtml\Product\Edit\Tab\Welcome.php

namespace Magento2\Tutorial9\Block\Adminhtml\Product\Edit\Tab;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
class Welcome extends \Magento\Framework\View\Element\Template{
 protected $_template = 'catalog/product/edit/welcome.phtml';
 protected $_coreRegistry = null;
 public function __construct(
   Context $context,
   Registry $registry,
   array $data = []
 )
 {
    $this->_coreRegistry = $registry;
    parent::__construct($context, $data);
}
public function getProduct(){
   return $this->_coreRegistry->registry('current_product');
}   }

view\adminhtml\templates\catalog\product\edit\welcome.phtml

<div class="welcome">
    <?php echo __('Welcome !'); ?>
</div>

etc\module.xml

<?xml version="1.0"?>
   <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
  <module name="Magento2_Tutorial9" setup_version="1.0.0">
</module>

registration.php

<?php \Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Magento2_Tutorial9',
__DIR__
);

closed as too broad by Keyul Shah, liyakat, Rakesh Jesadiya, brentwpeterson, Ashish Jagnani May 18 '17 at 10:30

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.