In around plugin function, if we don't use proceed() then after plugin execution will be suppressed. Is there anyway by which we can suppress before plugin execution?
Around Plugins ( Interceptors) in magento can be used to suppress before and after plugin execution?
1 Answer
Why not wrap everything inside around
plugin for your case? So that:
public function aroundFunction(\My\Module\Model\MyUtility $subject, callable $proceed){
//If condition is true
if (true){
//BeforeFunction
//Do sonething
//ExecuteFunction
$proceed();
}
}
-
I agree with your solution to add condition to prevent after plugin. Is there anyway by which we can supress before part of around plugin. Commented Jul 8, 2019 at 7:39
-
No, this is the only way. Once you entered
Function
you cannot avoid "before".– PY YickCommented Jul 8, 2019 at 7:53