craftcms / feed-me

Craft CMS plugin for importing entry data from XML, RSS or ATOM feeds—routine task or on-demand.
Other
289 stars 139 forks source link

Hierarchy not maintained when importing categories with different levels (5.8.0) #1522

Open jmauzyk opened 1 month ago

jmauzyk commented 1 month ago

Description

After upgrading to 5.8.0, categories imported by title to a category field do not maintain hierarchy and include ancestors if there are more than one category with different levels.

After import with 5.7.0:

Screenshot 2024-10-02 at 9 52 46 AM

After import with 5.8.0:

Screenshot 2024-10-02 at 9 50 15 AM

Steps to reproduce

  1. Set up an element data import and configure a node to import categories by title to a category field.
  2. Import element data with a node that contains more than one category that have different levels in the category structure.

Additional info

i-just commented 1 month ago

Hi, thanks for getting in touch! I’m unable to replicate this on a clean install. Are you importing into an Entry? Could you share a snippet of your feed and a screenshot of the mapping screen?

jmauzyk commented 7 hours ago

Sorry for the delayed response here. I'm importing into a Product element. Here's a snippet of the category data in the XML feed:

    <Categories>
        <Category><![CDATA[Frame & Fork]]></Category>
        <Category><![CDATA[Parts]]></Category>
    </Categories>

Here is a screenshot of the associated mapping: Image

I dug into this a bit more to try and figure out the source of the issue, and while examining the relations table I noticed that there was a category saved in the relations table that wasn't displaying. The category was one by the same name (Frame & Fork), but in a different category group. It seems that something changed in 5.8.0 so that when searching for category matches by title, it no longer scopes to the category groups defined by the field. As a result, both categories with matching titles are saved to the relation field, which in turn prevents the parent category from being saved.

i-just commented 7 hours ago

Thanks for the additional info! It sounds like you might be running into this one: https://github.com/craftcms/feed-me/issues/1530. PR's already raised, but hasn't been released yet.