Product CVS Import; automatic Handle generation

Product CVS Import; automatic Handle generation

arzt-shop
Tourist
7 0 3

I m using products import for Shopify with ten thousands of products. Now I added more locatios so I need another  (inventory) CSV import for the stock. In the inventory CSV import I need to know the generated Handle by Shopify. Ideally I just take the same algorith, apply it to the title field and then I have the Handle used by Shopify. But I can not find a detailed description of the algorithm; the page which describes just lowercase and substitition of blanks; but a lot more is going on. Due to System restrictions I can not just query Shopify to get all handles, I need to have the Handle "locally". Is there a way or open-source code how Shopify is generated Handle Column from Title? 

Ref: https://help.shopify.com/en/manual/products/import-export/using-csv#product-csv-file-format

Thx

Replies 2 (2)

HazilStudiosNYC
Shopify Partner
139 23 26

Hey Arzt,

Simple hack:
1. Export your products from Shopify to get the products including handles.
2. Compare the inventory CSV and map the product handles by SKU / titles

Hope this helps

Best,
Flo

Flo | Co-Founder and CEO; Hazil - Shopify Mentorship
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
-
Want fast help? Chat with me
arzt-shop
Tourist
7 0 3

Hi - thx a lot; after some trial & error ... here is what works using postgres-sql - it give a good idea how the algorithm looks like: 

 

create materialized view inventory_csv as
select
COALESCE(
REGEXP_REPLACE(
REGEXP_REPLACE(
TRANSLATE(
LOWER("Title"),
'äèéöüê',
'aeeoue'
),
'[^a-z0-9-]',
'-',
'g'
),
'-+',
'-',
'g'
)
) AS "Handle",
"Title",
"Option1 Name",
"Option1 Value",
null as "Option2 Name",
null as "Option2 Value",
null as "Option3 Name",
null as "Option3 Value",
"Variant SKU",....

 

thx