I am trying to call helper
function on observer custom module in Magento2
but Unable to call helper in observer.
Please help me if anybody have this solution. I am waiting for all your positive response.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI am trying to call helper
function on observer custom module in Magento2
but Unable to call helper in observer.
Please help me if anybody have this solution. I am waiting for all your positive response.
Try something like below in your observer file.
<?php
namespace Custom\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
class SalableObserver implements ObserverInterface
{
...
protected $dataHelper;
...
public function __construct(
...
\Custom\Module\Helper\Data $dataHelper
...
) {
...
$this->dataHelper = $dataHelper;
...
}
public function ...(){
$helper = $this->dataHelper;
}
...
}
?>