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

Translatable fields in Matrix are set for all languages. #1537

Open
stefanfriedrich opened this issue Oct 22, 2024 · 4 comments
Open

Translatable fields in Matrix are set for all languages. #1537

stefanfriedrich opened this issue Oct 22, 2024 · 4 comments
Labels

Comments

@stefanfriedrich
Copy link

stefanfriedrich commented Oct 22, 2024

Description

When I have a translatable field in a matrix-block feed-me will overwrite the content of this field for all languages.
When importing content to matrix-blocks, feed-me doesn't seem to check for the chosen target site.
(Matrix-Block Propagation Method: "Save entries to all sites the owner element is saved in")

Steps to reproduce

  1. Create matrix field
  2. Add translatable field (e.g. text) to the matrix field
  3. Add feed-me jobs for the different languages
  4. Import content via job into the translatable field
  5. Field will be set for all languages and will overwrite content for other languages

Additional info

  • Craft version: 5.4.8
  • PHP version: 8.2.24
  • Database driver & version: MySQL 8.0.40
  • Plugins & versions: Feed Me 6.5.0

Logs from database:

Job for site=craftDe:
{"Match existing element with data {"idorig":"65"}."}
{"Existing element [#41] (https://craft.test/cmsadm/entries/sectionWebsite/41-freie-stellen?site=craftDe) found."}
{"Data to update for matrixContent: {"new1":{"type":"headline","enabled":true,"collapsed":false,"fields":{"headline":"Freie Stellen"}}}."}
{"Data ready to import {"title":"Freie Stellen","matrixContent":{"new1":{"type":"headline","enabled":true,"collapsed":false,"fields":{"headline":"Freie Stellen"}}},"idorig":"65","headline":"Freie Stellen"}."}
{"Entry [#41] (https://craft.test/cmsadm/entries/sectionWebsite/41-freie-stellen?site=craftDe) updated successfully."}

Job for site=craftEn:
{"Match existing element with data {"idorig":"65"}."}
{"Existing element [#41] (https://craft.test/cmsadm/entries/sectionWebsite/41-freie-stellen?site=craftEn) found."}
{"Data to update for matrixContent: {"new1":{"type":"headline","enabled":true,"collapsed":false,"fields":{"headline":"Vacancies"}}}."}
{"Data ready to import {"title":"Vacancies","matrixContent":{"new1":{"type":"headline","enabled":true,"collapsed":false,"fields":{"headline":"Vacancies"}}},"idorig":"65","headline":"Vacancies"}."}
{"Entry [#41] (https://craft.test/cmsadm/entries/sectionWebsite/41-freie-stellen?site=craftEn) updated successfully."}

Guess as matrix-blocks are more or less entries by itself they also have to be checked for siteId.

@brandonkelly
Copy link
Member

This has come up a couple times before (#463, #634). It’s currently working as expected, as Feed Me doesn’t have a way of identifying existing nested Matrix entries. So it will wipe out all existing nested entries for the field on each import, and recreate them based on the import data.

The way to work around that is to set your Matrix field’s Propagation Method to “Only save entries to the site they were created in”, so only the current site’s entries get removed/recreated during the import.

That said, we’re going to look into making it possible to import nested entries directly via their own import job, via new “Field” and “Owner Element” entry import settings. That way you’ll be able to match incoming nested entry data against existing entries, and update them if they already exist, like any other entry import.

@stefanfriedrich
Copy link
Author

Hmm. Is there no way to check for a site Id on a nested entry? As normal text fields do this?

@brandonkelly
Copy link
Member

It already does only re-import the nested entries based on the site ID.

However, if the Matrix field’s propagation method is set to “Save blocks to all sites the owner element is saved in”, then all sites share the same set of nested entries. So when Feed Me deletes the existing nested entries so new ones can be imported, those nested entries will get deleted for all the sites they belong to.

Which is why the current solution here is that you change your propagation method to “Only save entries to the site they were created in”. Then, when Feed Me deletes the existing nested entries, it’s only deleting them for that one site, leaving the other sites’ nested entries in-tact.

@stefanfriedrich
Copy link
Author

“Save blocks to all sites the owner element is saved in” would lead to: the user has to upload every picture, every cta, every not-translatable matrix field multiple times - for every language.
Maybe I can import the data with “Save blocks to all sites the owner element is saved in” and switch it back to "Save entries to all sites the owner element is saved in" afterwards.

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

No branches or pull requests

2 participants