Magento 2 How to change position for buttons on product add/edit form?Magento2 : How to add delete button in custom form in backendMagento2 : How to add Custom button in product edit formHow to use Magento 2 product add/edit form category tree structure in custom form?How to create custom “Duplicate” buttons for Adminhtml Form in Magento2?How to add Category tree structure like product edit/add in custom module Magento 2 [Solved]No Buttons For Adminhtml FormMagento 2 - How to add,save,display custom Field in Product Edit form using UiComponent?Magento 2 frontend uicomponent form buttons not appearingOpen a popup with form on click of link/button on customer edit form at back end Magento 2Magento 2 How to make “Save” button same as “Save & Close” on product add/edit?
"You are your self first supporter", a more proper way to say it
Why don't electron-positron collisions release infinite energy?
XeLaTeX and pdfLaTeX ignore hyphenation
I probably found a bug with the sudo apt install function
Infinite past with a beginning?
What would the Romans have called "sorcery"?
Why Is Death Allowed In the Matrix?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
How to add power-LED to my small amplifier?
Prevent a directory in /tmp from being deleted
Can I interfere when another PC is about to be attacked?
How to type dʒ symbol (IPA) on Mac?
Can I make popcorn with any corn?
Is there really no realistic way for a skeleton monster to move around without magic?
Are there any consumables that function as addictive (psychedelic) drugs?
Download, install and reboot computer at night if needed
Patience, young "Padovan"
If Manufacturer spice model and Datasheet give different values which should I use?
Why CLRS example on residual networks does not follows its formula?
What is the command to reset a PC without deleting any files
Motorized valve interfering with button?
What is the offset in a seaplane's hull?
Magento 2 How to change position for buttons on product add/edit form?
Magento2 : How to add delete button in custom form in backendMagento2 : How to add Custom button in product edit formHow to use Magento 2 product add/edit form category tree structure in custom form?How to create custom “Duplicate” buttons for Adminhtml Form in Magento2?How to add Category tree structure like product edit/add in custom module Magento 2 [Solved]No Buttons For Adminhtml FormMagento 2 - How to add,save,display custom Field in Product Edit form using UiComponent?Magento 2 frontend uicomponent form buttons not appearingOpen a popup with form on click of link/button on customer edit form at back end Magento 2Magento 2 How to make “Save” button same as “Save & Close” on product add/edit?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How can I change the position of Save, Save & Close buttons on the product add/edit?
I need to place the "Save & close" button first instead of "Save" button on the product add/edit form.
How can I achieve this?
magento2 product
add a comment |
How can I change the position of Save, Save & Close buttons on the product add/edit?
I need to place the "Save & close" button first instead of "Save" button on the product add/edit form.
How can I achieve this?
magento2 product
add a comment |
How can I change the position of Save, Save & Close buttons on the product add/edit?
I need to place the "Save & close" button first instead of "Save" button on the product add/edit form.
How can I achieve this?
magento2 product
How can I change the position of Save, Save & Close buttons on the product add/edit?
I need to place the "Save & close" button first instead of "Save" button on the product add/edit form.
How can I achieve this?
magento2 product
magento2 product
asked Apr 4 at 13:37
Utsav GuptaUtsav Gupta
443215
443215
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try following way:
app/code/SR/MagentoCommunity/etc/adminhtml/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="MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave">
<plugin name="SR_MagentoCommunity::change_product_button_position"
type="SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButtonSave" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Block/Adminhtml/Product/Edit/Button/Save.php
<?php
namespace SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButton;
use MagentoCatalogApiDataProductInterface;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewElementUiComponentContext;
use MagentoUiComponentControlContainer;
use MagentoConfigurableProductModelProductTypeConfigurable as ConfigurableType;
class Save
/**
* Url Builder
*
* @var Context
*/
protected $context;
/**
* Registry
*
* @var Registry
*/
protected $registry;
/**
* Generic constructor
*
* @param Context $context
* @param Registry $registry
*/
public function __construct(
Context $context,
Registry $registry
)
$this->context = $context;
$this->registry = $registry;
/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
return $this->context->getUrl($route, $params);
/**
* Get product
*
* @return ProductInterface
*/
public function getProduct()
return $this->registry->registry('current_product');
public function aroundGetButtonData(
MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave $subject,
Closure $proceed
)
//return $proceed();
if ($this->getProduct()->isReadonly())
return [];
return [
'id_hard' => 'save_and_close',
'label' => __('Save & Close'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true
]
]
]
]
]
],
'class_name' => Container::SPLIT_BUTTON,
'options' => $this->getOptions(),
];
/**
* Retrieve options
*
* @return array
*/
protected function getOptions()
$options[] = [
'id_hard' => 'save-button',
'label' => __('Save'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
false
]
]
]
]
]
],
];
$options[] = [
'id_hard' => 'save_and_new',
'label' => __('Save & New'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'new'
]
]
]
]
]
]
],
];
if (!$this->context->getRequestParam('popup') && $this->getProduct()->isDuplicable())
$options[] = [
'label' => __('Save & Duplicate'),
'id_hard' => 'save_and_duplicate',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'duplicate'
]
]
]
]
]
]
],
];
return $options;
/**
* Retrieve target for button.
*
* @return string
*/
protected function getSaveTarget()
$target = 'product_form.product_form';
if ($this->isConfigurableProduct())
$target = 'product_form.product_form.configurableVariations';
return $target;
/**
* Retrieve action for button.
*
* @return string
*/
protected function getSaveAction()
$action = 'save';
if ($this->isConfigurableProduct())
$action = 'saveFormHandler';
return $action;
/**
* Is configurable product.
*
* @return boolean
*/
protected function isConfigurableProduct()
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
For all product types
– Sohel Rana
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
add a comment |
Modify them with CSS. Make their container display:flex
add a flex-direction
and then on the save & close button put order:1
and order:2
on the save button. Here is a link for reference https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268801%2fmagento-2-how-to-change-position-for-buttons-on-product-add-edit-form%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try following way:
app/code/SR/MagentoCommunity/etc/adminhtml/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="MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave">
<plugin name="SR_MagentoCommunity::change_product_button_position"
type="SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButtonSave" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Block/Adminhtml/Product/Edit/Button/Save.php
<?php
namespace SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButton;
use MagentoCatalogApiDataProductInterface;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewElementUiComponentContext;
use MagentoUiComponentControlContainer;
use MagentoConfigurableProductModelProductTypeConfigurable as ConfigurableType;
class Save
/**
* Url Builder
*
* @var Context
*/
protected $context;
/**
* Registry
*
* @var Registry
*/
protected $registry;
/**
* Generic constructor
*
* @param Context $context
* @param Registry $registry
*/
public function __construct(
Context $context,
Registry $registry
)
$this->context = $context;
$this->registry = $registry;
/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
return $this->context->getUrl($route, $params);
/**
* Get product
*
* @return ProductInterface
*/
public function getProduct()
return $this->registry->registry('current_product');
public function aroundGetButtonData(
MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave $subject,
Closure $proceed
)
//return $proceed();
if ($this->getProduct()->isReadonly())
return [];
return [
'id_hard' => 'save_and_close',
'label' => __('Save & Close'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true
]
]
]
]
]
],
'class_name' => Container::SPLIT_BUTTON,
'options' => $this->getOptions(),
];
/**
* Retrieve options
*
* @return array
*/
protected function getOptions()
$options[] = [
'id_hard' => 'save-button',
'label' => __('Save'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
false
]
]
]
]
]
],
];
$options[] = [
'id_hard' => 'save_and_new',
'label' => __('Save & New'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'new'
]
]
]
]
]
]
],
];
if (!$this->context->getRequestParam('popup') && $this->getProduct()->isDuplicable())
$options[] = [
'label' => __('Save & Duplicate'),
'id_hard' => 'save_and_duplicate',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'duplicate'
]
]
]
]
]
]
],
];
return $options;
/**
* Retrieve target for button.
*
* @return string
*/
protected function getSaveTarget()
$target = 'product_form.product_form';
if ($this->isConfigurableProduct())
$target = 'product_form.product_form.configurableVariations';
return $target;
/**
* Retrieve action for button.
*
* @return string
*/
protected function getSaveAction()
$action = 'save';
if ($this->isConfigurableProduct())
$action = 'saveFormHandler';
return $action;
/**
* Is configurable product.
*
* @return boolean
*/
protected function isConfigurableProduct()
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
For all product types
– Sohel Rana
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
add a comment |
Try following way:
app/code/SR/MagentoCommunity/etc/adminhtml/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="MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave">
<plugin name="SR_MagentoCommunity::change_product_button_position"
type="SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButtonSave" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Block/Adminhtml/Product/Edit/Button/Save.php
<?php
namespace SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButton;
use MagentoCatalogApiDataProductInterface;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewElementUiComponentContext;
use MagentoUiComponentControlContainer;
use MagentoConfigurableProductModelProductTypeConfigurable as ConfigurableType;
class Save
/**
* Url Builder
*
* @var Context
*/
protected $context;
/**
* Registry
*
* @var Registry
*/
protected $registry;
/**
* Generic constructor
*
* @param Context $context
* @param Registry $registry
*/
public function __construct(
Context $context,
Registry $registry
)
$this->context = $context;
$this->registry = $registry;
/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
return $this->context->getUrl($route, $params);
/**
* Get product
*
* @return ProductInterface
*/
public function getProduct()
return $this->registry->registry('current_product');
public function aroundGetButtonData(
MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave $subject,
Closure $proceed
)
//return $proceed();
if ($this->getProduct()->isReadonly())
return [];
return [
'id_hard' => 'save_and_close',
'label' => __('Save & Close'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true
]
]
]
]
]
],
'class_name' => Container::SPLIT_BUTTON,
'options' => $this->getOptions(),
];
/**
* Retrieve options
*
* @return array
*/
protected function getOptions()
$options[] = [
'id_hard' => 'save-button',
'label' => __('Save'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
false
]
]
]
]
]
],
];
$options[] = [
'id_hard' => 'save_and_new',
'label' => __('Save & New'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'new'
]
]
]
]
]
]
],
];
if (!$this->context->getRequestParam('popup') && $this->getProduct()->isDuplicable())
$options[] = [
'label' => __('Save & Duplicate'),
'id_hard' => 'save_and_duplicate',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'duplicate'
]
]
]
]
]
]
],
];
return $options;
/**
* Retrieve target for button.
*
* @return string
*/
protected function getSaveTarget()
$target = 'product_form.product_form';
if ($this->isConfigurableProduct())
$target = 'product_form.product_form.configurableVariations';
return $target;
/**
* Retrieve action for button.
*
* @return string
*/
protected function getSaveAction()
$action = 'save';
if ($this->isConfigurableProduct())
$action = 'saveFormHandler';
return $action;
/**
* Is configurable product.
*
* @return boolean
*/
protected function isConfigurableProduct()
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
For all product types
– Sohel Rana
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
add a comment |
Try following way:
app/code/SR/MagentoCommunity/etc/adminhtml/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="MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave">
<plugin name="SR_MagentoCommunity::change_product_button_position"
type="SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButtonSave" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Block/Adminhtml/Product/Edit/Button/Save.php
<?php
namespace SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButton;
use MagentoCatalogApiDataProductInterface;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewElementUiComponentContext;
use MagentoUiComponentControlContainer;
use MagentoConfigurableProductModelProductTypeConfigurable as ConfigurableType;
class Save
/**
* Url Builder
*
* @var Context
*/
protected $context;
/**
* Registry
*
* @var Registry
*/
protected $registry;
/**
* Generic constructor
*
* @param Context $context
* @param Registry $registry
*/
public function __construct(
Context $context,
Registry $registry
)
$this->context = $context;
$this->registry = $registry;
/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
return $this->context->getUrl($route, $params);
/**
* Get product
*
* @return ProductInterface
*/
public function getProduct()
return $this->registry->registry('current_product');
public function aroundGetButtonData(
MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave $subject,
Closure $proceed
)
//return $proceed();
if ($this->getProduct()->isReadonly())
return [];
return [
'id_hard' => 'save_and_close',
'label' => __('Save & Close'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true
]
]
]
]
]
],
'class_name' => Container::SPLIT_BUTTON,
'options' => $this->getOptions(),
];
/**
* Retrieve options
*
* @return array
*/
protected function getOptions()
$options[] = [
'id_hard' => 'save-button',
'label' => __('Save'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
false
]
]
]
]
]
],
];
$options[] = [
'id_hard' => 'save_and_new',
'label' => __('Save & New'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'new'
]
]
]
]
]
]
],
];
if (!$this->context->getRequestParam('popup') && $this->getProduct()->isDuplicable())
$options[] = [
'label' => __('Save & Duplicate'),
'id_hard' => 'save_and_duplicate',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'duplicate'
]
]
]
]
]
]
],
];
return $options;
/**
* Retrieve target for button.
*
* @return string
*/
protected function getSaveTarget()
$target = 'product_form.product_form';
if ($this->isConfigurableProduct())
$target = 'product_form.product_form.configurableVariations';
return $target;
/**
* Retrieve action for button.
*
* @return string
*/
protected function getSaveAction()
$action = 'save';
if ($this->isConfigurableProduct())
$action = 'saveFormHandler';
return $action;
/**
* Is configurable product.
*
* @return boolean
*/
protected function isConfigurableProduct()
Try following way:
app/code/SR/MagentoCommunity/etc/adminhtml/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="MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave">
<plugin name="SR_MagentoCommunity::change_product_button_position"
type="SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButtonSave" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Block/Adminhtml/Product/Edit/Button/Save.php
<?php
namespace SRMagentoCommunityPluginCatalogBlockAdminhtmlProductEditButton;
use MagentoCatalogApiDataProductInterface;
use MagentoFrameworkRegistry;
use MagentoFrameworkViewElementUiComponentContext;
use MagentoUiComponentControlContainer;
use MagentoConfigurableProductModelProductTypeConfigurable as ConfigurableType;
class Save
/**
* Url Builder
*
* @var Context
*/
protected $context;
/**
* Registry
*
* @var Registry
*/
protected $registry;
/**
* Generic constructor
*
* @param Context $context
* @param Registry $registry
*/
public function __construct(
Context $context,
Registry $registry
)
$this->context = $context;
$this->registry = $registry;
/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
return $this->context->getUrl($route, $params);
/**
* Get product
*
* @return ProductInterface
*/
public function getProduct()
return $this->registry->registry('current_product');
public function aroundGetButtonData(
MagentoConfigurableProductBlockAdminhtmlProductEditButtonSave $subject,
Closure $proceed
)
//return $proceed();
if ($this->getProduct()->isReadonly())
return [];
return [
'id_hard' => 'save_and_close',
'label' => __('Save & Close'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true
]
]
]
]
]
],
'class_name' => Container::SPLIT_BUTTON,
'options' => $this->getOptions(),
];
/**
* Retrieve options
*
* @return array
*/
protected function getOptions()
$options[] = [
'id_hard' => 'save-button',
'label' => __('Save'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
false
]
]
]
]
]
],
];
$options[] = [
'id_hard' => 'save_and_new',
'label' => __('Save & New'),
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'new'
]
]
]
]
]
]
],
];
if (!$this->context->getRequestParam('popup') && $this->getProduct()->isDuplicable())
$options[] = [
'label' => __('Save & Duplicate'),
'id_hard' => 'save_and_duplicate',
'data_attribute' => [
'mage-init' => [
'buttonAdapter' => [
'actions' => [
[
'targetName' => $this->getSaveTarget(),
'actionName' => $this->getSaveAction(),
'params' => [
true,
[
'back' => 'duplicate'
]
]
]
]
]
]
],
];
return $options;
/**
* Retrieve target for button.
*
* @return string
*/
protected function getSaveTarget()
$target = 'product_form.product_form';
if ($this->isConfigurableProduct())
$target = 'product_form.product_form.configurableVariations';
return $target;
/**
* Retrieve action for button.
*
* @return string
*/
protected function getSaveAction()
$action = 'save';
if ($this->isConfigurableProduct())
$action = 'saveFormHandler';
return $action;
/**
* Is configurable product.
*
* @return boolean
*/
protected function isConfigurableProduct()
answered Apr 4 at 14:31
Sohel RanaSohel Rana
23.1k34461
23.1k34461
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
For all product types
– Sohel Rana
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
add a comment |
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
For all product types
– Sohel Rana
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
Should this code work with configurable product or all type of products?
– Utsav Gupta
2 days ago
For all product types
– Sohel Rana
2 days ago
For all product types
– Sohel Rana
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
One quick question I have what is the use of "getUrl()" function here? is it necessary?
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
Thanks for your support. it is working for all products. :)
– Utsav Gupta
2 days ago
add a comment |
Modify them with CSS. Make their container display:flex
add a flex-direction
and then on the save & close button put order:1
and order:2
on the save button. Here is a link for reference https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
add a comment |
Modify them with CSS. Make their container display:flex
add a flex-direction
and then on the save & close button put order:1
and order:2
on the save button. Here is a link for reference https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
add a comment |
Modify them with CSS. Make their container display:flex
add a flex-direction
and then on the save & close button put order:1
and order:2
on the save button. Here is a link for reference https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items
Modify them with CSS. Make their container display:flex
add a flex-direction
and then on the save & close button put order:1
and order:2
on the save button. Here is a link for reference https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Ordering_Flex_Items
answered Apr 4 at 13:43
mluntmlunt
8619
8619
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
add a comment |
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Thanks for your help but it will only show the dropdown options as buttons. but I need to change the position of buttons and show "save & close" as first instead of "Save" button.
– Utsav Gupta
Apr 4 at 14:03
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
Can you add a screenshot of what you're looking at so I can better understand?
– mlunt
Apr 4 at 14:09
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268801%2fmagento-2-how-to-change-position-for-buttons-on-product-add-edit-form%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown