Custom Search Fields, structurally updated in version 3.5, are probably one of the most powerful features in the ProductCart e-commerce system. For an overview of what they are and what they can be used for, please see Managing Custom Search Fields.
Here we will focus on the database structure and provide some sample information on how to query this important product-level information from the store database.
Contains general information about a certain Custom Search Fields.
Used for the Drill-down navigation feature, where custom search fields are associated with categories.
The “Show Custom Search Fields” section of the product details page in the storefront contains a useful query that you could use in other sections of the application to retrieve product-specific custom search field information. This query returns all Custom Search Fields and field values assigned to the product. Prior to using the following query you must set a variable named “pIdProduct” to the ID of the product you want to query.
Public Sub pcs_CustomSearchFields
Dim query,rs,pcArr,intCount,i
query="SELECT pcSearchFields.idSearchField,pcSearchFields.pcSearchFieldName,pcSearchData.idSearchData,pcSearchData.pcSearchDataName,pcSearchData.pcSearchDataOrder FROM pcSearchFields INNER JOIN (pcSearchData INNER JOIN pcSearchFields_Products ON pcSearchData.idSearchData=pcSearchFields_Products.idSearchData) ON pcSearchFields.idSearchField=pcSearchData.idSearchField WHERE pcSearchFields_Products.idproduct=" & pIdProduct & " AND pcSearchFieldShow=1 ORDER BY pcSearchFields.pcSearchFieldOrder ASC,pcSearchFields.pcSearchFieldName ASC;"
set rs=connTemp.execute(query)
IF not rs.eof THEN
pcArr=rs.getRows()
set rs=nothing
intCount=ubound(pcArr,2)
response.Write("<div style='padding-top: 5px;'></div>")
For i=0 to intCount
response.write "<div class='pcShowProductCustSearch'>"&pcArr(1,i)&": <a href='showsearchresults.asp?customfield="&pcArr(0,i)&"&SearchValues="&Server.URLEncode(pcArr(2,i))&"'>"&pcArr(3,i)&"</a></div>"
Next
END IF
set rs=nothing
End Sub
If you instead wish to query the value associated with a specific Custom Search Field for a certain product, you can use the following ASP code, where “pcStrFieldName” is the variable that contains the field name and “pIdProduct” is the variable that holds the Product ID. Here we assume the Product ID is 100 and the field name is called “Resolution” (e.g. a Digital Camera). The variable “pcStrFieldValue” will hold the result of the query.
pcStrFieldName = "Resolution"
pIdProduct = 100
query="SELECT pcSearchFields.idSearchField, pcSearchFields.pcSearchFieldName, pcSearchData.idSearchData, pcSearchData.pcSearchDataName FROM pcSearchFields INNER JOIN (pcSearchData INNER JOIN pcSearchFields_Products ON pcSearchData.idSearchData=pcSearchFields_Products.idSearchData) ON pcSearchFields.idSearchField=pcSearchData.idSearchField WHERE (pcSearchFields_Products.idproduct=" & pIdProduct & " AND pcSearchFields.pcSearchFieldName LIKE '" & pcStrFieldName & "');"
set rsCS=Server.CreateObject("ADODB.Recordset")
set rsCS=connTemp.execute(query)
IF not rsCS.eof THEN
pcStrFieldValue = rsCS("pcSearchDataName")
else
pcStrFieldValue = "N/A"
END IF
set rsCS=nothing
You can print a Pick List for selected orders from the View All Orders page in the Control Panel. This can help your staff fulfill orders by picking products from where they are warehoused. Using a Custom Search Field, you can easily add a product's location in your warehouse(s) to your product database.
Here is a screen shot of the end result. Notice the “Location” column on the Pick List. You can test this feature on your own by using the Apparel Add-on demo store on our Early Impact Web site (Orders > View All Orders > Check Orders > Print Pick List).
Here are the simple steps to follow:
<% '// INVENTORY LOCATION '// Enter the field name Dim pcStrLocationFieldName pcStrLocationFieldName = "Location" %>
By using Custom Search Field, you can now also use the Inventory Location of your products as a search field whenever you are filtering products in any of the Control Panel features that use the search filters. You can also export this information by including Custom Search Fields in your export file.