ProductQueryRq (Request)

The ProductQueryRq request allows users to retrieve product and option information from the Fortune3 database. All relevant product information will be included in the response. It can be used to retrieve all of the products in the ecommerce website, or a single product, or a group of products based on certain conditions (Filters).

Retrieving All Products

Although Fortune3 recommends filtering your requests in order to save bandwidth and response lengths, you can retrieve the information for all of the products on your ecommerce shopping cart. Proceed as follows:

Sample Code:

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<ProductQueryRq RequestID="1" />
</sendRequestXML>

Warning: If your shopping cart has more than 1,000 products, please do not query all of your products, as this may cause problems with your database and even crash your site. Instead use filters in your queries to only retrieve certain products based on criteria or conditions.

Retrieving Certain Products (Using Filters)

You can use Filters to limit which products you get in the response based on certain conditions, and therefore highly optimize the response by shortening it to only include your conditions. Using the <Filters> node, you can specify as many filters as you like that must be matched in order for the Product to be returned in the response. Since you can specify multiple filters within the same request, and each filter can have different settings, you must also specify individual <Filter> nodes for each filter you want to add to your request. Proceed as Follows:

Sample Code (retrieving product SKU “ABC1”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<ProductQueryRq RequestID="1">
  <Filters>
    <Filter>
      <SKU>ABC1</SKU>
    </Filter>
  </Filters>
</ProductQueryRq>
</sendRequestXML>

Available Filters for ProductQueryRq

Tag Name Sub-Tag Of Description Field Type Can Repeat
Filters ProductQueryRq The Filters Activation Node Node False
Filter Filters The Current Filter Node Node True
SKU Filter Matches the Product's SKU String True
Name Filter Matches the Product's Name String True
Brand Filter Matches the Product's Brand String True
UPC Filter Matches the Product's UPC String True
MfgPartNum Filter Matches the Product's Mfg. Part Number String True
CategoryName Filter Matches the name of the Category the product is in (one level only) String True

Using Multiple Filters

You can use multiple filters within a single request by either adding the multiple filters to the same <Filter> node, or by adding separate <Filter> nodes for each filter. By using the same <Filter> node to list multiple filters, you cannot add filtering options and you are therefore limited to the default filtering settings, which is to do an “exact” match of the filter, and to separate each filter with an “or”, so that each filter will produce a result independent of the other filters:

Sample Code (SKU matches “ABC1” or Brand matches “Sony”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<ProductQueryRq RequestID="1">
  <Filters>
    <Filter>
      <SKU>ABC1</SKU>
      <Brand>Sony</Brand>
    </Filter>
  </Filters>
</ProductQueryRq>
</sendRequestXML>

Filtering Options

However, if you use multiple <Filter> nodes for each filter, you can specify the options for each Filter using Filtering Options.

There are 2 XML tags that you can use on each filter to specify the options for that filter, <FilterMatch> and <FilterStyle>.

The 'FilterMatch' tag is available for every filter type in the ProductQueryRq and allows you to specify if you would like to do an “exact” match of the filter (the default), or a “contains” match of the filter, making your condition match if the value you send partially matches the result in the databse (where SKU contains “ABC”).

The 'FilterStyle' tag is only used if you are using more than one <Filter> node and should only be used for the 2nd filter and on (not for the first). It allows you to specify if the current filter you are sending should be matched with an 'or' parameter when following the previous filter (the default), or an 'and' parameter. Using 'and' will make the current filter match in addition to the previous filter (which is why the first filter should not have it), whereas using 'or' (or omitting the 'FilterStyle' since this is the default value) will make the current filter match, whether or not the previous filter matched.

Tag Name Sub-Tag Of Description Field Type Allowed Values Can Repeat
FilterStyle Filter Specifies if the current filter is
independent from the previous filter
String “or”
“and”
False
FilterMatch Filter Specifies if the current filter must
be an exact match or a “like” match
String “exact”
“contains”
False

Sample Code (Name contains “Television” and Brand matches “Sony” and CategoryName contains “Entertainment”):

<sendRequestXML>
<authenticate>
<APIUsername>TWmY6WBft</APIUsername>
<APIPassword>SKW8ssAmDu6xTGDl</APIPassword>
</authenticate>
<ProductQueryRq RequestID="1">
  <Filters>
    <Filter>
      <Name>Television</Name>
      <FilterMatch>contains</FilterMatch>
    </Filter>
    <Filter>
      <Brand>Sony</Brand>
      <FilterStyle>and</FilterStyle>
      <FilterMatch>exact</FilterMatch>(optional)
    </Filter>
    <Filter>
      <CategoryName>Entertainment</CategoryName>
      <FilterStyle>and</FilterStyle>
      <FilterMatch>contains</FilterMatch>
    </Filter>
  </Filters>
</ProductQueryRq>
</sendRequestXML>

Using these guidelines, you can fully filter out the ProductQueryRq response to only provide you with the products that you need.

Next: Reading the Response (ProductQueryRs)

Print/export