Helcim Logo Support & Tutorials

© Copyright 2006-2018 Helcim Inc.

All Rights Reserved.

Helcim Commerce API » Inventory »

View a Product

This API call let's you retrieve a product. The response is an XML of the product's information.

Request Fields

Field Name Type Required Description
action String Yes productView
accountId Integer Yes The Helcim Commerce account ID.
apiToken String Yes API token used for authentication and access control. 
productId Integer Yes (or) You can provide either product ID or product SKU to retrieve a product.
sku String Yes (or) You can provide either product ID or product SKU to retrieve a product.

Response Fields (XML)

Field Name Type Description
products - XML structure
product - XML structure
id Integer The product ID.
name String The product name.
sku String The product SKU.
brand - XML structure
id Integer The brand ID.
name String The brand name.
category - XML structure
id Integer The category ID.
name String The category name.
description String The product description.
barcode String The product bar code.
availability Integer 1 or 0 - Whether the product is available for sale.
availabilityOnline Integer 1 or 0 - Whether the product is available for sale online.
featured Integer 1 or 0 - Whether the product is featured (front page) item online.
stock Integer The number of items in stock.
price Decimal The product price.
salePrice Decimal The product sale price.
weight Decimal The product weight - based on Helcim Commerce Unit of Measurement (UoM) account settings.
dimensionW Decimal The product width- based on Helcim Commerce Unit of Measurement (UoM) account settings.
dimensionL Decimal The product length - based on Helcim Commerce Unit of Measurement (UoM) account settings.
dimensionH Decimal The product height - based on Helcim Commerce Unit of Measurement (UoM) account settings.
shippingExempt Integer 1 or 0 - Whether the product is exempt from shipping fees.
taxExempt Integer 1 or 0 - Whether the product is exempt from taxes.
pictures - XML structure - Pictures are ordered with the primary picture set as the first one.
picture - XML structure
main String The URL location of the full-size picture (1200px)
thumb String The URL location of the small-size picture (500px) 
small String  The URL location of the thumbnail-size picture (120px) 

Errors

For all API requests, there are also generic API authentication and user access restriction errors.
Response Code Error Code Message Description
0 - Invalid Product ID The product ID you provided could not be found.
0 - Invalid Product SKU The product SKU you provided could not be found.

Code Samples

HTML Form Sample HTML

<input type="hidden" name="accountId" value="YOUR-ACCOUNT-ID">
<input type="hidden" name="apiToken" value="YOUR-API-TOKEN">
<input type="hidden" name="action" value="productView">
<input type="hidden" name="productId" value="1701232">
<input type="hidden" name="SKU" value="SKU123">

Response Sample XML

<products>
	<product>
		<id>170</id>
		<name>MY PRODUCT NAME 123</name>
		<sku>SKU12312312333123123</sku>
		<brand>
			<id>11</id>
			<name/>
		</brand>
		<category>
			<id>10</id>
			<name/>
		</category>
		<description>This is a good product.</description>
		<barcode>1019209309109239</barcode>
		<availability>1</availability>
		<availabilityOnline>1</availabilityOnline>
		<featured>1</featured>
		<stock>7</stock>
		<price>17.07</price>
		<salePrice>14.97</salePrice>
		<weight>12.12</weight>
		<dimensionW>13.13</dimensionW>
		<dimensionL>14.14</dimensionL>
		<dimensionH>17.17</dimensionH>
		<shippingExempt>1</shippingExempt>
		<taxExempt>0</taxExempt>
		<pictures>
			<picture>
			<main>https://yourstore.myhelcim.com/images/2/HcmComm-Pic--147431637948.jpg</main>
			<thumb>https://yourstore.myhelcim.com/images/2/tmHcmComm-Pic--147431637948.jpg</thumb>
			<small>https://yourstore.myhelcim.com/images/2/smHcmComm-Pic--147431637948.jpg</small>
			</picture>
		</pictures>
	</product>
</products>

Sending a CURL Request PHP

<?php

	// CHECK IF THE FORM WAS SUBMITTED
	if(@$_POST['submit']){

		// SET URL
		$url = "https://secure.myhelcim.com/api/";

		// BUILD POST ARRAY
		$postArray = array(
			'accountId' => 'CHANGEME',
			'apiToken' => 'CHANGEME',
			'action' => 'productView',
			'productId' => '170');
		
		// CREATE POST STRING
		$postString = http_build_query($postArray)

		// SET CURL OPTIONS
		$curlOptions = array(	
			CURLOPT_RETURNTRANSFER => 1,
			CURLOPT_AUTOREFERER => TRUE,
			CURLOPT_FRESH_CONNECT => TRUE,
			CURLOPT_HEADER => FALSE,
			CURLOPT_POST => TRUE,
			CURLOPT_POSTFIELDS => $postString,
			CURLOPT_TIMEOUT => 30 );

		// CREATE NEW CURL RESOURCE
		$curl = curl_init($url);

		// SET CURL OPTIONS
		curl_setopt_array($curl,$curlOptions);

		// PROCESS TRANSACTION - GET RESPONSE
		$response = curl_exec($curl);

		// CLOSE CURL REOURCE
		curl_close($curl);

		//CREATE XML OBJECT
		$xmlObject = @simplexml_load_string($response);

		// CHECK FOR XML OBJECT
		if(is_object($xmlObject)){

			//
			// XML DATA READY
			//

			echo 'Response Received';

		}else{

			//
			// ERROR OCCURED 
			//

			echo 'Error Occured';

		}
	
	}

?>