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!