Advertisement:

Author Topic: [RESOLVED] Exclude category from results search ajax autocomplete  (Read 700 times)

WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Exclude category from results search ajax autocomplete
« Reply #15 on: July 06, 2019, 06:56:30 pm »

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #16 on: July 07, 2019, 12:36:34 am »
Yes ! But don't work ?


leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #17 on: July 07, 2019, 12:37:40 am »
You can try in my website : www.natava.ch !

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #18 on: July 07, 2019, 12:42:26 am »
You have check this error in your website test ?



leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #19 on: July 07, 2019, 12:43:51 am »

WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Exclude category from results search ajax autocomplete
« Reply #20 on: July 08, 2019, 01:32:46 pm »
Let me try on another site.

Regards.

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #21 on: July 12, 2019, 02:00:55 pm »
Any news ?

WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Exclude category from results search ajax autocomplete
« Reply #22 on: July 12, 2019, 03:51:22 pm »
Now try this. Apparently, the AJAX code is now in the contact.php file, while it was in the ajax.php file previously. Whole Veronika AJAX system is weird and it's not using Osclass AJAX calls...

Open oc-content/themes/veronika/contact.php.

Go to line 54.
Make it look like this SELECT i.pk_i_id, i.fk_i_category_id, d.s_title, i.i_price, i.fk_c_currency_code, CONCAT(r.s_path, r.pk_i_id,'_thumbnail.',r.s_extension) as image_url.

Go to line 67.
Add this to the end of it AND i.fk_i_category_id NOT IN (1,2,3,4).
Replace 1,2,3,4 with your category ID's.

Regards.

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #23 on: July 12, 2019, 11:34:55 pm »
Now, i have 0 result when i make a search.

Code: [Select]
    $sql = "
        SELECT i.pk_i_id, d.s_title, i.i_price, i.fk_c_currency_code, CONCAT(r.s_path, r.pk_i_id,'_thumbnail.',r.s_extension) as image_url
        FROM {$db_prefix}t_item i
        INNER JOIN {$db_prefix}t_item_description d
        ON d.fk_i_item_id = i.pk_i_id
        LEFT OUTER JOIN {$db_prefix}t_item_resource r
        ON r.fk_i_item_id = i.pk_i_id AND r.pk_i_id = (
          SELECT rs.pk_i_id
          FROM {$db_prefix}t_item_resource rs
          WHERE i.pk_i_id = rs.fk_i_item_id
          LIMIT 1
        )

        WHERE d.fk_c_locale_code = '" . osc_current_user_locale() . "' AND (s_title LIKE '%" . $pattern . "%' OR s_description LIKE '%" . $pattern . "%') AND b_active = 1 AND b_enabled = 1 AND b_spam = 0
        ORDER BY dt_pub_date DESC
        AND i.fk_i_category_id NOT IN (327, 326, 325, 324, 323, 322, 321, 320, 1335, 1334, 1333, 1332, 1331, 1330, 1329, 1328, 1327, 319, 318, 317, 316, 1326, 1325, 315, 314, 1324, 1323, 313, 312, 311, 1322, 1321, 1320, 1319, 310, 209, 308, 1318, 1317, 307, 107)
       
        LIMIT " . $max . ";
       
       
      ";

WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Exclude category from results search ajax autocomplete
« Reply #24 on: July 13, 2019, 12:35:29 am »
Wrong line I guess.

Code: [Select]
    $sql = "
        SELECT i.pk_i_id, i.fk_i_category_id, d.s_title, i.i_price, i.fk_c_currency_code, CONCAT(r.s_path, r.pk_i_id,'_thumbnail.',r.s_extension) as image_url
        FROM {$db_prefix}t_item i
        INNER JOIN {$db_prefix}t_item_description d
        ON d.fk_i_item_id = i.pk_i_id
        LEFT OUTER JOIN {$db_prefix}t_item_resource r
        ON r.fk_i_item_id = i.pk_i_id AND r.pk_i_id = (
          SELECT rs.pk_i_id
          FROM {$db_prefix}t_item_resource rs
          WHERE i.pk_i_id = rs.fk_i_item_id
          LIMIT 1
        )

        WHERE d.fk_c_locale_code = '" . osc_current_user_locale() . "' AND (s_title LIKE '%" . $pattern . "%' OR s_description LIKE '%" . $pattern . "%') AND b_active = 1 AND b_enabled = 1 AND b_spam = 0 AND i.fk_i_category_id NOT IN (327, 326, 325, 324, 323, 322, 321, 320, 1335, 1334, 1333, 1332, 1331, 1330, 1329, 1328, 1327, 319, 318, 317, 316, 1326, 1325, 315, 314, 1324, 1323, 313, 312, 311, 1322, 1321, 1320, 1319, 310, 209, 308, 1318, 1317, 307, 107)
        ORDER BY dt_pub_date DESC       
        LIMIT " . $max . ";
       
       
      ";

