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 Vendor\Module\Plugin;

class Save
   public function aroundExecute(\Magento\Catalog\Controller\Adminhtml\Product\Save $subject, $result)
      if (some condition == true)
          then save product
            not save the product

How can I achieve this functionality?

1 Answer 1


That would be because the admin product form doesn't actually use ProductRepository, at least as of 2.2.2.



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. May 20, 2019 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.