Split comma-separated strings from single JSON value pulled from xlsx

Describe the issue/error/question

I’m trying to set up an automation that scans a local xlsx file containing product information, parses the data and then creates new products/updates existing products according to the changes in WooCommerce.

What is the error message (if any)?

I’m extracting a string from a spreadsheet cell which is delimited by a command a space. They’re relative URLs to images for WooCommerce products. I’ve been able to convert this single string into an array using JS split which has returned multiple values which I can then map in the WooCommerce node.

However, is there a way to set the number of images to be imported by the WooCommerce node by how many values are in the array? Is it also possible to assign each value in the array to the next incremental number?

On the last node you’ll see that I’ve manually added images and assigned each value from the array. This strikes me as poor practice as oftentimes I will have more or fewer images, so this (in my eyes) should dynamically adjust according to the number of values.

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.175.1
  • Database you’re using (default: SQLite): default
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @rapidscampi, unfortunately I am not aware of a way to use a dynamic number of images on the WooCommerce node :frowning:

I can very much see how useful such a feature would be though. I suppose “Add Image” operation on the node could do the job as this would allow you to loop through each image, running the operation as often as needed. So I shall convert your question into a feature request, allowing you and other users to vote on this (and thus helping both our product team and our community prioritize development efforts).

As a workaround for now you could consider building different paths for different numbers of images using the Switch node. As in send item to WooCommerce1 node if there is 1 image, send item to WooCommerce2 node for 2 images, and so on.

1 Like