Hello Everyone,
I am working with Build 2025R2 Version 25.200.0248 Shopify Connector.
I have customized Stock Item sync processor and overridden SaveBucketExport() method (copy pasted base code only) but during product sync, getting error as: Missing type map configuration or unsupported mapping.Mapping types:ProductDataGQL -> ProductSetInputPX.Commerce.Shopify.API.GraphQL.ProductDataGQL -> PX.Commerce.Shopify.API.GraphQL.ProductSetInput.
Sharing sample code below, can you please review and suggest possible root cause and fix.
public class TestStockItemSync : PXGraphExtension<SPStockItemProcessor>
{
public static bool IsActive() { return true; }
#region Mapper
private IMapper mapper;
protected IMapper Mapper => mapper ?? (mapper = CreateMapper());
protected virtual bool UseAutoMapper => true;
private IMapper CreateMapper()
{
if (!UseAutoMapper)
{
throw new ApplicationException("The processor " + GetType().FullName + " must override UseAutoMapper property.");
}
return new MapperConfiguration(AddConfigurations).CreateMapper();
}
private void AddConfigurations(IMapperConfigurationExpression config)
{
AddAutoMapperMappings(config);
AddAutoMapperExtraMappings(config);
}
protected virtual void AddAutoMapperMappings(IMapperConfigurationExpression config) { }
protected virtual void AddAutoMapperExtraMappings(IMapperConfigurationExpression config) { }
#endregion
protected IProductGQLDataProvider ProductGQLDataProvider { get; set; }
[InjectDependency]
protected ISPGraphQLAPIClientFactory ShopifyGraphQLClientFactory { get; set; }
[InjectDependency]
protected ISPGraphQLDataProviderFactory<IProductGQLDataProvider> ProductGraphQLDataProviderFactory { get; set; }
public delegate Task InitialiseDelegate(IConnector iconnector, ConnectorOperation operation, CancellationToken cancellationToken);
[PXOverride]
public async Task Initialise(IConnector iconnector, ConnectorOperation operation, CancellationToken cancellationToken, InitialiseDelegate BaseMethod)
{
await BaseMethod(iconnector, operation, cancellationToken);
var graphQLClient = ShopifyGraphQLClientFactory.GetClient(Base.GetBindingExt<BCBindingShopify>());
ProductGQLDataProvider = ProductGraphQLDataProviderFactory.GetProvider(graphQLClient, Mapper);
}
public delegate Task SaveBucketExportDelegate(SPStockItemEntityBucket bucket, IMappedEntity existing, String operation, CancellationToken cancellationToken);
[PXOverride]
public async Task SaveBucketExport(SPStockItemEntityBucket bucket, IMappedEntity existing, String operation, CancellationToken cancellationToken, SaveBucketExportDelegate BaseMethod)
{
MappedStockItem obj = bucket.Product;
ProductDataGQL product = null;
if (obj.Extern.Categories?.Count > 0 && Base.GetBindingExt<BCBindingShopify>()?.CombineCategoriesToTags == BCSalesCategoriesExportAttribute.SyncToProductTags)
{
obj.Extern.Tags = Enumerable.Concat(obj.Extern.Categories, obj.Extern.Tags ?? []);
}
try
{
product = await ProductGQLDataProvider.ProductSetAsync(obj.Extern, cancellationToken);
if (obj.ExternID is null)
{
obj.Extern.Id = product.Id;
obj.Extern.Variants.First().Id = product.Variants.First().Id;
}
else
{
var externallyStoredVariantSKUs = obj.Extern.Variants.Select(variant => variant.Sku).ToHashSet();
var notExistedVariantIds = bucket.VariantMappings.Where(x => !externallyStoredVariantSKUs.Contains(x.Key)).Select(x => x.Value).ToList();
if (notExistedVariantIds.Count > 0)
await ProductGQLDataProvider.DeleteProductVariantsBulkAsync(obj.ExternID, notExistedVariantIds, cancellationToken);
}
ProductDataGQL updatedProduct = await ProductGQLDataProvider.UpdateProductVariantsBulkAsync(obj.Extern, cancellationToken);
product = updatedProduct ?? product;
//await PublishUnpublishProduct(obj.Extern, cancellationToken);
}
catch (Exception ex)
{
throw new PXException(ex.Message);
}
DateTime productTimestamp = product.UpdatedAt ?? DateTime.Now;
obj.AddVariantToDetails();
obj.AddExtern(product, product.GetNumericId(), product.Title, productTimestamp.ToDate(false));
await Base.SaveImages(product, obj, obj.Local?.FileURLs, cancellationToken);
Base.UpdateStatus(obj, operation);
}
}
