verbb / navigation

A Craft CMS plugin to create navigation menus for your site.
Other
90 stars 23 forks source link

Navee Migration - Copied nodes now maintain structure #271

Closed iainsaxon closed 3 years ago

iainsaxon commented 3 years ago

Fixed database queries to address issue where old parent nodes were not found.

I encountered an issue where none of the nodes copied from Navee retained their structure.

After debugging I found there was an issue with the query to find the old node's parent appeared to be incorrect and not returning the expected result. By specifying the structureId, finding the structure node that encompasses the lft and rgt and ordering by the smallest difference between rgt - lft this fixed the issue for me.

Once the database query to find the parent was addressed I had issues still with not rebuilding the hierarchy. After looking at the hydrated $NaveeElement I found the IDs were correct for the first dozen or so results but were wrong after that. The issue appeared to be the navee_nodes table uses id to reflect the element.id which was stored as the $oldNodeId whereas content.id is its own ID and not the elementId. When hydrated the content.id was overriding the element.id value. Specifying the selected columns addressed this for me.

engram-design commented 3 years ago

Thanks for this!