This function returns a list of related products for a given product.
Description#
This function returns a list of related products for a given product. This is a runtime function intended to be called client side to query related product data. Because this is a runtime (public) function no API key is required. This function has ondemandcolumns to optionally retrieve inventory, attribute and options, discounts, sale price, and default category. In addition, there are optional filters to return images including dynamically requesting image sizes that may not exist yet.
Request Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
count |
Number | Maximum lines of data allowed to be returned in the response. This limit is used to prevent excessive amounts of data return | |
filter |
String | A string for filtering returned data | |
offset |
Number | Used with the Count parameter for paginating results of large datasets. Default 0 is no offset. | |
sort |
String | The order for sorting returned data | |
session_type |
String | This will always have a hard-coded value of “runtime.” This tells Miva, no authentication is needed for the API call. | |
Session_ID |
String | Optional Passing the Session_ID in the request will allow any customer-specific discounts get applied. | |
product_idProduct_Code |
Number String |
ID Number of product Product code string |
On Demand Columns#
| Name | Description |
|---|---|
descrip |
Full HTML product description |
inventory |
Inventory count and inventory settings |
attributes |
Product attributes and options |
sale_price |
Discounted sale price for the product. When sale_price is requested, the price standard field will be overwritten with the sale price value. |
discounts |
Any discounts applied to the product creating the sale_price |
category |
Canonical category for each product. This is determined, first by the canonical category, if specified, and second, the first category to which the product is assigned. |
facets |
Loads the available facets for the result set |
subscriptionsettings |
Loads subscription settings for the products returned |
subscriptionterms |
Loads subscription terms for the products returned |
CustomField_Values:* |
See custom field usage here: List Load Query Overview |
Other Custom Filters#
| Name | Description |
|---|---|
imagetypes |
This filter may be specified more than once. Each instance of the filter may request different sizes. If “sizes” is not specified, only the original image is returned. Requested sizes that do not exist will be generated. |
images |
This filter returns all of the images assigned to a product, regardless of image type. Any sizes passed will be generated/returned for all images. |
runtime_search |
Performs a runtime search against the products (same as if the customer used the search box on the site). Only the columns included in the response are searchable. Inventory and attributes are not searched. |
productvariant_possible |
When present, adds a productvariant_possible object to each product in the response, indicating which attribute options are in-stock/selectable for the product’s variants. This output matches amPossible/Runtime_AttributeList_Load_ProductVariant_Possible. See Parameters below. (Introduced in Version 26.03.00) |
productvariant_possible Parameters#
Parameter |
Type | Description |
|---|---|---|
select_one |
Boolean | Determines whether generated dropdown lists include a “Select One” placeholder entry.false — AttributeMachine’s “Preload - Drop-Down Lists Do Not Contain Select One” (preload).true — AttributeMachine’s “Preload - Drop-Down Lists Contain Select One” (preload_select_one). |
dependency_resolution |
String | One of first, cascade, or last, controlling how AttributeMachine resolves which options are shown/selected/disabled based on other selected attributes.first — First Selected Attribute Shows all Options.cascade — Cascade.last — Most Recently Selected Attribute Shows all Options. |
Supported Sort Columns#
One of these values would be passed in the sort request parameter to have the results sorted by that column.
Column |
Description |
|---|---|
relevance |
Sort by relevance |
newest |
Sort by newest |
code_asc |
Sort by code (ascending) |
name_asc |
Sort by name (ascending) |
price_asc |
Sort by price (ascending) |
bestsellers |
Sort by bestsellers |
customfield |
Sort by custom field |
oldest |
Sort by oldest |
code_desc |
Sort by code (descending) |
name_desc |
Sort by name (descending) |
price_desc |
Sort by price (descending) |
Response Parameters#
| Parameter | Type | Description |
|---|---|---|
total_count |
Number | total_count is the total number of records that match your search criteria. Note: this is not always the total products returned. Based on the Count and Offset parameters passed, the number of records returned could be different than the total_count. |
start_offset |
Number | Number of the starting offset number of products to return. Used in conjunction with the Count parameter for paginating results of large datasets. |
id |
Number | Product Id |
code |
String | Miva Product Code (unique) |
Sku |
String | Product SKU |
image |
String | [Depreciated] This field is depreciated and is supported for legacy purposes. Relative Path to the product fullsize image. |
thumbnail |
String | [Depreciated] This field is depreciated and is supported for legacy purposes. Relative Path to the product thumbnail image. |
disp_order |
Number | Product Display Order |
output_disp_order |
Number | Output Product Display Order |
dt_created |
Object | Date Time Stamp the product was created |
dt_Updated |
Object | Date Time Stamp the product was last updated |
weight |
Number | Product Weight |
taxable |
Boolean | true/false flag if the product is taxable |
price |
Number | Product Price |
formatted_price |
String | Currency-Formatted Product Price |
retail |
Number | Retail price before any discounts have been applied |
formatted_retail |
String | Currency-Formatted Retail Price |
base_price |
Number | Includes any legacy price group discounts but does not reflect sales, coupons or discounts applied in the basket |
formatted_base_price |
String | Includes any legacy price group discounts but does not reflect sales, coupons or discounts applied in the basket |
quantity |
Number | Quantity |
url |
String | Canonical URL to the product |
descrip |
String | Only output if “descrip” is passed as an ondemandcolumn. Full HTML description. |
attributes |
Object | Attributes |
sale_price |
Number | Sale Price with discounts applied. If you want customer-specific prices the Sesssion_ID should also be passed in the request |
inv_active |
Boolean | Boolean flag for Inventory Active for this product |
inv_level |
String | One of In Stock, Low Stock, Out of Stock |
inv_available |
Number | Inventory Available |
inv_available |
Number | Inventory Available. This is the instock amount - threshold you have set for out of stock level (default is 0) |
inv_instock |
Number | Inventory In Stock |
inv_short |
String | Inventory Short Message |
inv_long |
String | Inventory Long Message |
page |
Object | Page Template |
category |
Sting | Canonical Category Code Product is Assigned To |
discounts |
Object | Discounts |
images |
Object | Images |
imagetypes |
Object | Request Images By Image Types. Contains child objects with the image type name. |
productvariant_possible |
Object | Only output when the productvariant_possible filter is present. Indicates which attribute options are in-stock/selectable across the product’s variants. (Introduced in Version 26.03.00) |
CustomField_Values:* |
Object | See custom field usage here: List Load Query Overview |
dt_created Object#
| Parameter | Type | Description |
|---|---|---|
time_t |
Unix Timestamp | Unix Timestamp for date created |
year |
Number | Year |
month |
Number | Month |
day |
Number | Day |
hour |
Number | Hour |
minute |
Number | Minute |
second |
Number | Second |
timezone |
Number | Offset from UTC |
dt_Updated Object#
| Parameter | Type | Description |
|---|---|---|
time_t |
Unix Timestamp | Unix Timestamp for date updated |
year |
Number | Year |
month |
Number | Month |
day |
Number | Day |
hour |
Number | Hour |
minute |
Number | Minute |
second |
Number | Second |
timezone |
Number | Offset from UTC |
attributes Object#
| Parameter | Type | Description |
|---|---|---|
id |
Number | Attribute ID |
product_id |
Number | ID of product attribute is assigned to |
default_id |
Number | ID of default attribute option |
disp_order |
Number | Display Order. Used in sorting attributes. |
code |
String | Attribute Code |
type |
String | One of the following types: radio, checkbox, text, memo, swatch, swatch-select |
attemp_id |
Number | Will contain the id of the attribute id reference, otherwise 0 |
prompt |
String | Attribute Text displayed to customer during runtime |
price |
Number | Attribute Price |
formatted_price |
String | Currency Formatted Attribute Price |
weight |
Number | Attribute Weight |
required |
Boolean | Flag if the Attribute is Required |
inventory |
Boolean | Flag if Inventory is being tracked on this attribute. Required when using Inventory Variants. |
image |
String | Attribute Image - Relative path to image file. |
options |
Object | Options |
options Object#
| Parameter | Type | Description |
|---|---|---|
id |
Number | Option ID |
product_id |
Number | ID of product attribute is assigned to |
attr_id |
Number | ID of attribute option is assigned to |
disp_order |
Number | Display Order. Used in sorting options. |
code |
String | Option Code |
prompt |
String | Option Text displayed to customer during runtime |
price |
Number | Option Price |
formatted_price |
String | Currency Formatted Option Price |
weight |
Number | Option Weight |
image |
String | Option Image - Relative path to image file. |
productvariant_possible Object#
Output only when the productvariant_possible filter is present. It has the same structure as the Runtime_AttributeList_Load_ProductVariant_Possible response, based on the product’s default attribute selections.
| Parameter | Type | Description |
|---|---|---|
success |
Integer | 1 when the data loaded. |
data |
Object | The pricing, weight, variant and attribute data. See below. |
productvariant_possible:data Object#
| Parameter | Type | Description |
|---|---|---|
variant |
Object | Output only when the selected options match a variant. See variant below. |
have_price |
Boolean | true when a price could be calculated for the selections. |
retail |
Float | Retail price. |
formatted_retail |
String | Formatted retail price. |
base_price |
Float | Base price. |
formatted_base_price |
String | Formatted base price. |
price |
Float | Price for the selections. |
formatted_price |
String | Formatted price. |
weight |
Float | Weight for the selections. |
formatted_weight |
String | Formatted weight, including units. |
padded_weight |
String | Weight as a string, without units. |
attributes |
Array of Objects | One entry per attribute. Empty when the product has no attributes. See attributes below. |
productvariant_possible:data:variant Object#
| Parameter | Type | Description |
|---|---|---|
variant_id |
Integer | ID of the matched variant. |
inv_active |
Boolean | true when inventory tracking is on for the variant. |
inv_available |
Integer | Quantity available. |
inv_instock |
Integer | Quantity in stock. |
inv_level |
String | Inventory level: in, low or out. |
inv_long |
String | Long inventory message. |
inv_short |
String | Short inventory message. |
productvariant_possible:data:attributes Object#
| Parameter | Type | Description |
|---|---|---|
id |
Integer | Attribute ID. |
attmpat_id |
Integer | Attribute template attribute ID. 0 when the attribute isn’t from a template. |
selected_id |
Integer | ID of the selected option. |
options |
Array of Integers | IDs of the options that can be selected with the current selections. |
page Object#
| Parameter | Type | Description |
|---|---|---|
id |
Number | Page Id for template controlling product (default template is PROD) |
code |
String | Page Code for template controlling product. (default template is PROD) |
title |
String | Title of Page Template |
discounts Object#
| Parameter | Type | Description |
|---|---|---|
descrip |
String | Discount Description |
discount |
Number | Discount Amount |
formatted_discount |
String | Currency-Formatted Discount Amount |
images Object#
| Parameter | Type | Description |
|---|---|---|
code |
String | Image Type Code, if assigned |
descrip |
String | Image Type Description |
sizes |
Object | Sizes will have child objects with the name width of the images. Ie. 50x50, 100x100. Original is the non-resized image |
sizes Object#
| Parameter | Type | Description |
|---|---|---|
url |
String | Full URL to Image |
width |
Number | Image Width |
height |
Number | Image |
imagetypes Object#
| Parameter | Type | Description |
|---|---|---|
descrip |
String | Image Type Description |
sizes |
Object | Sizes will have child objects with the name width of the images. Ie. 50x50, 100x100. Original is the non-resized image |
imagetypes.sizes Object#
| Parameter | Type | Description |
|---|---|---|
url |
String | Full URL to Image |
width |
Number | Image Width |
height |
Number | Image Height |
discounts Object#
| Parameter | Type | Description |
|---|---|---|
descrip |
String | Discount Description |
discount |
Number | Discount Amount |
formatted_discount |
String | CUrrency Formatted Discount Amount |
Example Requests#
{
"Store_Code": "{{Store_Code}}",
"Miva_Request_Timestamp": "{{$timestamp}}",
"Function": "Runtime_RelatedProductList_Load_Query",
"Session_Type": "runtime",
"Product_Code": "shirt",
"Count": 0,
"Offset": 0,
"Filter": [
{
"name": "search",
"value": [
{
"field": "active",
"operator": "EQ",
"value": true
}
]
},
{
"name": "imagetypes",
"value": {
"types": ["main", "back"],
"sizes": ["original", "200x200"]
}
},
{
"name": "images",
"value": {
"sizes": ["original", "100x100", "50x50"]
}
},
{
"name": "productvariant_possible",
"value": {
"select_one": false,
"dependency_resolution": "first"
}
},
{
"name": "ondemandcolumns",
"value": ["descrip", "inventory", "attributes", "sale_price", "discounts", "page", "category", "facets", "subscriptionsettings", "subscriptionterms", "CustomField_Values:*"]
}
]
}
Example Response#
{
"success": 1,
"data": {
"total_count": 1,
"start_offset": 0,
"data": [
{
"id": 6,
"code": "pants",
"name": "Pants",
"sku": "",
"image": "",
"thumbnail": "",
"disp_order": 6,
"output_disp_order": 1,
"dt_created": {
"time_t": 1670626506,
"year": 2022,
"month": 12,
"day": 9,
"hour": 14,
"minute": 55,
"second": 6,
"timezone": -8
},
"dt_Updated": {
"time_t": 1670626935,
"year": 2022,
"month": 12,
"day": 9,
"hour": 15,
"minute": 2,
"second": 15,
"timezone": -8
},
"weight": 0.0,
"taxable": true,
"price": 50.0,
"formatted_price": "$50.00",
"retail": 50.0,
"formatted_retail": "$50.00",
"base_price": 50.0,
"formatted_base_price": "$50.00",
"quantity": 0,
"url": "https://local.coolcommerce.net/mm5/merchant.mvc?Screen=PROD&Product_Code=pants",
"descrip": "This is the product description!",
"attributes": [],
"productvariant_possible": {
"success": 1,
"data": {
"variant": {
"variant_id": 2,
"inv_active": true,
"inv_available": 30,
"inv_instock": 25,
"inv_level": "in",
"inv_long": "25 available for immediate delivery",
"inv_short": "In Stock"
},
"have_price": true,
"retail": 24.99,
"formatted_retail": "$24.99",
"base_price": 24.99,
"formatted_base_price": "$24.99",
"price": 24.99,
"formatted_price": "$24.99",
"weight": 0.375,
"formatted_weight": "0.375 lb",
"padded_weight": "0.375",
"attributes": [
{
"id": 1,
"attmpat_id": 0,
"selected_id": 1,
"options": [ 1, 2, 3, 4 ]
},
{
"id": 2,
"attmpat_id": 0,
"selected_id": 6,
"options": [ 5, 6, 7, 8 ]
}
]
}
},
"sale_price": 50.0,
"formatted_sale_price": "$50.00",
"inv_active": false,
"inv_level": "",
"inv_available": 0,
"inv_instock": 0,
"inv_short": "",
"inv_long": "",
"page": {
"id": 68,
"code": "PROD",
"title": ""
},
"discounts": [],
"subscriptionsettings": {
"product_id": 6,
"enabled": false,
"mandatory": false,
"can_cancel": true,
"cncl_min": 0,
"can_qty": true,
"qty_min": 0,
"can_term": true,
"term_min": 0,
"can_date": true,
"date_min": 0
},
"subscriptionterms": [],
"images": [
{
"code": "main",
"descrip": "Main",
"sizes": {
"original": {
"url": "https://local.coolcommerce.net/mm5/graphics/00000002/1/image2.jpeg",
"width": 440,
"height": 440
},
"100x100": {
"url": "https://local.coolcommerce.net/mm5/graphics/00000002/1/image2_100x100.jpeg",
"width": 100,
"height": 100
},
"50x50": {
"url": "https://local.coolcommerce.net/mm5/graphics/00000002/1/image2_50x50.jpeg",
"width": 50,
"height": 50
}
}
}
],
"imagetypes": {
"main": {
"descrip": "Main",
"sizes": {
"original": {
"url": "https://local.coolcommerce.net/mm5/graphics/00000002/1/image2.jpeg",
"width": 440,
"height": 440
},
"200x200": {
"url": "https://local.coolcommerce.net/mm5/graphics/00000002/1/image2_200x200.jpeg",
"width": 200,
"height": 200
}
}
}
},
"CustomField_Values": {
"cmp-mv-prodctgy-meta": {
"keywords": "",
"description": ""
},
"customfields": {
"Brand": "Miva, Inc"
}
}
}
],
"facets": {
"Brand": {
"type": "checkbox",
"values": [
{
"value": "Miva, Inc",
"count": 1
}
]
}
}
}
}