Updating Product Variants

Highlighted
Shopify Partner
14 0 1

Hi guys,

I'm working on integrating Shopify with a Point of Sale system called Apparel 21. So basically my client will manage products through AP21 and I have some scripts (in the form of a small PHP website) to get products from AP21 and push them up to Shopify. I'm having some issues with managing product variants.

Originally I was just trying to completely overwrite the variants field of an existing product with the new set of variants (so using update product as opposed to update product variant(s) ), but I kept getting errors relating to "Variant # already exists".

So this morning I've written a new process which retrieves the current variants for a product, then loops through and compares them to the variants that should exist and adds/updates or deletes them where necessary. That works fairly well except that: a). it's very slow, a lot of individual API calls. b). One of my fields is size which is just numbers like 38, 40, 42, etc and I deleted 38 manually then it was re-added with my script, but was added at the end of the variants list. I want them in numerical order. So I would prefer to go back to my first way of just overwritting the variants field for the product, but again, I was getting that error.

Can anyone help me here? Do I have to do something crazy like delete all variants and then update the product with a new (ordered) variant set?

Cheers, Pete.

0 Likes
Highlighted
Shopify Partner
371 0 54

Hey Pete,

We have worked with AP21 alot and have written connectors for other platforms, would love to work with you on this. We have been wanting to bring AP21 to Shopify for a long time.

Can you shoot me an email at mike@evulse.com as we really want to talk with you about this. 

Thanks,

Mike

Want an app but can't find what you need? Let us know we custom build apps for Free
0 Likes
Highlighted
Shopify Partner
14 0 1

Hi Mike,

I have also worked with AP21 a lot, though not so with Shopify.

I figured out how to fix my own problem: seeing as I was looping through the AP21 "variants" (equivalent) in the order I wanted I could just set a counter variable and add that as the position value for the Shopify variant. So it works, but as I mentioned in the original post it's very slow. Oh well, it works.

Cheers, Pete.

0 Likes
Highlighted
Shopify Partner
371 0 54

Good to see you fixed it. Let me know if you do want to talk. It would be free development as our interest is in creating apps specifically for the app store here in Shopify. We do a lot of integrations and as such have a nice worker/queue system, insanely fast webhook handling and redudant infastructure so you can guarantee orders that come through shopify are pushed straight through to AP21. We would have a connector for Shopify already but most companies that use AP21 are more invested in the larger soutions such as Magento Enterprise/Demandware etc. Anyway let me know if you ever have any integrations that you need to do as ERP's are a section we are very specialised in.

Want an app but can't find what you need? Let us know we custom build apps for Free
0 Likes
Shopify Partner
14 0 1

Thanks Mike, I'm covered for now.

0 Likes
Highlighted
Shopify Partner
14 0 1

BUMP

 

Still having issues with variants. If I want to completely refresh the available variants on a product then by updating the product through the API, with the new variant list it should just overwrite them as I understand it? That's not working, always throws an error about the final variant (whatever it is) "already existing".

I've tried doing 2 update calls for each product, one to delete the variants by passing an empty variants field and then the next one to re-add them but that doesn't seem to work at all. Specifically the first part, not sure how I can delete the variants on a product (all at once, not individually, that's way too slow).

0 Likes
Highlighted
Shopify Partner
14 0 1

Alright so I finally clicked on the fact that if I want to update existing variants I need to pass the variant IDs. Without passing those I guess Shopify tries to add them as new variants. Fair enough.

I retrieve and index information from AP21, then retrieve the current variant list for a product (from shopify) and loop through and create an array of variants I want to update with the ID from Shopify and the new info from AP21. Seems to work.

Still would like to know if I should be able to delete a product's variants by passing an empty variant field when doing an update.

0 Likes
Highlighted
Shopify Partner
25 0 0

Hey Peter,

I know it's a long shot as your post is 5yo. But anyway I will try my luck, did you end up creating this connector between AP21 & Shopify properly? I am working with a client that need exactly this.

Cheers

0 Likes