Cost vs price, sorting on margin

I have a question, as I can’t seem to find out how to make it happen.

Is there a way to pull both the selling price and cost price of a product and sort them by the difference between both (products with small/no margin on top, big margin on bottom?

I have the import of products in my pet products store (over 12000 items) automated. sometimes eorrors happen, sometimes I catch them, sometimes they slip through…
Yesterday, I have sold a product UNDER cost! gaining me a net loss on the sale, and making me pay the VAT on the sale out of my own pocket as well.

To catch these errors before they arise, I would like to compare the selling vs buying price of my products, so that these faulty priced products show up on top.

Haven’t found how to do it, can anyone help me?

Hi @KittenMania,

Great question. Yes, there is a way to pull in both a product’s selling price and cost price while sorting their difference from top-down in ascending order. Here’s one way you could build this in Parabola:

5 steps: Pull from Shopify -> Enrich with an API -> Insert math column -> Sort rows -> Select columns


(Double-click on the screenshot to enlarge/zoom in for following along with these steps’ settings.)

Start out with a Pull from Shopify step to bring in the selling price information (in addition to other data points like product ID and product title). Then you’d connect this import step to the step Enrich with an API so it incorporates product cost information from a specific Shopify API endpoint. You’d calculate the difference with an Insert math column step targeting those selling price and cost columns. The Sort rows will have this appear in top-down ascending order with the smallest margins at the top. Any remainder steps in the flow are up to you on how you’d like to filter it for the dataset’s appearance. :slightly_smiling_face:

Please note: for the Enrich with an API step’s settings of username and password, you’d enter your Shopify private app API key as the username and the password as the password. (Direct link to your Shopify store’s private apps page to make and retrieve this is: https://_____.myshopify.com/admin/apps/private and replace ____ with your Shopify store name.)

Let me know how that works out for you and if you’d like any clarification on the above.

Hello Adelinde,

Thank you for replying…

I have tried your solution, but the “Enrich with an API” step keeps throwing me an error…
First it was an error that it took too long, then an error that it had too many requests per second, now it is an 503 error on line 1 and a 429 error on line 2…

I even added in a step to split up the rows in 2 parts, but to no avail

I followed every step you laid out, and can’t seem to get it right.
Could it be that my store has too many items? I have 14852 rows to start with…

@KittenMania was the step Enrich with an API’s error message “API Enrichment took longer than 3600s”? If so or similar, this is due to Parabola having a 1-hour timeout on any flow step, meaning our call to the API’s endpoint to receive or send data (rows) stops after 1 hour.

Given your row amount, to make your flow run quicker while avoiding errors, I’d advise switching to a different Shopify InventoryItem endpoint in the API enrichment step for product cost information (change from using the endpoint that retrieves a single inventory item by ID to the one that retrieves a list of inventory items).

New flow structure does ID batches to prevent timeout or max request errors:

After the Shopify import brings in selling price data, connect it to Insert row numbers to get a column of repeated numbers (i.e. the number 1 on 100 of the rows, then the number 2 on the next 100 rows, etc). Then Select columns to only keep row numbers and the variant inventory item IDs. Merge duplicate rows to get the inventory column of rows with merged ID batches (instead of one row per item ID we get one row per 100 item IDs). Connect this to the Enrich with an API noting the limit of 100 rows in the URL parameters and the top level key of intentory_items. You’d finish by combining the results from API enrichment back to the main Shopify imported data to have both api.cost and variants: price columns.


This Limit rows method will be prone to more errors, but if you’d like to continue trying it, set its settings to Keep the first 7200 rows or less so it’s within our 1hr timeout limit (7200 rows ÷ 120 requests per min = 60min). This is because Shopify’s API rate limits are 120 requests/min for the max value to use in Enrich with an API > Rate Limiting > Maximum requests per min. Update these step settings in the initial version’s flow structure:
method2

@Adeline,

Thank you SO MUCH!

This time, it worked like a charm…
Found a few more culprits, none as severe as the last one, but they have been eliminated. :sunglasses:

2 Likes