OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
865 stars 438 forks source link

Cannot search for Greek words in wysiwyg descriptions #1892

Open ioweb-gr opened 2 years ago

ioweb-gr commented 2 years ago

Preconditions (*)

  1. OpenMage LTS 19.4.15
  2. One product with a description / short description in Greek using the wysiwyg editor

Steps to reproduce (*)

  1. Create a simple product that's in stock, has quantity, is visible in catalog and search.

  2. Add to it a description like Φώτα θέσεως using the wysiwyg editor. The description is going to be saved encoded in html entities like this <p>&Phi;ώ&tau;&alpha; &theta;έ&sigma;&epsilon;&omega;&sigmaf;</p> image image

  3. Reindex and clear cache

  4. Go to the frontend and search for the word Φώτα

Expected result (*)

  1. The product is found

Actual result (*)

  1. The product is not found image

It seems that OpenMage is not building the search index correctly or during search it forgets to encode or decode the html entities.

ioweb-gr commented 2 years ago

Any ideas where I should start looking for it?

macoaure commented 2 years ago

making some tests i detect that magento will allways convert the simbols into unicode for searching, try making the same method, convert the symbols to the unicode and search for then:

// app/code/core/Mage/CatalogSearch/Helper/Data.php
<?php
// ...
    public function getQuery()
    {
        if (!$this->_query) {
            $this->_query = Mage::getModel('catalogsearch/query')
-                ->loadByQuery($this->getQueryText());
+                ->loadByQuery(htmlentities($this->getQueryText()));
            if (!$this->_query->getId()) {
-                ->loadByQuery($this->getQueryText());
+                ->loadByQuery(htmlentities($this->getQueryText()));
            }
        }
        return $this->_query;
    }

Remember to add the targets attributes on the search filter.

ioweb-gr commented 2 years ago

The problem is that if we don't use the wysiwyg editor, the characters are not encoded, and they work fine in search. Doing this, will make other attributes not work like the product name for examle :(

macoaure commented 2 years ago

u can do a special rule for this symbols like a str_replace([symbols], [encode], string_search);