Power Search
Copyright © 2000, William Weiland
Overview
The purpose of powrsrch.mv is to allow a customer to search one or more fields which are allowed by the store owner. The store owner can choose any fields within the products.dbf structure to be available.
Initial Setup
Use the Merchant admin upload feature to upload the powrsrch.mv(c) module. Once uploaded, click the Add button to add it to the mall/domain.

In admin, under your store, click on the link for Utilities Configuration Screen. Assign the module and Update it to install it in your store.

Click the link for Power Search to enter the configuration settings.


Configuration Settings
For each field that you want to be selectable by the customer, enter a tag line (description) for that field, eg. NAME could read Product Name for its display tag. Blank tag line fields will not be listed as selectable search options.

If you change the structure of your products database, you will need to uninstall Power Search from the store, then re-install it. That will create a new field list for you to enter tag lines.

Each time you run the report under the admin:store:utilities you have the option of deleting the flat file log. This is advisable as the log will get too large to view. Since it is mainly to monitor trends, you need not even view the whole log. Entering to view the first 100 searches should give you an idea what people look for. Checking the box to delete will delete all existing searches from the log. If for some reason you want to keep all of the search log for later analysis, you should download the flat file log to your PC for import into a spreadsheet or database manager. Then delete the flat file.


Editing Requirements (skip if using the OpenUI)
If you are using the Miva Merchant User Interface (mmui) you will need to make some very simple edits to the core files. Be sure to do that with a text editor (NO WYSIWYG editors) such as Programmer's File Editor (PFE) so as not to damage the mv files. ALWAYS BACKUP your unmodified mv files in case you make a mistake.

1) In the mmui.mv file you insert the following non-asterisk lines in the MMUI_Search function about 50 lines from the beginning of that function. You will see </TABLE> and </FORM> tags followed by the line
<MvIF EXPR = "{ len( g.Search ) }">. Example below with * at the beginning.

* </TABLE>
* </FORM>
<HR>
<MvDO FILE = "{g.Module_Root$'modules/util/powrsrch.mv'}" NAME = "l.powersearchprompt" VALUE = "{Power_Search_Prompt()}">
* <MvIF EXPR = "{ len( g.Search ) }">

2) Several lines below this location you will see the line:
<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.nextoffset" VALUE = "{ Customer_Product_FindOffset_Words( BasketList.d.cust_id, g.Offset, g.Search ) }">
Replace that line with the following five lines.
<MvIF EXPR = "{g.dopowersearch}">
<MvDO FILE = "{g.Module_Root$'modules/util/powrsrch.mv'}" NAME = "l.nextoffset" VALUE = "{ PowerSearch_Customer_Product_FindOffset_Words( BasketList.d.cust_id, g.Offset, g.Search ) }">
<MvELSE>
<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.nextoffset" VALUE = "{ Customer_Product_FindOffset_Words( BasketList.d.cust_id, g.Offset, g.Search ) }">
</MvIF>

3) Several lines further down in the MMUI_Search locate the lines matching the lines marked with asterisks:
* <MvWHILE EXPR = "{ ( ( MMUI_Store.d.srch_len EQ 0 ) OR ( l.count LE MMUI_Store.d.srch_len ) ) AND l.nextoffset }">
<MvIF EXPR = "{g.filter_cat}">
<MvDO FILE = "{g.Module_Root$'modules/util/powrsrch.mv'}" NAME = "l.code_found" VALUE = "{Apply_Category_Filter(Products.d.id)}">
</MvIF>
<MvIF EXPR = "{ (NOT g.filter_cat) OR (l.code_found) }">
* <MvIF EXPR = "{ l.colorswitch EQ 1 }">
* <MvASSIGN NAME = "l.bgcolor" VALUE = "">
* <MvASSIGN NAME = "l.colorswitch" VALUE = 0>
* <MvELSE>
* <MvASSIGN NAME = "l.bgcolor" VALUE = "{ MMUI_Store.d.list_alt }">
* <MvASSIGN NAME = "l.colorswitch" VALUE = 1>
* </MvIF>
* </MvIF>
Insert the 4 lines not marked with an asterisk.

