7 replies [Last post]
futurist's picture
Offline
Joined: 08/08/2007
Juice: 114
Was this information Helpful?

I need a search form that searches only for products. Some people have tweaked Drupal's search.module (search for node type 'product') or suggest using trip_search.module. Is there a proper UC way to do this - an implementation of hook_search or something?

aswalla's picture
Offline
Getting busy with the Ubercode.Spreading the word - Ubercart for president.
Joined: 08/17/2007
Juice: 105
Re: Search for product

There should be a tab on your site's search page labeled "Products" ; it will point to http://www.yoursitename.com/search/uc_product
This page will just search within products. Are you looking for something more sophisticated?

There is also a uc_views module that seems to be floating around somewhere but unfortunately isn't posted to ubercart.org. I've created a similiar views module for myself (its quite a hack) since I couldn't find this original one anywhere. Combining this module with with the fastsearch module would also do the trick. I'm working on a similar page right now, but its now finished quite yet...

futurist's picture
Offline
Joined: 08/08/2007
Juice: 114
Re: Re: Search for product

Thanks for your hints. But I need the search block (in the header of a page, like here on ubercart.org) to search for products, not the full search page. I found this comment and put this in my template.php:

<?php
function mytheme_search_block_form($form) {
  return
'<div class="product-search">'. drupal_get_form('product_search_form') .'</div>';
}

function

product_search_form() {
 
$form = array();
 
$form['keys'] = array('#type' => 'textfield');
 
$form['submit'] = array('#type' => 'submit', '#value' => t('go'));
  return
$form;
}

function

product_search_form_submit($form_id, $form_values) {
  return
'search/node/' . trim($form_values['keys']) . ' type:product';
}
?>

It works, but I have a feeling that this is a complicated solution to a simple problem. And there are other drawbacks: The search form on the results page shows '[keys] type:product' in its textfield (should be empty) and it searches sitewide (should be just products). Any suggestions for improvement?

Concerning the uc_views module by BullCreek (hasn't signed up after the server crash): I do have a copy (alpha6c, as of July 10). I can upload it if anyone wishes.

aswalla's picture
Offline
Getting busy with the Ubercode.Spreading the word - Ubercart for president.
Joined: 08/17/2007
Juice: 105
Re: Re: Re: Search for product

If you could upload it or pm it to me, that would be great. I would like to work on it as a base if possible. Hopefully bullcreek will sign up again, but if it doesn't then a few of us should take off from where he has ended on the uc_views module.

As for search - I'm site isn't live yet - but the solution I am using is just to steal the code generated from my uc_views + fastsearch View. Then I've placed this code into my page.tpl.php file where I want the search box to show up. So my code ends up looking something like this:

    <form action="http://www.mysitename.com/views_search"  method="get" id="views-filters">
      I'm interested in magazines about
      <input name="filter0" id="edit-filter0" value="" maxlength="256" size="30" style="font-size: 12px;" type="text">
      <input type="hidden" name="op1" id="edit-op1" value="AND" />
      <input type="hidden" name="filter1[]" id="edit-filter1" value="**ALL**" />
      &nbsp;
      in
<!--  <select name="filter1[]" id="edit-filter1"  size="8"> -->
      <select name="filter1[]" id="edit-category" style="font-size: 12px;">
        <option value="**ALL**" selected="selected">All Categories</option>
        <option value="1">Automobiles</option>
        <option value="2">Business</option>
        <option value="3">Children</option>
        <option value="4">Computing</option>
      </select>
      <input id="edit-submit" value="Find it!" class="form-submit" type="submit">
    </form>

So in the View I have created, I have told it to just filter within the Products nodes. Appears to work fine and not search non-product nodes. I also like this method because I can then finetune how the search output appears - I have an image that shows as well as a short description and the of course the product name.

I give the customer the ability to do a keyword search across the entire site or within just a single shopping category.

-Aaron

futurist's picture
Offline
Joined: 08/08/2007
Juice: 114
Re: Re: Re: Re: Search for product

Thanks, Aaron, seems to work. However, I'm still wondering if there is a way to do this using Drupal's Form API/search system (instead of "stealing" rendered HTML): A simple search block that only searches for UC products, and a result page with a form that does the same...

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Search for product

I bet I can do this using the search routine from the order edit form. You can choose to not use the uBrowser to add products to an order, and it pops up a custom product search form. I'll file this away and get to it eventually if no one else gets to it first. Eye-wink

StephenGWills's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/07/2007
Juice: 414
Re: Re: Re: Re: Re: Re: Search for product

This is a bump on the product search issue. My marketing department just asked me to implement:

product search within catagory branch,
the cheesy old A-Z text links that yield all products beginning with [Letter] within catagory
products with specific suggested keyword (a drop down of a CCK field)

my solution? A howitzer aimed at the Marketing department. Anyway....

Has anyone made more progress on sub-catagory search?

zareen's picture
Offline
Joined: 01/20/2008
Juice: 81
not showing product tab

My sites search page doesn't show the product tab. And it does show a users tab, which I don't want. How do I manage those tabs?

Thanks in advance
Connie