By gravit on
Hello -
I need to make it so the SKU for a product gets added into the drupal search index, so that a user can search by Item Number (SKU) in the search box. I believe that just the correct hooks need to go into the product module to accomplish this, but I'm not sure.
I am looking for bids on time and cost for this small task.
contact me throught my form.
Thanks!
Comments
are you sure?
If you have the Search option configured (using cron or poormanscron) right then I would have thought that the indexer would pick it up on each run. In which case all you need is the internationalisation stuff to allow you to define your own text for mods and you can change Search to "Search - text or SKU" to help users.
If I'm right and you want to reward me, drop me a line :-)
Ian Dickson - community specialist.
www.emint.org - Association of Online Community Professionals
www.iandickson.com/taxonomy/drupal/ - Taxonomy Server Project - generic, organic, standards compliant, directed graph based, ass kicking taxonomy
doesn't work
just tried it,inc min word count of 1.
Thanks for your feedback
Hi ian - Thanks for the feedback - Unfortunately it doesnt seem ecommerce does this out of the box. Looking into the search_index hooks in the API is a little beyond me so I was hoping someone might have a simpler solution.
The simplest idea I found
The simplest idea I found was to just make a SKU item in the CCK. It is duplicating work, but a simple copy/paste from one text field only takes about 5 seconds more to do. It'd be good to get a solution to fix this, however, its probably quicker to make a text field. You could even implement a cron script to copy the sku into the text field box.
lol
Thanks Jakob -
but unfortunately, as you already know... I am not using CCK for my products, just the default product node. :-)
Good to find you on the forums.
Module for Late Adopters
Apparently this functionality is standard as of Ecomm 4+, but I thought it would be worth noting our workaround for people who, like ourselves, are fearful of change and progression.
Create an ec_searchsku folder in your modules directory (usually sites/all/modules).
Within this folder create two files:
ec_searchsku.info
and
ec_searchsku.module
Then to actually trigger the index update, you'll have to go to admin/settings/search and hit the 're-index content' button - then wait until Cron has fired enough times to index the site (or visit admin/logs/status and Run Cron Manually until the search page displays 100%.
It really is that simple :)
(Unless somebody says otherwise...)
--Andy
++Andy
Andy, thanks for this
Andy, thanks for this workaround. It's a simple and great solution till we are ready to upgrade.
ubercart sku search
will this search function (similar) work for ubercart?
simplest solution that I
simplest solution that I found was to add the sku to the product name and use the search feature in views bulk operations to find the product where the name includes the sku number
for instance: Tire size 12, with sku 123 becomes 112 - Tire size 12
this works well just as long as the person doing the searching is not a customer or if as admin you dont activate a bulk operation
Only in the sense of "yes"
Honestly I would have expected Ubercart to incorporate SKU indexing into their code, they're usually quite thorough. Oh well.
The code should technically work - BUT - be aware that Ubercart stores its SKU on a 'model' property instead of 'sku'. So that part of the code will have to change, at least. Also note that it's a Drupal 5.x module, there are a few changes that will need to be made if you want it to work with Drupal 6.x or higher (at the very least the .info file will need a 'core = 6.x' declaration).
I'm about to try to implement a variant of this, so will try and let you know how it comes out.
EDIT: Yes, switching '$node->sku' to '$node->model' (and 'store' to 'uc_store' in the .info file) worked fine. I also added a .install file with a hook_install that calls search_wipe(), but that's because I'm a perfectionist...
++Andy
Here is a version of the above function that works with Ubercart
Create an uc_search_model folder in your modules directory (usually sites/all/modules).
Within this folder create two files:
uc_search_model.info
and
uc_search_model.module
After creating the above files, go to "admin/build/modules" and enable your new module. The name of your new module is "Ubercart Search Model Number".
Now, the next time that cron runs on your server, your product nodes are going to be re-indexed with their respective SKU (Model) numbers.