How to add tab in product edit page in magento2?
I refering some tutorial ...but its not woking for me...
https://webkul.com/blog/add-tab-product-page-magento-admin/
If anyone knows ,Explain me...
How to add tab in product edit page in magento2?
I refering some tutorial ...but its not woking for me...
https://webkul.com/blog/add-tab-product-page-magento-admin/
If anyone knows ,Explain me...
You can add custom tab using UI component
- app/code/Namespace/Modulename/view/adminhtml/ui_component/product_form.xml
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="demotab">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Demo Tab</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="number">100</item>
</item>
</argument>
<container name="fieldname_container" >
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sortOrder" xsi:type="number">160</item>
</item>
</argument>
<htmlContent name="html_content_demo">
<argument name="block" xsi:type="object">Namespace\Modulename\Block\Adminhtml\Catalog\Product\Edit\Tab\Demo</argument>
</htmlContent>
</container>
</fieldset>
</form>
- app/code/Namespace/Modulename/Block/Adminhtml/Catalog/Product/Edit/Tab/Demo.php
<?php
namespace Namespace\Modulename\Block\Adminhtml\Catalog\Product\Edit\Tab;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
class Demo extends \Magento\Framework\View\Element\Template
{
/**
* @var string
*/
protected $_template = 'product/edit/demo.phtml';
/**
* Core registry
*
* @var Registry
*/
protected $_coreRegistry = null;
public function __construct(
Context $context,
Registry $registry,
array $data = []
)
{
$this->_coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* Retrieve product
*
* @return \Magento\Catalog\Model\Product
*/
public function getProduct()
{
return $this->_coreRegistry->registry('current_product');
}
}
- app/code/Namespace/Modulename/view/adminhtml/templates/product/edit/demo.phtml
<?php echo "This is demo tab content."; ?>