3

When applying laygered navigation filter in my Magento 2, In Developer Mode I got this error,

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): sorry, something went wrong. You can find out more in the error log

But the problem is that nothing is tracked in whether the Apache error log or the Magento log. So I don't know how to diagnose the issue.

Any ideas on how to debug when seeing errors like this?


Update,

If I turn Production Mode on, the Exception #0 (Magento\Framework\Exception\LocalizedException): error mesesage is gone, and it displays an empty page, but I in developer tools in my browser it says "JavaScript seems to be disabled in your browser".

enter image description here

But I'm sure it's nothing to do with Javascript on my browser. I've tried with different browsers on different computers, I got the same error.

2 Answers 2

1

You can get this error on two times.

  • When Product collection is called.
  • When Advance Search Collection is called.

On classes

  • Magento\CatalogSearch\Model\ResourceModel\Advanced\Collection.
  • Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection.

I guess that you have issue on collection call.

I guess that you need to do an indexing.

7
  • I just did reindexing. I didn't help. Is there a way that I can see the error in log? I wonder why apache error log didn't track anything. I got the error when applying layered navigation in magento. but not all options i selected in the filter give me the error. for example if i use only price in the layered navigation then it's working fine. it's sizes, and some other option that gives errors. Mar 29, 2018 at 3:52
  • I have look further on this issue, and you are right, it is the fulltext search gave the error. it's my 3rd part module that conflicted with Magento's Layered navigation. Apr 4, 2018 at 13:10
  • which extension?
    – Amit Bera
    Apr 4, 2018 at 13:33
  • It's EaDesign's warehouse inventory module. github.com/EaDesgin/magento2-warehouses/issues/13 I have disabled the fulltext search from this module, then Layered Navigation is working again. Apr 4, 2018 at 13:42
  • @AmitBera i did indexing but still getting this error,i am using that mageplaza layered navigation Feb 6, 2020 at 12:09
1

✅How to fix it

Modify the Mageplaza_LayeredNavigation module's existing code to use the logger as follows:

app/code/Mageplaza/LayeredNavigation/Model/ResourceModel/Fulltext/Collection.php::497-501
function _renderFiltersBefore(){
    ...
    try {
        $this->searchResult = $this->getSearch()->search($searchCriteria);
    } catch (Exception $e) {
        $this->_logger->error( $e->getMessage() );  //  👈 Add this line
        throw new LocalizedException(__('Sorry, something went wrong. You can find out more in the error log.'));
    }
    ...
}

🏅Result

Now useful information will be populated in Magento's var/system.log:

[2021-02-19 18:30:46] report.ERROR: Notice: Undefined index: match in app/code/Mything/Elasticsearch/Plugin/SearchAdapter/Query/Builder/Match.php on line 50 [] []
[2021-02-19 18:30:46] report.ERROR: Sorry, something went wrong. You can find out more in the error log. [] []

📚Academic Reading

This error is specific to Magento sites using the Mageplaza_LayeredNavigation module.

I understand that for frontend users we would want a static & locally translated message. However it seems very silly to catch an Exception but not log or render any information about the actual Exception. To make things debuggable, this implementation needed to be changed.

What caused it (for me); your's will be different:

I encountered Mageplaza's LocalizedException when creating a plugin on afterBuild() for this class:

Magento\Elasticsearch\SearchAdapter\Query\Builder\Match

The issue was caused by a very simple error in my own plugin's afterBuild() method (for me, it was simply a Notice about a missing array key). However due to Mageplaza's try{}catch(){} block throwing a static message in a LocalizedException, I did not have the information necessary to debug the underlying issue.

Personal experience with this brand of modules

I've been involved with sites using Mageplaza modules from 2014 to 2021. Although some of their development staff is extremely talented (Uri is great), these types of best-practice missteps seem to arise semi-frequently regarding Mageplaza modules. Some of their implementations seem less-than-professional or not thoroughly finished for minor things like this and it commonly costs me hours of extra time. Some areas of their codebase remind me of when I leave a //TO-DO: comment marker in my own code to flag a better way to implement something later because I don't have time at the moment to do it right.

1
  • Your answer helped me to debug the errors at system.log
    – Felix Htoo
    Oct 4, 2021 at 12:27

Your Answer

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

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