@Adcirruserp
The standard entity mapping approach mentioned above is worth trying first. However, if you want to handle this through customization, you can extend SPTemplateItemProcessor.
- Override
MapBucketExport and execute the standard export first. - Access the Shopify variants through
bucket.Product?.Extern?.Variants. - Match the Shopify variant with the corresponding Acumatica matrix/child stock item using the SKU.
- Read the child item's attribute value from
AttributesValues. - Update the corresponding
variant.VariantMetafields. - Since the Shopify metafield is a list type, serialize the value as a JSON array.
public delegate Task MapBucketExportDelegate(SPTemplateItemEntityBucket bucket, IMappedEntity existing, CancellationToken cancellationToken);
[PXOverride]
public async Task MapBucketExport(SPTemplateItemEntityBucket bucket, IMappedEntity existing, CancellationToken cancellationToken, MapBucketExportDelegate baseMethod)
{
await baseMethod(bucket, existing, cancellationToken);
ProductDataGQL external = bucket.Product?.Extern;
if (external?.Variants == null)
return;
foreach (ProductVariantGQL variant in external.Variants)
{
// Match Shopify variant with Acumatica matrix item using SKU.
// Read the corresponding child item attribute from AttributesValues.
// Update the Shopify variant metafield.
string value = JsonConvert.SerializeObject(new[] { attributeValue });
MetafieldGQL metafield = variant.VariantMetafields?.FirstOrDefault(x =>
x.Namespace == "custom" &&
x.Key == "varaint_level_color");
if (metafield != null)
metafield.Value = value;
}
}
Hope this helps!