Datafeedr Support Forums

Datafeedr Support Forums (/index.php)
-   Questions (/forumdisplay.php?f=67)
-   -   Search Code not working (/showthread.php?t=10892)

alankarsale August 18th, 2014 10:24 AM

Search Code not working
 
Hello,

My search form is not working properly. It will do products but my merchants are coming up with any products. Can you help?

Code:

<?php
function dfr_get_merchants() {
    global $wpdb;
    $merchants = $wpdb->get_results("SELECT merchant, merchant_id FROM ".$wpdb->prefix."dfr_shop_products GROUP BY merchant");
    $html = '<option value="">Select all Merchants</option>';
    foreach ($merchants as $k => $v) {
        if (trim($v->merchant) != "") {
            $selected = (strip_tags($_GET['merchant_id'])==$v->merchant_id) ? ' selected="selected"' : '';
            $html .= '<option value="'.$v->merchant_id.'"'.$selected.'>'.$v->merchant.'</option>';
        }
    }
    return $html;
}
?>

[search.form]
<div class="store_search_form">
  <p class="keyword">
    <label for="word">Keyword</label> [search.word]
  </p>
  <p class="merchant">
    <label for="word">Merchant</label>
    <select name="merchant_id">
      <?php echo dfr_get_merchants(); ?>
    </select>
  </p>
  <p class="category">
    <label for="category">Category</label>
    <select name="c">
      <option value=""> Select all categories </option>
      [category.list before='' after='']
        <option value="[category.id]"><?php echo str_repeat ('-', (($depth-1)*2) ); ?> &nbsp; [category.name]</option>
        [category.repeat]
      [/category.list]
    </select>
  </p>
  <p class="price">
  <label for="price">Price</label> [search.selectprice options='any, Below $10(-5), $10 - $20, $20 - $30, $30 - $40, more than 40 (40+)']
  </p>
  <p class="button">[search.submit title='Find it!']</p>
</div>
[/search.form]


Eric August 18th, 2014 10:34 AM

Hi,

You can't pass an empty "c" parameter to the URL. If the "c" parameter exists, it must be filled with a valid category ID.

Eric

alankarsale August 18th, 2014 10:50 AM

Can I just erase that line to fix it?

alankarsale August 18th, 2014 10:55 AM

I replaced the "c" with "category.id" it seemed to fix it. Is that correct?

alankarsale August 18th, 2014 11:13 AM

Now, it gives me the merchant items, but the category search is not working. It just gives me all the merchant items and it will not filter category or price

Eric August 18th, 2014 11:19 AM

Hi,

"category.id" will not work. It's not a valid parameter. Only "c" works and if it's set as a parameter, it requires a value.

Eric

Eric August 18th, 2014 11:20 AM

Hi,

Also, categories are not meant to be used as filters. They are their own product organization system. Why not just expose filters on a per-category basis? That's what I would do.

Eric

alankarsale August 18th, 2014 11:23 AM

Can you send me a link on how to do this?

Eric August 18th, 2014 11:33 AM

Hi,

Sorry, that wasn't clear. I meant remove the category drop down from the Advanced Search form and just have the Category widget listed above (or below) your Advanced Search form.

Eric


All times are GMT -5. The time now is 01:08 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.