Hi,
I'm trying to write a module that parses Yahoo Store XML feed and converts the information into product nodes and attributes using Ubercart.

I'm using the function node_save to create the product node. But in order to save attribute information to the tables I need the nid of which the attributes applies. Which is an awful architecture because it prevents creating the node and the attribute at the same time.

node_save function doesn't return a nid unfortunately, it would be nice if it did. Is there a way in Drupal to get the nid of the node created by node_save?

I don't want to just look at the last node added to the node table and get the nid because I have a multi user environment where other user can create nodes simultaneously and can potentially get the wrong nid.

Thanks,
Zade

Comments

FM-1’s picture

I think I found an answer to my own question. I can access the node object after performing node_save($node) and it would have the nid assigned.

That was a dumb question on my part. thanks!

Drave Robber’s picture

Your answer is correct though. :)