GetProductAttributeValuePriceAdjustment issue

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
In the following function, shouldn't we be using the Customer parameter instead of _workContext.CurrentCustomer in the associated to product condition?


public virtual decimal GetProductAttributeValuePriceAdjustment(Product product, ProductAttributeValue value, Customer customer, decimal? productPrice = null)
        {
            if (value == null)
                throw new ArgumentNullException(nameof(value));

            var adjustment = decimal.Zero;
            switch (value.AttributeValueType)
            {
                case AttributeValueType.Simple:
                    //simple attribute
                    if (value.PriceAdjustmentUsePercentage)
                    {
                        if (!productPrice.HasValue)
                            productPrice = GetFinalPrice(product, customer);

                        adjustment = (decimal)((float)productPrice * (float)value.PriceAdjustment / 100f);
                    }
                    else
                    {
                        adjustment = value.PriceAdjustment;
                    }

                    break;
                case AttributeValueType.AssociatedToProduct:
                    //bundled product
                    var associatedProduct = _productService.GetProductById(value.AssociatedProductId);
                    if (associatedProduct != null)
                    {
                        adjustment = GetFinalPrice(associatedProduct, _workContext.CurrentCustomer) * value.Quantity;
                    }

                    break;
                default:
                    break;
            }

            return adjustment;
        }



Thanks!
3 years ago
I would agree...  It looks like a 'typo' considering that the parameter is used several lines above in GetFinalPrice(product, customer).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.