I have added a custom button in product edit page using product_form.xml
like below :
app/code/Company/Module/view/adminhtml/ui_component/product_form.xml
<?xml version="1.0" encoding="UTF-8"?>
<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="buttons" xsi:type="array">
<item name="set-to-sold" xsi:type="string">Company\Module\Block\Adminhtml\Product\Edit\Button\SoldButton</item>
</item>
</argument>
</form>
app/code/Company/Module/Block/Adminhtml/Product/Edit/Button/SoldButton.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Brainvire\ProductType\Block\Adminhtml\Product\Edit\Button;
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Generic;
class SoldButton extends Generic
{
/**
* @return array
*/
public function getButtonData()
{
return [
'label' => __('Diamond is SOLD'),
'disabled' => true,
'on_click' => sprintf("location.href = '%s';", $this->getUrl('producttype/product/sold')),
'class' => 'save primary',
'sort_order' => 5,
];
}
}
the button is added like below :
This is working perfectly. A button is added, and a confirm box is also displayed on button click. But now i want to add a popup and call custom phtml in that popup on button click.
Any ideas how to proceed. Thanks in advance.
phtml
file in alert widget popup. there is no parameter to set template see here devdocs.magento.com/guides/v2.3/javascript-dev-guide/widgets/…