Skip to Content
author's profile photo Former Member
Former Member

Exclude Attribute from Synchronization programmatically.

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?

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 20, 2016 at 09:23 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 19, 2016 at 08:59 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 19, 2016 at 09:01 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.