4) Several lines further down in the MMUI_Search locate the lines which end the table row followed by the </MvWHILE> tag.
I have placed an asterisk (*) in the lines below to demonstrate which ones you are looking for. Between those two lines, you will insert the 4 lines which are not preceeded with an asterisk.
* </TR>
<MvELSE>
<MvASSIGN NAME = "l.lastoffset" VALUE = "{ l.nextoffset }">
<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.nextoffset" VALUE = "{ Customer_Product_FindNext( BasketList.d.cust_id, l.nextoffset ) }">
</MvIF>
* </MvWHILE>

5) A few lines further down in the MMUI_Search, locate the following lines I've denoted with asterisks here and insert the lines not asterisked:
* <MvIF EXPR = "{ MMUI_ProductLayout.d.format EQ 'X' }">
* <TABLE BORDER = 0 CELLPADDING = 2 CELLSPACING = 0>
* <MvWHILE EXPR = "{ ( ( MMUI_Store.d.srch_len EQ 0 ) OR ( l.count LE MMUI_Store.d.srch_len ) ) AND l.nextoffset }">
<MvIF EXPR = "{g.filter_cat}">
<MvDO FILE = "{g.Module_Root$'modules/util/powrsrch.mv'}" NAME = "l.code_found" VALUE = "{Apply_Category_Filter(Products.d.id)}">
</MvIF>
<MvIF EXPR = "{ (NOT g.filter_cat) OR (l.code_found) }">
* <MvEVAL EXPR = "{ Display_Product_ScreenExpand() }">

6) Several lines further down you will see the end of the </MvWHILE> loop along with a count increment (lines marked with asterisk). Place a </MvIF> just after the counter:
* <MvASSIGN NAME = "l.count" VALUE = "{ l.count + 1 }">
</MvIF>
* <MvASSIGN NAME = "l.lastoffset" VALUE = "{ l.nextoffset }">
* <MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.nextoffset" VALUE = "{ Customer_Product_FindNext( BasketList.d.cust_id, l.nextoffset ) }">
* </MvWHILE>

7) In the same function, MMUI_Search, near the end of the function you will see the forms for the Previous and Next buttons. A few lines above the input for the submit of those buttons, you will see several hidden input tags. Add the following to both forms:
<INPUT TYPE = "hidden" NAME = "filter_cat" VALUE = "&[g.filter_cat:entities]">
<INPUT TYPE = "hidden" NAME = "exclude_word" VALUE = "&[g.exclude_word:entities]">
<INPUT TYPE = "hidden" NAME = "the_fieldlist" VALUE = "&[g.the_fieldlist:entities]">
<INPUT TYPE = "hidden" NAME = "dopowersearch" VALUE = "&[g.dopowersearch]">

8) In the same function, MMUI_Search, you will see the form for the Add to Basket button. It looks like <MvIF EXPR = "{ MMUI_ProductLayout.d.adbutton }"> followed by the form tag. Right after that you will see several hidden inputs. Add the following to both places where the adbutton form is located.
<INPUT TYPE = "hidden" NAME = "filter_cat" VALUE = "&[g.filter_cat:entities]">
<INPUT TYPE = "hidden" NAME = "exclude_word" VALUE = "&[g.exclude_word:entities]">
<INPUT TYPE = "hidden" NAME = "the_fieldlist" VALUE = "&[g.the_fieldlist:entities]">
<INPUT TYPE = "hidden" NAME = "dopowersearch" VALUE = "&[g.dopowersearch]">

9) After you've installed this, you will probably want to get rid of the old standard search. Simply go back up to the point where you inserted the two lines which call the Power_Search_Prompt. Then above that, comment out the form and table for the standard search which is directly above that point. Then below the commented out original table and the line which calls the Power_Search_Prompt, add the following line:
<MvASSIGN NAME = "g.dopowersearch" VALUE = "1">