Skip to main content

Hello Everyone,

I want to sync Stock Item Attribute (combo/multi-select combo) Value Description instead of Attribute Value ID at the time of Stock Item Sync from Acumatica to BigCommerce as custom field name and value.

From Entity Mapping it is not possible, so I did a customization but observed that one attribute value, updating across all other custom field values.

Please find below sample code and screenshots for reference.

Sample Code:

public class KNBCStockItemProcessorExt : PXGraphExtension<BCStockItemProcessor>
    {
       
        public delegate object GetAttributeDelegate(BCStockItemEntityBucket bucket, string attributeID);
        bPXOverride]
        public object GetAttribute(BCStockItemEntityBucket bucket, string attributeID, GetAttributeDelegate baseMethod)
        {
            MappedStockItem obj = bucket.Product;
            StockItem impl = obj.Local;
            impl.Attributes?.Where(x => string.Equals(x?.AttributeDescription?.Value, attributeID, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            foreach (AttributeValue attr in impl.Attributes)
            {
                foreach (EntityValueField val in attr.Impl?.Fields)
                {
                    if (val.Name == "ValueDescription")
                    {
                        attr.Value.Value = val.Value;
                    }
                }
            }

            return impl.Attributes;
        }   
    }

Entity Mapping:

 

Stock Item:

 

Actual Result on BigCommerce:

 

Any suggestions/help will be very much appreciated. Thank you in advance! :)

Hi @vivekm you have a bug in your code.

The method should return one particular attribute, where you return the collection of attributes.

return impl.Attributes;


Thanks @smarenich, will modify as per your suggestion and verify.


Reply