Closed dfrommi closed 8 months ago
Hi @dfrommi , thank you for reporting this issue. We will check it and let you know the results.
To help us reproducing your issue please let us know
Regards, Sarah
Hello Sarah,
thanks for your answer.
We're trying to use the latest version as of now, which is 10.0.2
, as we have to migrate to SDK v2 before end of the year.
Unfortunately I can't post products into publicly available issues. But you can create any attribute which references a product, like this:
Hope this is good enough, otherwise I can maybe share project-key and product-id of an example, if you'd have access to them. But I'd have to clarify first, so I hope that's enough.
Hi @dfrommi , thanks for your response. The posted information should be good enough. Only one question i need to know is, are the referenced products already existing in your target project when you try to sync? Regards.
Hello @salander85 Yes they are and also published.
Hi @dfrommi ,
i've tested your scenario and figured out the problems you are facing result from a misconfiguration of the ProductDraft
you want to sync.
Please have a look in the docs about the ProductSync. In the last row you can see, that attributes of type SetType
with elementType
is ReferenceType
are required to have the KEY
set in the id-field. Otherwise the sync considers the referenced product as existing and skips reference resolution by key.
If your source-project is another commercetools project you can consider to use ProductTransformUtils to avoid this problem. Please let me know when you are already using the transform-utils and still facing the issue.
I hope this answer will help to fix your problem. Let me know when you need further support.
Thanks you so much for your quick help! On a first quick test, it updates something. Have to look closer into it, but looks promising as of now.
And yes, the ProductTransformUtils-method did the trick. We were using ProductReferenceResolutionUtils.mapToProductDrafts
from the SDK instead, which is not resolving keys.
I've done more tests and the problem is resolved. Thank you very much, @salander85
To create the ProductDraft
, use com.commercetools.sync.products.utils.ProductTransformUtils#toProductDrafts
.
(Don't use ProductReferenceResolutionUtils.mapToProductDrafts from the CT SDK)
Describe the bug Products referencing other products are not synced. They are skipped due to unknown references.
To Reproduce Steps to reproduce the behavior:
ProductSync.sync()
for a product that references other productsExpected behavior References to other products should be resolved and the changes synchronised. A matching by product-key is expected. (The bug is not about changes in referenced products. The input-product is not synchronised.)
Additional context Analysis-result so far:
ProductBatchValidator.getReferencedKeysWithReferenceTypeId()
.id
of the products are returned, instead of thekey
BaseService.cacheKeysToIdsUsingGraphQl()
filters for keys on the target-project, so it doesn't find the referenced products and thus they are not available in cachemissingReferencedProductKeys
to be non-empty inProductSync.syncOrKeepTrack()
which prevents the syncWhat in my opinion needs to be done: