Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unable to match an existing element." when updating against a slug #1515

Closed
jimmerk opened this issue Sep 20, 2024 · 6 comments
Closed

"Unable to match an existing element." when updating against a slug #1515

jimmerk opened this issue Sep 20, 2024 · 6 comments
Assignees

Comments

@jimmerk
Copy link

jimmerk commented Sep 20, 2024

Description

Using Craft 5.4.4 and FeedMe 6.3.0, MySQL 8

I have about 80 existing articles that I'm trying to update with title tags and meta descriptions from an xml file. I tried this with a cvs file first and got the "unable to match" error. So I "summoned" an xml schema and exported the data as xml. Still getting the same error. I'm sure the slugs exist and should match. I've tried selected the root from three different levels in the hierarchy (including one that lists the record count). I also tried to match on the Title. Same issue.

The xml schema and a sample record...

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="posts">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="post" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="BlogName" type="xs:string"/>
              <xs:element name="PostTitle" type="xs:string"/>
              <xs:element name="PostSEOTitle" type="xs:string"/>
              <xs:element name="PostLanguage" type="xs:string"/>
              <xs:element name="Slug" type="xs:string"/>
              <xs:element name="Author" type="xs:string"/>
              <xs:element name="Tags" type="xs:string"/>
              <xs:element name="MetaDescription" type="xs:string"/>
              <xs:element name="PublishDate" type="xs:date"/>
              <xs:element name="LastModifiedDate" type="xs:date"/>
              <xs:element name="PostBody" type="xs:string"/>
              <xs:element name="FeaturedImageURL" type="xs:string"/>
              <xs:element name="HeadHTML" type="xs:string"/>
              <xs:element name="Status" type="xs:string"/>
              <xs:element name="Archived" type="xs:boolean"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<posts>
	<post>
		<BlogName>stuff</BlogName>
		<PostTitle>stuff</PostTitle>
		<PostSEOTitle>stuff</PostSEOTitle>
		<PostLanguage>stuff</PostLanguage>
		<Slug>stuff</Slug>
		<Author>stuff</Author>
		<Tags>stuff</Tags>
		<MetaDescription>stuff</MetaDescription>
		<PublishDate>stuff</PublishDate>
		<LastModifiedDate>stuff</LastModifiedDate>
		<PostBody>stuff</FeaturedImageURL>
		<HeadHTML/>
		<Status>stuff</Status>
		<Archived>stuff</Archived>
	</post>
</posts>
</xml>

Steps to reproduce

  1. Run the update feed while trying to match on a slug

Results in errors like this...
Unable to match an existing element. Have you set a unique identifier for ["slug"]? Make sure you are also mapping this in your feed and it has a value. - Element.php: 178.

Any help would be greatly appreciated! Thanks.

@jimmerk jimmerk added the bug label Sep 20, 2024
@jimmerk
Copy link
Author

jimmerk commented Sep 26, 2024

Still having trouble with this after the recent update.

@i-just
Copy link
Contributor

i-just commented Oct 9, 2024

Hi, thanks for getting in touch! Could you please share a screenshot of the entire mapping screen and also let me know what you have selected as the Primary Element?

@i-just i-just self-assigned this Oct 9, 2024
@jimmerk
Copy link
Author

jimmerk commented Oct 9, 2024

Image

I'm only updating two fields in the meta section. I've tried using all three levels in the hierarchy for the Primary Element, including /root, /posts, and /posts/post.

@i-just
Copy link
Contributor

i-just commented Oct 9, 2024

Thanks for the info!

Your Primary Element should be /posts/post. There’s a bit more info on this subject here.

As for the error you’re getting, the field you want to use as the unique identifier must also be mapped. Without that mapping, the import has no data to match the elements in the system against. Here’s a bit more info about unique identifiers.

I hope this helps!

I will close this now, but feel free to reach out again if you run into any further problems.

@i-just i-just closed this as completed Oct 9, 2024
@jimmerk
Copy link
Author

jimmerk commented Oct 9, 2024

I really didn't want to wake up today as the guy who didn't read the docs! Thank you. It worked.

@i-just
Copy link
Contributor

i-just commented Oct 9, 2024

Glad to hear it's all working as expected now 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants