# Brightpearl > Shopify - inventory stock

## Introduction

This process flow updates Shopify with Brightpearl inventory. With no direct facility to retrieve the latest inventory from Brightpearl, the flow is designed to pull SKUs from the latest orders; search products in Brightpearl and retrieve availability information; compare this data with Shopify and sync changes.

## Process flow snapshot

<details>

<summary><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FSUvxsp8XwrC9qsafJMIe%2Ficon%20process%20flow.svg?alt=media&#x26;token=ad1dc886-4a4e-4cad-9ad0-3d755e0f3b5a" alt="" data-size="line"> Click to view process flow snapshot</summary>

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F5pLdoDXItmM3lJ9Zzg6H%2FBrightpearl%20%3E%20Shopify%20-%20Inventory%20stock%20-%20full%20flow.png?alt=media&#x26;token=c4ceea4e-b7f0-40bc-a8a6-33b5729bc4c2" alt="" width="375"><figcaption></figcaption></figure></div>

</details>

## Limitations

<table><thead><tr><th width="266.79296875">Limitation</th><th>Summary</th></tr></thead><tbody><tr><td>Retrieving inventory from Brightpearl </td><td>With no direct way to retrieve inventory or 'last changed' items using the Brightpearl API, a number of steps are needed to achieve the required results. As a result, this flow cannot be run on an automated schedule. </td></tr></tbody></table>

## Assumptions

<table><thead><tr><th width="266.79296875">Assumption</th><th>Summary</th></tr></thead><tbody><tr><td>Existing data status</td><td>Assumes all products and contacts are already synced in both systems</td></tr></tbody></table>

## Customisation

To ensure that this process flow runs as required, some customisation options are available. These are documented in the following sections:

* [Flow variables](#flow-variables)
* [Process shape shapes](#process-flow-shapes)

### Flow variables

The table below summarises [flow variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables) defined for this process flow.

<table><thead><tr><th width="163.5078125">Flow variable</th><th>Summary</th><th>Default value</th></tr></thead><tbody><tr><td>datefrom</td><td>Set the relative number of days to look back for updates. Update the default value as required.<br><br>This variable is referenced in the first Shopify connector, where a filter query is defined to determine which SKUs to pull.</td><td>-20 minutes UTC</td></tr></tbody></table>

{% hint style="info" %}
For information on working with flow variables, please refer to our [flow variables documentation](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables).
{% endhint %}

### Process flow shapes

This process flow includes some shapes that can be configured with your own settings. Please see guidelines in the table below.

{% hint style="warning" %}
Shape settings determine the outcome of process flows. Do not change shape settings unless they are listed below.&#x20;
{% endhint %}

<table data-full-width="false"><thead><tr><th width="220.09375">Shape</th><th>Notes</th></tr></thead><tbody><tr><td>Trigger</td><td>The default schedule for this flow is to run <code>every 20 minutes</code>. This is the recommended run frequency but the schedule can be changed if necessary.</td></tr><tr><td>Connector (Shopify)</td><td><p>If you did not add or select a Shopify instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Get skus from recent orders</code><br><code>Filter</code> : The default filter references the <code>datefrom</code> <a href="#flow-variables">flow variable</a> as below:</p><pre data-overflow="wrap"><code>created_at:>='{{flow.variables.datefrom}}'
</code></pre></td></tr><tr><td>Connector (Brightpearl)</td><td><p>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance</p><p><code>Source endpoint</code> :  Set to <code>GET Search products</code><br><code>Parameters</code> :  A default filter is defined to search (and match) on <code>SKU</code> where the value is set to <code>[[payload.sku]]</code>.</p></td></tr><tr><td>Connector (Shopify)</td><td>If you did not add or select a Shopify instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Retrieve inventory data by GraphQL</code><br><code>Location ID</code> : Enter the location ID associated with the Shopify location that you want to search.<br><br>Note that this flow is configured to process a single location. If you have multiple locations, you would need to redefine this flow with multiple branches. </td></tr><tr><td>Connector (Brightpearl)</td><td><p>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance</p><p><code>Source endpoint</code> :  Set to <code>GET Get Product availability</code><br><code>Id</code> : Set to <code>[[payload]]</code>.</p></td></tr><tr><td>Connector (Brightpearl)</td><td><p>If you did not add or select a Brightpearl instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Brightpearl</code> instance</p><p><code>Source endpoint</code> :  Set to <code>GET Get warehouse by id</code><br><code>Id</code> : Set to <code>[[payload]]</code>.</p></td></tr><tr><td>Connector (Shopify)</td><td>If you did not add or select a Shopify instance during the blueprint <a href="../installation-guide-shopify-and-brightpearl">installation process</a>, the following settings must be configured:<br><br><code>Source instance</code> : Set to your required <code>Shopify</code> instance.<br><code>Source endpoint</code> :  Set to <code>POST Inventory adjust quantities graphQL</code><br><code>Inventory Id</code> : Set to <code>[[payload.inventoryItemId]]</code><br><code>Delta</code> : Set to <code>[[payload.delta]]</code><br><code>Location Id</code> : Set to <code>[[payload.locationId]]</code> </td></tr></tbody></table>

## Reference

Reference information for this process flow is documented in the following sections:

* [Scripts used in this process flow](#scripts-in-this-process-flow)
* [Cross-reference lookups used in this process flow](#cross-reference-lookups-in-this-process-flow)

### Scripts in this process flow

<table><thead><tr><th width="293">Script</th><th>Summary</th></tr></thead><tbody><tr><td> Pull ID after product search</td><td> Pulls the ID from the retrieved Brightpearl data.</td></tr><tr><td>BP - generate graphql string for search</td><td> Creates a searchable string for Shopify.</td></tr><tr><td>BP - generate query for inventory search</td><td>Creates a query to search for product availability. Allows wide product set searches.</td></tr><tr><td> BP - calculate inventory for Shopify</td><td>Calculates the delta if there is one.</td></tr></tbody></table>

### Cross-reference lookups in this process flow

This process flow does not use cross-reference lookups.
