How to display the Stanley/Stella collection correctly

When you download the Stanley/Stella products catalogue via our Products API (either CSV or JSON/REST), you receive all the data we maintain about our products. You then have to display it correctly in your online catalogue. This short guide explains you how to do this the right way.


Products sequence

Normally, the API (CSV or JSON/REST) returns the list of products already in the right sequence, i.e. the sequence determined by Stanley/Stella.The styles are sorted in the way we want to present the collection. The colors are sorted according to our color palette. The sizes are sorted from the smallest to the largest one. The new styles of the current collection are also normally the first styles in the list.

If you follow the sequence of the list you downloaded via the API then you should normally display the collection in the right way.


If for any reason, the sequence is lost, you can always sort the products again thanks to the following attributes:

  • At the level of the style, you will find an attribute "SequenceStyle" containing an integer representing the position of the style in the collection. Sort it ascending to get the collection sorted again.

  • At the level of the variant, you will find 2 attributes : "ColorSequence" and "SizeSequence". Sort these 2 attributes in ascending order to get the colors and sizes sorted again.


Products visibility

Not all products that we send via the API are actually in the collection.

Appearance in the API

Our SKU's have a start and an end date. We publish products via the API:

  • 1 month before their start date

  • 1 year after their end date

This means that new products will not appear in the API earlier than 1 month before their start date or later than 1 year after their end date.

If a product does not longer appear in the API, you MUST remove it from your online catalogue since this product is probably discontinued.


Published status

Each style and each variant has a "Published" status that you can find in the attribute "StylePublished" at style level and "Published" at variant level.

If the "StylePublished" attribute of a style is false, you may not display the corresponding style in your online catalogue (or not include it if you start from scratch).

If the "Published" attribute of a variant is false, you may not display the corresponding variant in your online catalogue.

Examples:

  • Some styles are removed from our collection. Their status is then "unpublished". These styles should not appear anymore in your online catalogue.

  • Some new styles may not appear yet in your online catalogue. Their status is then "unpublished".

  • Between the winter and the summer collections, some colors of one particular style are removed, others added. The status of the style is still "published". But the status of the variants can be "published" or "unpublished" depending if the color is in the collection or not. You should remove the colors that are not in the collection anymore and add the colors that are in collection.

See the PHP example hereunder on how to implement this logic.


"New" flag

In the API, you will also find, on each variant, 2 flags indicating the "new" status of a product. You can use this flag to determine if you must add a "new" label on the products in your online catalogue.

  • "NewStyle" : This indicates that the style is new in the current collection. By default, the new styles are at the top of the API list. Be sure to display these styles as the first styles in your catalogue.

  • "NewColor" : This indicates that the color is new for the current collection.


Note: There are also 3 other "new" flags for the size, the product and the item. The "new" flag on the size indicates that the size is a new size in the collection. The "new" flag on the product indicates that the style+color combination is new (it can be an existing style and an existing color (on other styles) but the combination is new). The "new" flag on the item indicates that the combination style+color+size is new.

Stock

All this information about the products is independent of the available stock.

A specific SKU may be visible in the API but with an available stock of 0.

On the contrary, you can have SKU's visible in the API with a status "Unpublished" with available stock.

In any case, be sure to use our Stock API if you need to know if there is enough available stock for your order. See our Stock API documentation here.

Illustration in PHP code

 As an illustration, we propose you the following PHP code. Feel free to start from this code and adapt it to your needs.


<?php
ini_set("memory_limit","128M");
ini_set("max_execution_time",9000);
ini_set('default_charset', 'utf-8');
function getAllSTSTProductsV2($language) {
$url = "https://api.stanleystella.com/webrequest/productsV2/get_json";
$jsonData = array(
'jsonrpc' => '2.0',
'method' => 'call',
'params' => array(
'db_name' => "production_api",
'password' => "YOUR_PASSWORD",
'user' => "YOUR_USER",
"LanguageCode" => $language
),
'id' => 0
);
$ch = curl_init($url);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
$jsonDataDecoded = json_decode(json_decode($result)->result, true);
curl_close($ch);
return $jsonDataDecoded;
}
$languagecode = 'en_US';
$stpm = getAllSTSTProductsV2($languagecode);
?>
<!DOCTYPE html>
<html>
<head>
<title>Stanley/Stella Variant Matrix Visualization</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> </head>
<body>
<div class='container'>
<?php
$c = 0;
foreach ($stpm as $style) {
$variantmatrix = array();
$allsizes = array();
foreach ($style["Variants"] as $variant) {
$allsizes[$variant["SizeCodeNavision"]] = $variant["SizeCodeNavision"];
if (!isset($variantmatrix[$variant["ColorCode"]])) $variantmatrix[$variant["ColorCode"]] = array();
$variantmatrix[$variant["ColorCode"]][$variant["SizeCode"]] = array();
$variantmatrix[$variant["ColorCode"]][$variant["SizeCode"]]["sku"] = $variant["B2BSKUREF"];
$variantmatrix[$variant["ColorCode"]][$variant["SizeCode"]]["published"] = $variant["Published"];
$variantmatrix[$variant["ColorCode"]][$variant["SizeCode"]]["newcolor"] = $variant["NewColor"];
$variantmatrix[$variant["ColorCode"]][$variant["SizeCode"]]["newsize"] = $variant["NewSize"];
}
if ($style["StylePublished"]) {
$c++;
echo "<div class='row'>";
echo "<h2>".$style["StyleCode"]." is published and ";
if ($style["Variants"][0]["NewStyle"]) {
echo "is a new style</h2>";
} else {
echo "is an existing style</h2>";
}
echo "<table class='table table-bordered'><thead><tr><th></th>";
foreach ($allsizes as $key => $size) {
echo "<th>".$size."</th>";
}
echo "</tr>";
echo "</thead><tbody>";
foreach ($variantmatrix as $color => $row) {
echo "<tr>";
echo "<td>".$color."</td>";
foreach ($row as $sku) {
if ($sku["published"]) {
echo "<td bgcolor='#70AD47'>";
} else {
echo "<td bgcolor='#FF0000'>";
}
if ($sku["newcolor"]) {
echo "New color<br/>";
}
if ($sku["newsize"]) {
echo "New size";
}
echo "</td>";
}
echo "</tr>";
}
echo "</tbody></table>";
echo "</div>";
} else {
echo "<div class='row'>";
echo "<h2>".$style["StyleCode"]." is not published. It will not be displayed</h2>";
echo "</div>";
}
}
?>
</div>
</body>
</html>


Result: