Showing posts with label Shopify adapter. Show all posts
Showing posts with label Shopify adapter. Show all posts

Friday, September 24, 2021

#879 - OIC Pub/Sub with OCI Streaming

Simple use case here - publish and subscribes to events from Shopify. 





Normally I would be doing this with orders, however, my trial Shopify account doesn't allow me to create orders, so I'm leveraging Products here. But, I know you are all experts at extrapolating.

Now someone may think of using Pub/Sub pattern available when creating a new integration in OIC. However, as you can see - it has been deprecated.




 




The publish to OIC integration style has been deprecated. Oracle recommends that you use app driven orchestration and use an invoke to publish a message into the OIC streaming service.

So let's take that advice -

Here is my Stream - ProductStream-NiallC









Now to the Connection creation in OIC - Please see my Shopify blog posts for details on how to create that connection. So now to the OCI Streaming connection creation - 



 Bootstrap Servers entry can be found here - 
As you can see, it also contains the SASL username. You need to generate an Auth Token for the SASL Password - 














Check out the OIC OCI Streaming adapter docs for the steps to create the Trust Store. Test and Save the Connection - 





Now to the "Publish" integration - very simple really - 














I get the JSON for the PublishProduct request payload from the Shopify api docs here














Configuration of the PublishProduct action is as follows - 












I activate and test by creating a new product in Shopify and then check out the stream - 



So that's the Publish part addressed. Now to the subscribe - for this I use a Scheduled Integration - 












The above is the final result - let's look at the integration in detail - 






















Subscribe2NewProduct is configured as follows - 














Now to the message structure - 


 








This I copy from the Recent Messages view from Streaming












The only logic I add is a LOG action - to output the product name - 







Now to testing the Subscribe - 

I add 2 new products in Shopify -









I run the scheduled integration -



Monday, August 17, 2020

#795 - OIC Shopify Adapter improvements - August Release New Feature



1. The OIC Shopify adapter is now certified with the 2020-04 version of the Shopify api.

2. The OIC Shopify adapter now supports the Inventory Level Update event -


















I specify some Tracking fields - activate and test -

Starting point is one product in Shopify




The relevant Shopify permissions have been granted -


I now change the inventory level in Shopify -


An integration flow has been triggered -


3. The Store name is now included in the Business Event payload


4. "Presentment" price support - ability to fetch prices in different currencies - e.g.
Hare of the Dog Vol 1 costs $20 in the US shop and €20 in the EMEA shop.

This requires custom header support in the Shopify adapter.





















Wednesday, July 29, 2020

#786 OIC --> Updating Product Inventory in Shopify




This is a typical use case -

I have a eCommerce site that sells the product, I have an ERP that manages the sales lifecycle.

In this case I am looking at Netsuite as the ERP and Shopify as the eCommerce site, but I assume one can extrapolate for other ERP apps.

Firstly, a big thank you to my colleague Shantala S. for her support here!

Now let's begin by looking at the Product inventory in Shopify -














Note from the inventory history, I can see the default location -
I have partially obfuscated it but you still see the street number, 168.

Ergo, we have 4 of these Leica cases in stock at the default location.

As you can see, I can have more than 1 location -


















It is very easy to add new locations in Shopify -
















Same idea in Netsuite, I have inventory items available at different locations -





















So many customers would have the same location in both Netsuite and Shopify and then synchronize the inventory between them.

In the following simple example I will will process each of my products from Shopify, updating them with the quantity available from Netsuite.

I have a large amount of products so I will avail of the Shopify pagination feature discussed in a previous blog post here

So now we will start with the processing of the individual Shopify products.

Step 1 - Check Netsuite for the quantity available

I do this via a Netsuite SavedSearch that returns items, their locations and the quantities available at those locations.



 















The map to the search is as follows -






















I have a lookup that contains the default locationInternalId from Netsuite -
this I assign to the inventoryLocation search value.
Target operator is set to anyOf.

The key I use to link Products/Items is
Product sku = itemid.

Now that I have that -














I check if the search has been successful - i.e. I have found the item at that location.
If so I update Shopify with the quantity available value.

Now, let's take a step back and look at how Shopify works in this respect -
Shopify has products - each product has an id.
Products can have variants e.g. T-Shirt in L, M and S. Each variant has an id.

Each of these variants also has an inventory item id.

Here are those fields in the product structure returned by Shopify.


























Locations in Shopify also have their ids -
























To update the inventory in Shopify I need the following -

{
  "location_id": yourLocationId,
  "inventory_item_id": yourInventoryItemId,
  "available": 20
}

Now to configuring this via the OIC Shopify adapter -

















Next, select the Create option and NOT update. 
Setting the inventory is available under Create.



































Now to the mapping -

















I have retrieved the quantityAvailable from Netsuite. I assigned it to an integration variable.


























Now I cast this variable as a number -









Now to testing this - 

Remember, my Leica Case in Shopify has quantity = 12



Here is its pendant in Netsuite Inventory -
















Note: sku and item id match.

Here is the quantity available in Netsuite for my Shopify default location -












I test the integration - 
Note this will be called from the main integration that retrieves the products from Shopify.
Request Payload contains sku and inventory_item_id


















I validate in Shopify -