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
else
not save the product
}
}
How can I achieve this functionality?