magento2-faqs-extensions icon indicating copy to clipboard operation
magento2-faqs-extensions copied to clipboard

Search crashes: Invalid method PHPCuong\Faq\Block\Search\Search::filterProvider

Open dazz397 opened this issue 6 years ago • 4 comments

If you search for something that matches a value the search will crash /faq/search/?s=feet

If you search for something with no matches it returns fine /faq/search/?s=xxxxx

I was able to replicate this on 2.1.7 and 2.1.7.1

dazz397 avatar Dec 15 '17 07:12 dazz397

I have created a pull request to fix this issue. Check #23

SherifElfadaly avatar Dec 19 '17 15:12 SherifElfadaly

@SherifElfadaly great patch! I can confirm the patch is working and to me it should be merged to master as soon as possibile since at the current state the search functionality is broken.

ghost avatar Jan 04 '18 14:01 ghost

@SherifElfadaly fixed a part of the search results. I searched with more than 3 words which were copied from one of the answers. But results listed all questions in my English Store (some times it also included all questions from my other Chinese Store)

lamaithanh avatar Mar 07 '18 06:03 lamaithanh

@lamaithanh I know this is years later but the query is not built correctly when there are multiple keywords. You can correct this by adding parenthesis to the query at line 175 like this:

    for ($i=0; $i<count($explode); $i++) {
        if ($i == 0) {
            $select->where('(faq.title LIKE ?', "%{$explode[$i]}%");
        } else {
            $select->orWhere('faq.title LIKE ?', "%{$explode[$i]}%");
        }
        if ($i == count($explode)-1) {
            $select->orWhere('faq.content LIKE ?)', "%{$explode[$i]}%");
        } else {
            $select->orWhere('faq.content LIKE ?', "%{$explode[$i]}%");
        }
    }

dazz397 avatar Aug 30 '22 20:08 dazz397