OS Property support center

SOLVED !!! Amenities Search

  • Kasey Moore
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 7 months ago - 10 years 6 months ago #57959 by Kasey Moore
SOLVED !!! Amenities Search was created by Kasey Moore
Hi there,

We have amenities down the left however they're not quite working right with logic.

When you have two tick boxes checked it will look for each results individually in an OR logic. We want AND logic.

For example if you tick disabled access it results 8 listings. If I also tick Toilets Nearby it then displays 35 results. But Beauchamp Arms does not have disabled access.

Do you have any idea how to switch the logic around on the search form?
Last edit: 10 years 6 months ago by Dang Thuc Dam.

Please Log in or Create an account to join the conversation.

  • Dang Thuc Dam
  • Away
  • Administrator
  • Administrator
More
10 years 7 months ago #58068 by Dang Thuc Dam
Replied by Dang Thuc Dam on topic Amenities Search
Hi Kasey,
To solve the problem, you can follow these steps
1. Open file: components > com_osproperty > classes > listing.php
2. find
$amenities_sql = " AND a.id in (SELECT pro_id FROM #__osrs_property_amenities WHERE amen_id in ($amenities_str))";
and replace by
$amenities_sql = " AND a.id in (SELECT pro_id FROM #__osrs_property_amenities WHERE amen_id in ($amenities_str) group by pro_id having count(pro_id) = ".count($amenities).")";
Good luck
Dam

Please Log in or Create an account to join the conversation.

  • Kasey Moore
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 6 months ago #58240 by Kasey Moore
Replied by Kasey Moore on topic Amenities Search
Great worked first time.

Can you do the same with checkbox on Extra Field?

Please Log in or Create an account to join the conversation.

  • Dang Thuc Dam
  • Away
  • Administrator
  • Administrator
More
10 years 6 months ago #58257 by Dang Thuc Dam
Replied by Dang Thuc Dam on topic Amenities Search
Hi Kasey,
Please open file:
administrator > components > com_osproperty > helpers > extrafields.php
find
if(count($value) > 0){
$extraArr = array();
for($i=0;$i<count($value);$i++){
$v = $value[$i];
$extraArr[] = " a.id in (Select pid from #__osrs_property_field_opt_value where fid = '$field->id' and `oid` = '$v') ";
}
$sql = " ( ". implode(" OR ",$extraArr) ." ) ";
}
and change to
if(count($value) > 0){
$extraArr = array();
for($i=0;$i<count($value);$i++){
$value[$i] = "'".$value[$i]."'";
}
$valueSql = implode(",",$value);
$sql = " a.id in (Select pid from #__osrs_property_field_opt_value where fid = '$field->id' and `oid` in ($valueSql)) group by pid having count (pid) = '".count($value)."'";
}

Thanks
Dam

Please Log in or Create an account to join the conversation.

  • Kasey Moore
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 6 months ago #58258 by Kasey Moore
Replied by Kasey Moore on topic Amenities Search
You're the man!

Thanks a lot!

Please Log in or Create an account to join the conversation.

Moderators: Dang Thuc DamNguyen Phu Quan