Solved

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

  • 4 June 2021
  • 2 replies
  • 207 views

Userlevel 4
Badge

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! :)

icon

Best answer by smarenich 4 June 2021, 19:20

View original

2 replies

Userlevel 7
Badge +3

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;

Userlevel 4
Badge

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

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved