0

I am trying to sync only approved Products, unfortunately below created Restrictions completely ignored by sync.

INSERT_UPDATE CatalogVersionSyncJob;code[unique=true];sourceVersion(catalog(id),version)[unique=true];targetVersion(catalog(id),version)[unique=true];syncPrincipals(uid);sessionUser(uid)
 ;testSyncJob;Default:Staged;Default:Online;syncUserGroup;syncUser



 INSERT_UPDATE JobSearchRestriction; code[unique = true] ; job(code) ; query ; type(code)
; syncuser_restriction ; mySyncJob ; {approvalStatus} IN ({{ SELECT {pk} FROM {ArticleApprovalStatus} WHERE {code}= 'approved'}}) ; Product


INSERT_UPDATE SearchRestriction;code[unique=true];name[lang=en];query;principal(UID);restrictedType(code);active;generate
;syncuser_restriction;Sync Only Approved Products;{approvalStatus} IN ({{ SELECT {pk} FROM {ArticleApprovalStatus} WHERE {code}= 'approved'}});syncUserGroup;Product;true;true

May I know the reason of ignoring above restrictions by sync? and how to fix?

john
  • 15
  • 8

1 Answers1

0

It's not recommended to use approvalStatus.

See this post from SAP

You can find below a copy-paste

Which Items Will be Synchronized?

Synchronizing can be done either on the entire catalog version (easiest option) or can be done on a select group of items.

There are two typical use cases for filtering the items to be synchronized:

There is a requirement to synchronize only approved products. The recommended practice is to avoid using the out of the box "approvalStatus" attribute as you may want to synchronize products which are not approved. The recommended practice is to introduce a new attribute "readyForSync" as a boolean type. A business user or a business logic would be responsible for setting the attribute to TRUE. A restriction would guarantee that only confirmed products are synchronized. Synchronize a subset of items (such as products of a specific category) to a specified target catalog version.

One important consideration, in an enterprise setting where there are many concurrent product managers, is the coordination of the synchronization. The "readyForSync" flag can be helpful to schedule products for the next synchronization run. However, it offers limited granularity of control in an environment where there are multiple teams managing their own lines of products. To provide a more granular coordination, it is recommended to use a hybrid approach where the "readyForSync" flag and the category-specific synchronization are used together. This way, different teams managing different brands or categories would not affect each other in unintended ways and it offers more flexibility in terms of when the synchronization can be run.

If you synchronize using a scheduled cron job then a search restriction can be used with a dedicated synchronization user:

INSERT_UPDATE SearchRestriction|code[unique=true]|name[lang=en]|query|principal(UID)|restrictedType(code)|active|generate|Backend_Sync_Product|Sync|{item.readyForSync}=1|syncgroup|Product|true|true


As a side note, I don't know on which version you are working on. It used to not work well in older version. (mentionned on this old page that will probably get deleted)

If you synchronize manually, then things can get tricky again:

Concurrent invocations from more than one business users result in some of the attempts aborting without an informative error message.
References to items in the same catalog version will not be synchronized unless marked as "copy by value" or "part-of".
Restrictions used for scheduled cron job synchronization do not work. Everything gets synchronized.
alain.janinm
  • 19,951
  • 10
  • 65
  • 112
  • whatever you provided answer is an alternative approach, but I have tried both the approaches and both of them are ignoring restrictions. BTW, am using 1905 version – john Nov 23 '21 at 13:15