RSS

Category Archives: Mysql

How to search for all words in magento?

If u want to make an AND search instead of OR, you will need to rewrite the class

Mage_CatalogSearch_Model_Resource_Fulltext

at this location in magento v1.7.0.2.

app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

Now Go to the following function in this file

public function prepareResult($object, $queryText, $query)

You have to change the following line

$likeCond = '(' . join(' OR ', $like) . ')';

To

$likeCond = '(' . join(' AND ', $like) . ')';

Now change the Search Type to “LIKE” from catalog search section in admin.

Now reindex the search index afterwards to have an effect..

Advertisements
 
1 Comment

Posted by on Sep 26, 2013 in Magento, Mysql, PHP

 

Tags: , , , , , , , , , , ,

How to store UTF8 (indian language) data in mysql?

We assume we have a DataBase with table news, and a column named posts, which will save the news written in your website.We know that all major DataBase’s support UTF8. And we shall explore that feature.
Now we write a article in hindi, हेल्लो वर्ल्ड
If the UTF8 is not specified, you should see something like ?????? in ur DataBase otherwise you should see the hindi data. Clear? Now lets see the code given below:

First check for UTF8 compatibility with this query. If it supports you should see the output as “Character_set_system”| “UTF8″
SHOW VARIABLES LIKE ‘character_set_system’;
this will show the below result if support:

Full Texts
Variable_name    Value
character_set_system    utf8

Now that being checked, alter the table and just modify the column, which is ‘text’ in our above example and specify it as UTF8
ALTER TABLE news MODIFY text VARCHAR(200) CHARACTER SET UTF8;

Then execute following query before inserting into the table:

mysql_query(‘SET character_set_results=utf8’);
mysql_query(‘SET names=utf8’);
mysql_query(‘SET character_set_client=utf8’);
mysql_query(‘SET character_set_connection=utf8’);
mysql_query(‘SET collation_connection=utf8_general_ci’);

 
Now, try to insert the hindi value and save it. Query it and u should see the hindi text :)

 
2 Comments

Posted by on Sep 14, 2011 in Mysql, PHP

 

Tags: , , ,

 
%d bloggers like this: