Skip to main content
Solved

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


vivekm
Varsity I
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;

View original
Did this topic help you find an answer to your question?

2 replies

smarenich
Acumatica Moderator
Forum|alt.badge.img+3
  • Acumatica Commerce Edition Team Lead
  • 227 replies
  • 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 I
Forum|alt.badge.img
  • Author
  • Varsity I
  • 78 replies
  • June 7, 2021

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings