I'm trying to find a way to autopopulate an image url field in Woocommerce products. where products are uploaded via csv.
So I have a csv (that I will not be able to alter the format, or be uploading ) being regularly used for mass product import/update. It contains a product code that is imported to woocommerce product as the SKU. The SKU's are in the format:
category01var1234
category03var1235
etc
Remote images exist for each product, using subfolders, in a format that is calculable from the SKU:
imageserver.com/category01/category1var1234.jpg
imageserver.com/category01/category03var1235.jpg
etc.
The subfolder is always the first 10 digits of the product code. and the jpg name is always all the digits of the product code
Is there a way to autopopulate an image url field with the url and subfolder information. And can this be done even though I'm not using Cred, or inputting products manually, but via .csv?
I looked at:
https://toolset.com/forums/topic/auto-populate-a-text-area-field-from-another-custom-field/
which seemed really close, but didn't know if the "via admin" code, would be usable for csv product import
I'm aware this is pretty niche, but any help is appreciated!
Hello,
There isn't such kind of built-in feature within Toolset plugins.
And it depends on the CSV importer plugin you are using, I suggest you check it the CSV importer plugin author for these:
1) Is there any action hook after a post is imported and saved into database,
2) If there is such an action hook, you can use it to get the product post information:
https://codex.wordpress.org/Function_Reference/get_post
https://developer.wordpress.org/reference/functions/get_post_meta/
3) Use above information to get your custom image URL, then populate it into "image url field" value:
https://developer.wordpress.org/reference/functions/update_post_meta/
I have searched it in google, and found some related Woocommerce CSV importer plugin:
hidden link
More help:
https://developer.wordpress.org/reference/functions/add_action/
For your reference.
Ok, thanks for that info. I'll look into those, though it looks like it might be a little beyond my capabilities.
I'm just using the standard, built-in woocommerce csv importer.
I assume we are talking about this addon:
https://docs.woocommerce.com/document/product-csv-importer-exporter/
You can check it with Woocommerce supports:
https://woocommerce.com/contact-us/
And according to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/
You can also check it with Toolset contractors:
https://toolset.com/contractors/
I assume we are talking about this addon:
https://docs.woocommerce.com/document/product-csv-importer-exporter/
Yes, although it is not an "addon", it is part of Woocommerce.
Thanks for the information, the Woocommerce plugin isn't Toolset plugin, so we are not the best source of their API action hook, you can check it with their supports for the correct action hook name, then apply your custom PHP codes.