Magento 2 How to prevent product save with custom condition using plugin 'aroundSave'?Rewriting Magento 2 classes vs PluginsMagento2: plugin around method not workingMagento 2 adminhtml getUrl not working as expectedMagento 2.1 Create a filter in the product grid by new attributeHow do I get a methods argument for an after plugin in Magento 2?Magento 2.2.5: Add, Update and Delete existing products Custom OptionsCreating Single Sign-on - Logging in admin throws “Your current session has been expired.”Magento 2 plugin change price of products that have a custom attribute withEvent fire before save invoice in `sales_invoice` tableMagento 2 validate the form input using plugin and save the modified data
Where have Brexit voters gone?
Did people Unsnap to where they were?
Where can I find visible/radio telescopic observations of the center of the Milky Way galaxy?
Inclusion of standard error in regression equation
Does Nitrogen inside commercial airliner wheels prevent blowouts on touchdown?
Any advice on creating fictional locations in real places when writing historical fiction?
Count rotary dial pulses in a phone number (including letters)
What was the idiom for something that we take without a doubt?
How long until a random word with letters "A", "B", "C" ends in the pattern "ABC"?
What is the object moving across the ceiling in this stock footage?
Is real public IP Address hidden when using a system wide proxy in Windows 10?
How strong are Wi-Fi signals?
At what point in European history could a government build a printing press given a basic description?
Maxima of Brownian motion
What does this symbol on the box of power supply mean?
Why did David Cameron offer a referendum on the European Union?
Count Even Digits In Number
Employer asking for online access to bank account - Is this a scam?
Looking for a soft substance that doesn't dissolve underwater
A steel cutting sword?
My employer faked my resume to acquire projects
Is it rude to call a professor by their last name with no prefix in a non-academic setting?
Caught 2 students cheating together on the final exam that I proctored
What does the view outside my ship traveling at light speed look like?
Magento 2 How to prevent product save with custom condition using plugin 'aroundSave'?
Rewriting Magento 2 classes vs PluginsMagento2: plugin around method not workingMagento 2 adminhtml getUrl not working as expectedMagento 2.1 Create a filter in the product grid by new attributeHow do I get a methods argument for an after plugin in Magento 2?Magento 2.2.5: Add, Update and Delete existing products Custom OptionsCreating Single Sign-on - Logging in admin throws “Your current session has been expired.”Magento 2 plugin change price of products that have a custom attribute withEvent fire before save invoice in `sales_invoice` tableMagento 2 validate the form input using plugin and save the modified data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to prevent to save the product with my custom condition, for that, I want to use the plugin with method 'aroundSave',
- When the user clicks on 'Save & Duplicate' button I do not want to save the original product simply duplicate the product.
Is the plugin method is correct or I need to override the controller or use catalog_product_save_befor event?
Anyone have any example please share.
for example,
namespace VendorModulePlugin;
class Save
public function aroundExecute(MagentoCatalogControllerAdminhtmlProductSave $subject, $result)
if (some condition == true)
then save product
else
not save the product
How can I achieve this functionality?
magento2 product plugin
add a comment |
I want to prevent to save the product with my custom condition, for that, I want to use the plugin with method 'aroundSave',
- When the user clicks on 'Save & Duplicate' button I do not want to save the original product simply duplicate the product.
Is the plugin method is correct or I need to override the controller or use catalog_product_save_befor event?
Anyone have any example please share.
for example,
namespace VendorModulePlugin;
class Save
public function aroundExecute(MagentoCatalogControllerAdminhtmlProductSave $subject, $result)
if (some condition == true)
then save product
else
not save the product
How can I achieve this functionality?
magento2 product plugin
add a comment |
I want to prevent to save the product with my custom condition, for that, I want to use the plugin with method 'aroundSave',
- When the user clicks on 'Save & Duplicate' button I do not want to save the original product simply duplicate the product.
Is the plugin method is correct or I need to override the controller or use catalog_product_save_befor event?
Anyone have any example please share.
for example,
namespace VendorModulePlugin;
class Save
public function aroundExecute(MagentoCatalogControllerAdminhtmlProductSave $subject, $result)
if (some condition == true)
then save product
else
not save the product
How can I achieve this functionality?
magento2 product plugin
I want to prevent to save the product with my custom condition, for that, I want to use the plugin with method 'aroundSave',
- When the user clicks on 'Save & Duplicate' button I do not want to save the original product simply duplicate the product.
Is the plugin method is correct or I need to override the controller or use catalog_product_save_befor event?
Anyone have any example please share.
for example,
namespace VendorModulePlugin;
class Save
public function aroundExecute(MagentoCatalogControllerAdminhtmlProductSave $subject, $result)
if (some condition == true)
then save product
else
not save the product
How can I achieve this functionality?
magento2 product plugin
magento2 product plugin
edited May 20 at 9:23
Utsav Gupta
asked May 20 at 6:29
Utsav GuptaUtsav Gupta
457215
457215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
That would be because the admin product form doesn't actually use ProductRepository
, at least as of 2.2.2.
vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php:
$product->save();
You haven't explained what you're actually trying to accomplish, but you would probably be better served by an observer on event catalog_product_save_before
or catalog_product_save_after
. Those are kicked off by the product resource model, so they should fire regardless of whether the product is saved via ProductRepository
or directly.
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
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%2f275212%2fmagento-2-how-to-prevent-product-save-with-custom-condition-using-plugin-around%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
That would be because the admin product form doesn't actually use ProductRepository
, at least as of 2.2.2.
vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php:
$product->save();
You haven't explained what you're actually trying to accomplish, but you would probably be better served by an observer on event catalog_product_save_before
or catalog_product_save_after
. Those are kicked off by the product resource model, so they should fire regardless of whether the product is saved via ProductRepository
or directly.
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
add a comment |
That would be because the admin product form doesn't actually use ProductRepository
, at least as of 2.2.2.
vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php:
$product->save();
You haven't explained what you're actually trying to accomplish, but you would probably be better served by an observer on event catalog_product_save_before
or catalog_product_save_after
. Those are kicked off by the product resource model, so they should fire regardless of whether the product is saved via ProductRepository
or directly.
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
add a comment |
That would be because the admin product form doesn't actually use ProductRepository
, at least as of 2.2.2.
vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php:
$product->save();
You haven't explained what you're actually trying to accomplish, but you would probably be better served by an observer on event catalog_product_save_before
or catalog_product_save_after
. Those are kicked off by the product resource model, so they should fire regardless of whether the product is saved via ProductRepository
or directly.
That would be because the admin product form doesn't actually use ProductRepository
, at least as of 2.2.2.
vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php:
$product->save();
You haven't explained what you're actually trying to accomplish, but you would probably be better served by an observer on event catalog_product_save_before
or catalog_product_save_after
. Those are kicked off by the product resource model, so they should fire regardless of whether the product is saved via ProductRepository
or directly.
answered May 20 at 6:36
Rk RathodRk Rathod
2,041214
2,041214
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
add a comment |
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
please check updated question. thanks for your help.
– Utsav Gupta
May 20 at 7:18
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%2f275212%2fmagento-2-how-to-prevent-product-save-with-custom-condition-using-plugin-around%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