Goldinteractive / craft3-sitecopy

With this plugin you can copy the content of an entry to another site.
MIT License
22 stars 6 forks source link

Matrix blocks are copied to too many sites #33

Closed jripmeester closed 2 years ago

jripmeester commented 2 years ago

Current Behavior Using SiteCopy on a entry with a normal field a matrix field. Select copy content to another site and hit save. The content is copied to the selected site but the matrix field content is copied to all sites and overwrites correct content on other sites (which were not selected on save).

Translation behaviour

This problem only affects the matrix field.

Expected Behavior The content should have been copied to only the selected site(s). Matrix block fields should be copied for only the selected site(s).

Steps to Reproduce Install Craft Add plugin Gold Sitecopy Add 2 sites to the configuration Add a section with a Matrix field and a translatable field within it. Create an entry (only title is enough) and select to copy this to an other site. Hit save.

Plug-in verisons Craft 3.7.44 Sitecopy 0.7.1

lukasNo1 commented 2 years ago

I think the problem here is "Text field with matrix block: Translate for each site group." Which means if you save this matrix block in any site, craft will automatically overwrite it for every other site in this site group.

lukasNo1 commented 2 years ago

if you want the content to be per site, you should change the propagation method of the fields.

jripmeester commented 2 years ago

@lukasNo1 The propagation setting is exactly how we want it (per site-group) and that's working like a charm. But the plugin is ignoring that and copying to all sites.

I've made a video with an example. Please ask for access after clicking on the link. https://drive.google.com/file/d/1jgR5_3o5fUD9Hs23GyAiFGZDuUCYuWxx/view?usp=sharing

lukasNo1 commented 2 years ago

With "Matrix field: no translation" Do you mean the propagation settings are set to "Save blocks to all sites the owner element is saved in"?

Because no translations means "Only save blocks to the site they were created in" in the craft workflow, in which case this problem should not exist.

I could reproduce the issue with the first propagation setting. So i think this is the one you have set too.


The issue is that when copying a matrix block that is saved to all sites, it will change on all sites and not only the one we save it in.

I'll have a look into it, I think we need to change the plugin to only copy the fields of the matrix block instead of the whole block when the propagation setting is set to "all"

jripmeester commented 2 years ago

Hi @lukasNo1, What you describe sound exactly like what is happening. If the plugin is copying the whole matrixblock instead of the content within it than that's what causing this issue.

Can i help you in anyway to make this change easier?

lukasNo1 commented 2 years ago

The issue seems pretty clear to me now.

I'll get back to you if I need more information.

lukasNo1 commented 2 years ago

This issue should be fixed now, can you test if everything is working for you aswell?

I pushed the fix to the develop branch composer require goldinteractive/craft3-sitecopy:dev-develop

jripmeester commented 2 years ago

@lukasNo1 We've checked it locally which worked nice. After that our client tested it on their staging and same results. So seems to be fixed! Thanks a lot!

lukasNo1 commented 2 years ago

Thats great to hear!

I just released the new version 0.8.0 with this fix.