cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with Tabs. Moving sourcecode from Magento/Catalog to my own component.

Need help with Tabs. Moving sourcecode from Magento/Catalog to my own component.

Hi guys, I was able to add a custom tab with additional textfields through the tutorial found in http://www.datasheat.com/tutos/ajouter-une-nouvelle-tab-et-form-custom-tab-dans-la-page-%C3%A9dition...

What I want to do next is move the codes into my own component (Rahaha/MyComponent).  The tutorial was unfortunately editting the Magento/Catalog component and I was wondering what I should do with the 2 codes below which were added to catalog_product_new.xml and Tabs.php respectively.  

 

Magento\Catalog\view\adminhtml\layout\catalog_product_new.xml

<block class="Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\CustomTab" name="product_tabs.customtab" as="custom-tab">
    <arguments>
        <argument name="label" xsi:type="string" translate="true">Custom Tab</argument>
     
    </arguments>
</block>

Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs.php

    $this->addTab(
    'custom-tab', [
        'label' => __('Custom Tab'),
        'content' => $this->_translateHtml(
            $this->getChildHtml('custom-tab')
        ),
        'group_code' => self::BASIC_TAB_GROUP_CODE
    ]
    );
2 REPLIES 2

Re: Need help with Tabs. Moving sourcecode from Magento/Catalog to my own component.

Create an "after" plugin, and call the addTab() there:

http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html

 

There is also a simpler solution without plugins and core files editing:

How to add a tab to a backend product view? https://mage2.pro/t/382

Re: Need help with Tabs. Moving sourcecode from Magento/Catalog to my own component.

Hi Dmitry,

Thanks a lot for the reply.  I tested out the simpler solution but I can't make it work.  May I know how the arguments for the block should be configured in relation to the Tab class I have?  This is the CustomTab:

 

<?php
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab;
 
class CustomTab extends \Magento\Backend\Block\Widget
{
   protected $_template = 'catalog/product/tab/customtab.phtml';
 
   public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        array $data = []
    ) {
       parent::__construct($context, $data);
    }
}

How do I change this setting:  

<argument name="url" xsi:type="url" path="review/product_reviews/grid">