2 - Last update parameter

Modified on Tue, 19 May at 4:18 PM


Introduction and data structure


Through the Sales Layer API, you can export only the items modified after a given date. This is controlled by the last_update parameter passed to the SDK function get_info().

!

Warning: if the connector has been modified or refreshed after the date stored in last_update, the API returns all items and the previous date is ignored.

This example uses the connector created in Example 1, with the same tables, filters, and parameters. 



Because no label or search filters are configured, the only active filter is the visible status.

  • 14 visible categories
  • 5 visible products
  • 6 visible variants





The last modification date of the categories is 19/05/2026 at 16:05. The products were last modified on 19/05/2026 at 16:07 , and the visible variants were last modified on 19/05/2026 at 16:08.


Code


The script is almost the same as in Example 1, but this time get_info() receives a real $last_update value instead of 0.

<?php 
define('LOC_BASE', dirname(__FILE__) . '/');
require(LOC_BASE.'SalesLayer-Conn.php');
require(LOC_BASE.'lib/nice_r-master/Nicer.php');
?>

<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
    <link rel="stylesheet" type="text/css" href="lib/nice_r-master/nice_r.css?version=<?php echo filemtime(LOC_BASE.'lib/nice_r-master/nice_r.css'); ?>"/>
    <script type="text/javascript" src="lib/nice_r-master/nice_r.js?version=<?php echo filemtime(LOC_BASE.'lib/nice_r-master/nice_r.js'); ?>"></script>
</head>

<body>
    <?php
    //SL connector credencials
    $connector_id = 'CN12347H3308C4486';
    $secret_key = '7aeb575d9bf15bfa238e8f01842417a2';
    
    //Definition of the last_update parameter
    $last_update= "1597924800";

    //Create object with the credentials on the connector in SL
    $SLConn = new SalesLayer_Conn ($connector_id, $secret_key);

    //API Call to export the information
    $SLConn->get_info($last_update);

    if ($SLConn->has_response_error()) {
        echo "<h4>Error:</h4>\n\n Code: ".$SLConn->get_response_error().
             "<br>\nMessage: ".           $SLConn->get_response_error_message();
    } else {
        echo "<h4>Response OK</h4>\n".
             "<p>".
             "API version: <b>".            $SLConn->get_response_api_version()          ."</b><br />\n".
             "Time: <b>".                   $SLConn->get_response_time('unix')                 ."</b><br/>\n".
             "Default language: <b>".       $SLConn->get_response_default_language()     ."</b><br/><br />\n".
             "</p>";

        //Print the API response
        $n = new Nicer($SLConn->get_response_table_data());
        $n->render();
        echo "<hr/>";

    }       
    ?>
</body>
</html>

In the first call, the example uses 20/05/2026 12:00 UTC , which corresponds to the UNIX value 1779271200. This means the API should return only changes made after that moment.

After checking the response with has_response_error(), the script prints the API version, the request time, the default language, and the returned data structure.


Execution and results


When the script is executed with a $last_update later than the actual item changes, the API returns zero modified items in all tables.



To see the parameter in action, the example changes $last_update to 21/08/2020 11:00 UTC, or 1598004000.

With that date, the category table still returns no modified items, because no category changed after that moment.



In the product table, the product with reference 42PH420305221 was modified. Since it has variants, the API exports both the modified product and its related variants.



In the variant table, there are 3 directly modified variants after the selected date. However, because the parent product was also modified, the API exports all related variants for that product, bringing the total to 5.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article