3

In Magento 2, it shows an error which is really annoying for customers. How can we hide or remove showing those errors in the page?

Currently, the application is in the production mode. But still, the following error is shown.

enter image description here enter image description here

  • you can try this reference to remove that message : interactiv4.com/blog-es-en/… – mrfizh Sep 8 '18 at 7:24
  • These are error message coming from your tracking module. Please check the controller of your module and remove the error messages from there. – Sukumar Gorai Sep 8 '18 at 7:32
  • @SukumarGorai, this is basic magento tracking selected and can you please tell where I can get the controller for magento tracking? – Jithin U. Ahmed Sep 8 '18 at 7:39
  • Do you want to remove all error messages in magento for every pages? Or for these 2 pages? – Sukumar Gorai Sep 8 '18 at 7:45
  • You must find the controll who add this messages error and remove it – Mohamed El Mrabet Sep 8 '18 at 8:06
0

Go to : app/code/{Vendor}/{Yourmodulename}/Controller/.../... .php Then you w'ill fine addError in some lines like this :

$this->messageManager->addError(__('An error occurred while....'));

Replace them with :

$this->logger->info('An error occurred while....');

Important: If you haven't yet this piece of code $this->logger or sometimes like this : $this->_logger please inject it in the contructor like this:

protected $logger;
public function __construct(\Psr\Log\LoggerInterface $logger)
{
    ...
    $this->logger = $logger;
}

Now the errors will be displayed in var/log instead in frontend

  • How can I find the Yourmodulename in Magento 2 for making this change? – Jithin U. Ahmed Sep 11 '18 at 10:40
  • Your tracking module – PЯINCƏ Sep 11 '18 at 10:42
  • I have fixed this for the tracking module. But how to find thr controller for the second image? Its actually the search result page. – Jithin U. Ahmed Sep 11 '18 at 10:47
  • 1
    module-catalog-search module but you should rewrite it (don't update it directly) from vendor/magento/Module-catalog-search – PЯINCƏ Sep 11 '18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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