cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Exclude Attribute from Synchronization programmatically.

Former Member
0 Likes
3,353

Is it possible to exclude an attribute from synchronization programmatically? So that I don't need to adjust the synchronization properties manually in hmc.

The attributes must not be synchronized through CMS Cockpit nor through hmc. Also the sync marker in CMS Cockpit must not change to red when changing that attribute.

In my case it's a Date and an Enum.


My ideas so far:

  • Outsource them with a relation and don't add that relation to cmscockpit-services.xml.

  • Extend SynchronizationService with a attribute blacklist.

I don't like that solutions. Is there a more straight forward way?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

As explained by the sync marker in CMS Cockpit works on type level. Therefore it's not possible to exclude attributes without much effort.

We ended up creating a new item type with the attributes that are not relevant for synchronization.

  • This new item type has an attribute which points back to the original item type. You can't do it the other way around, else it would be synced of course, and relations cannot be 1-to-1.

  • Optionally one could create dynamic attributes on the original item type, which will retrieve the outsourced values.

  • We use an Init Defaults Interceptor to make sure the additional item gets created.

Answers (2)

Answers (2)

Former Member
0 Likes

Hi Christian,

Here are the steps to remove an attribute, for this example I will take the Product type but the same applies to any other type. As part of my example I will remove an attribute called variants from being synchronized when Product is synchronized.

  1. Go to HMC (http://localhost:9001/hmc/hybris)

  2. Click on Catalog >> Catalog Management Tools >> Synchronization

  3. From the Source catalog version table click on the catalog that you want to synchronize

  4. Click on the Catalog Versions tab

  5. From the Dependent catalog versions table, click on the Synchronization target (in my case it is: electronicsProductCatalog)

  6. Click on the Synchronization Properties tab

  7. Properties to synchronize section contains a tree whose root is: Item. Navigate that tree and open Product, then Properties, then look for the variants attribute. By default it should be checked, remove the checkmark.

  8. Scroll up and click on Save

For a programmatic approach:

As of versions 5.2 you can use Spring to configure rootTypes for both ProductCatalogSyncJob and ContentCatalogSyncJob, as well as attributes of SyncAttributeDescriptorConfig. Here is the document that explains how to do so:

Regards,

Luis

Former Member
0 Likes

Can I do this programmatically?

Former Member
0 Likes

I hope this is what you mean, if not I apologize in advance. As of versions 5.2 you can use Spring to configure attributes of SyncAttributeDescriptorConfig for given items. Have a look at the document: https://wiki.hybris.com/display/release5/commerceservices+Extension+-+Technical+Guide#commerceservic...

Former Member
0 Likes

Yes, it is. Thanks. Would be nice if you edit it into your answer.

Former Member
0 Likes

I'm glad to hear that! I also added that to the answer.

Former Member
0 Likes

Hello Christian, yes you can remove an attribute from synchronization by configuration only. See: https://wiki.hybris.com/display/release5/Synchronization+Guide#SynchronizationGuide-EditingSynchroni... point 5

Former Member
0 Likes

One more comment: The sync marker works on type level, not an attribute level, this can not be easily changed, you would need to modify the SyncTimestamp type and all the logic around it.

Former Member
0 Likes

That sounds bad... Then I'll have to use one of my other ideas.