Regards.

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #25 on: July 13, 2019, 12:45:30 am »
YESSS ! Thank you ! It's OK when the user is not in the adult categories.

You think it's hard to enable the search in this category when the user is in category adult because now when the user is in the category adult and make a search, he does'nt have results for this category.


WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Exclude category from results search ajax autocomplete
« Reply #26 on: July 13, 2019, 01:26:25 am »
We finally got it working! ;)

Try this:

Code: [Select]
$removed_categories = array(327, 326, 325, 324, 323, 322, 321, 320, 1335, 1334, 1333, 1332, 1331, 1330, 1329, 1328, 1327, 319, 318, 317, 316, 1326, 1325, 315, 314, 1324, 1323, 313, 312, 311, 1322, 1321, 1320, 1319, 310, 209, 308, 1318, 1317, 307, 107);
if(in_array(@osc_search_category_id()[0], $removed_categories)) { // If current search category is on the list of removed ones, show all categories.
    $sql = "
        SELECT i.pk_i_id, d.s_title, i.i_price, i.fk_c_currency_code, CONCAT(r.s_path, r.pk_i_id,'_thumbnail.',r.s_extension) as image_url
        FROM {$db_prefix}t_item i
        INNER JOIN {$db_prefix}t_item_description d
        ON d.fk_i_item_id = i.pk_i_id
        LEFT OUTER JOIN {$db_prefix}t_item_resource r
        ON r.fk_i_item_id = i.pk_i_id AND r.pk_i_id = (
          SELECT rs.pk_i_id
          FROM {$db_prefix}t_item_resource rs
          WHERE i.pk_i_id = rs.fk_i_item_id
          LIMIT 1
        )

        WHERE d.fk_c_locale_code = '" . osc_current_user_locale() . "' AND (s_title LIKE '%" . $pattern . "%' OR s_description LIKE '%" . $pattern . "%') AND b_active = 1 AND b_enabled = 1 AND b_spam = 0
        ORDER BY dt_pub_date DESC       
        LIMIT " . $max . ";
      ";
} else { // Otherwise remove categories on the list.
    $sql = "
        SELECT i.pk_i_id, i.fk_i_category_id, d.s_title, i.i_price, i.fk_c_currency_code, CONCAT(r.s_path, r.pk_i_id,'_thumbnail.',r.s_extension) as image_url
        FROM {$db_prefix}t_item i
        INNER JOIN {$db_prefix}t_item_description d
        ON d.fk_i_item_id = i.pk_i_id
        LEFT OUTER JOIN {$db_prefix}t_item_resource r
        ON r.fk_i_item_id = i.pk_i_id AND r.pk_i_id = (
          SELECT rs.pk_i_id
          FROM {$db_prefix}t_item_resource rs
          WHERE i.pk_i_id = rs.fk_i_item_id
          LIMIT 1
        )

        WHERE d.fk_c_locale_code = '" . osc_current_user_locale() . "' AND (s_title LIKE '%" . $pattern . "%' OR s_description LIKE '%" . $pattern . "%') AND b_active = 1 AND b_enabled = 1 AND b_spam = 0 AND i.fk_i_category_id NOT IN (327, 326, 325, 324, 323, 322, 321, 320, 1335, 1334, 1333, 1332, 1331, 1330, 1329, 1328, 1327, 319, 318, 317, 316, 1326, 1325, 315, 314, 1324, 1323, 313, 312, 311, 1322, 1321, 1320, 1319, 310, 209, 308, 1318, 1317, 307, 107)
        ORDER BY dt_pub_date DESC       
        LIMIT " . $max . ";
      ";
}

Regards.

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #27 on: July 13, 2019, 01:33:08 am »
It's OK for the search in all categories but in adult "no results" ! You can see here :

https://www.natava.ch/erotique

WEBmods

  • Hero Member
  • *****
  • Posts: 936
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Exclude category from results search ajax autocomplete
« Reply #28 on: July 13, 2019, 07:25:33 pm »
Probably an issue with 'osc_search_category_id()[0]'. Let me test something.

Regards.

leuname07

  • Newbie
  • *
  • Posts: 39
Re: Exclude category from results search ajax autocomplete
« Reply #29 on: July 14, 2019, 11:20:10 pm »
Ok, thank you for your help !