Advertisement:

Author Topic: Real Estate Theme Search Not Working- Solved  (Read 4955 times)

Helpto

  • Newbie
  • *
  • Posts: 45
Real Estate Theme Search Not Working- Solved
« on: October 09, 2013, 10:58:40 am »
Hello,

I'm new to Osclass and using Realestate theme in my new classified Ad website. Everything was working fine except the Search.

Last 2 days I've been searching for a solution in Real estate theme search problem. But I could not find a solution in the osclass forums.

Finally I could figure out the issue and find a solution which is working fine in my case. I don't know whether it is a perfect solution.

I'm using Osclass latest version 3.2.1. In my case when searching from Home page, even though the Keywords exists in the fields s_title,s_description in the t_item_description table, it was showing no results.

The real problem is in the query used for doSearch(); It returns results only if the location  is selected. But in the Real estate theme home page there is no option to select the location. I've changed the code in search.php and now it is working fine.

Find the below code in  oc-includes / osclass / model / Search.php (https://github.com/osclass/Osclass/blob/master/oc-includes/osclass/model/Search.php) - Line No : 912 to 924

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code: [Select]
if ($this->withPattern ) {
                    $this->dao->join(DB_TABLE_PREFIX.'t_item_description as d','d.fk_i_item_id = '.DB_TABLE_PREFIX.'t_item.pk_i_id','LEFT');
                    $this->dao->where(sprintf("MATCH(d.s_title, d.s_description) AGAINST('%s' IN BOOLEAN MODE)", $this->sPattern) );
                    if(empty($this->locale_code)) {
                        if(OC_ADMIN) {
                            $this->locale_code[osc_current_admin_locale()] = osc_current_admin_locale();
                        } else {
                            $this->locale_code[osc_current_user_locale()] = osc_current_user_locale();
                        }
                    }
                    $this->dao->where(sprintf("( d.fk_c_locale_code LIKE '%s' )", implode("' d.fk_c_locale_code LIKE '", $this->locale_code)));
                }

-------------------------------------------------------------------------------------------------------------------------------------------------------------------

And replace it with the below code.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code: [Select]
if ($this->withPattern ) {
                    $this->dao->join(DB_TABLE_PREFIX.'t_item_description as d','d.fk_i_item_id = '.DB_TABLE_PREFIX.'t_item.pk_i_id','LEFT');
                    $this->dao->where(sprintf("MATCH(d.s_title, d.s_description) AGAINST('%s' IN BOOLEAN MODE)", $this->sPattern) );
                    if(!empty($this->locale_code)) {
                       $this->dao->where(sprintf("( d.fk_c_locale_code LIKE '%s' )", implode("' d.fk_c_locale_code LIKE '", $this->locale_code)));
                    }
                }

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

Now it will work if the location parameter is not passed.

See the search result in my website : http://helptobuynsell.in/

Use the Keywords : Apple iPhone or Blackberry etc

In the actual code, If the location parameter is not passed, then the query will find the current user location( osc_current_user_locale() ).

I think there is something wrong with this function at least in the Real estate theme.  But I could not figure out the issue. If Admin or someone else could tell how it works ( osc_current_user_locale() ), then we can find a permanent solution for real estate theme search problem.

I've not checked it with other themes.

See the attached image to find the active Plugins in my theme. ie; No issues with these Plugins.

Let me know if it is working in your case :).

Thanks
Helpto
« Last Edit: October 09, 2013, 12:11:38 pm by Helpto »

Neo

  • Newbie
  • *
  • Posts: 3
Re: Real Estate Theme Search Not Working- Solved
« Reply #1 on: November 20, 2016, 04:32:02 pm »
Hi,

i tried doing what you said by adding those codes but it's not working. Can you please  help me out.