Hi,

Simple question, I tried to understand, to use and implement NodeOrder usage through some migration (using migrate module).
But I can't find a way to correctly use it through the code. I tried to simply create $node->nodeorder as an array (tid->order) but migrate doesn't understand, probably because it's not a field.

So, I ended up having tid and position, but unable to save those pieces of information to the node.

I was hoping to find a function like nodeorder_set_node_position($node, $tid), but nothing like that seems to exist (maybe I'm not so good at reading code).

Any idea how I could do this? I can implement a nodeorder_set_node_position function if maintainers are ok.

Thanks.

Comments

qudec created an issue.

davps’s picture

Hello @qudec,

Check nodeorder_node_update() function it should helps to you.

Here is an example steps:

  • Migrate vocabularies (ensure that vocabularies are orderable)
  • Migrate terms
  • Migrate nodes:
    • Collect old weights
    • Update weights mapping according to migrated terms ID
    • Pass modified weights to $entity->nodeorder in migration prepare() method

After node will migrated and inserted should be triggered hook_node_update and new weight should be processed by nodeorder module.

Or you can update weights in complete() method and re-save node, as another solution.

I hope this helps to solve the problem.