Skip to main content
Answer

BigCommerce: To Sync Attribute Value Description Instead of Attribute Value ID

  • June 4, 2021
  • 2 replies
  • 243 views

vivekm
Varsity II
Forum|alt.badge.img

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);
        [PXOverride]
        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! :)

Best answer by smarenich

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;

2 replies

smarenich
Acumatica Moderator
Forum|alt.badge.img+3
  • Acumatica Commerce Edition Team Lead
  • Answer
  • June 4, 2021

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;


vivekm
Varsity II
Forum|alt.badge.img
  • Author
  • Varsity II
  • June 7, 2021

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