Problem with Woocommerce node, fails on Product > Get All

Hi everyone!

I’m trying to use Get All Products on the WooCommerce node and it returns “ERROR: Cannot read property ‘split’ of undefined”

The message it returns:

TypeError: Cannot read property 'split' of undefined
    at Object.woocommerceApiRequestAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/WooCommerce/GenericFunctions.js:47:44)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/WooCommerce/WooCommerce.node.js:253:40)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:447:47

The simple workflow I’m using:

{
“nodes”: [
{
“parameters”: {
“operation”: “getAll”,
“returnAll”: true,
“options”: {}
},
“name”: “WooCommerce”,
“type”: “n8n-nodes-base.wooCommerce”,
“typeVersion”: 1,
“position”: [
420,
300
]
}
],
“connections”: {}
}

n8n version: 0.151.0
Database: PostgreSQL
Running on docker using the latest image on DockerHub

Thanks in advance!

Hi @Alejandro_Bonnin, welcome to the community :tada:

I’m very sorry to hear you’re running into this problem. I’ll need to set up a WordPress instance and install WooCommerce to give this a go first hand and will report back once done. Just to make sure: You do have products added to your WooCommerce database, right?

On a more general note, when posting code like the JSON representation one of your workflow, would you be able to wrap it in a preformatted block by using this button (or by manually adding three backticks ``` above and below your snippet)?

image

This will help greatly with copying it as it will prevent the forum from applying any formatting (though in this case it’s not a real problem as this is not a very complex workflow :wink:). I’ve also added these backticks to the question template to make it easier going forward.

Thank you so much!!

Yes, right now I have 10,300 products in the database, but it only allows me to import up to 100 products and if I try to import all at once it gives me the error.

Understood, thanks for the advice. I’ll do it the next time!

Thanks in advance!

1 Like

Thanks @Alejandro_Bonnin, it’s quite helpful to see this is happening only for a larger amount of products. Based on this info I assume the problem would then only occur if the Return All option is enabled (as in your example workflow) but otherwise the node is working fine?

Maybe there’s a problem with the pagination logic then. I’ll insert some more products in my store next to see what happens.

Okay, after adding a bit of additional logging I can see there definitely is definitely wrong with pagination when the Return All option is enabled.

image

The node would fetch page 1 and page 2 with 100 products each in an endless loop:

I could not reproduce the exact error you have described though @Alejandro_Bonnin. The split method from the error trace you have shared refers to the response headers received from WooCommerce, which for some reason does not seem to be available in your example. I wonder if this might just be a side effect of the problem I have noticed.

Let me fix the pagination problem first, maybe this also addresses your issue :slight_smile:

Found the issue and raised a pull request with a fix for the pagination problem:

We’ll let you know once it’s released.

1 Like

Hi! Thanks a lot @MutedJam
Have a nice day!

Regards, Alex

1 Like