Is there an easy way to show discounts on Category/Manufacturer pages?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 12 años
We have applied a 50% discount to a certain category of products.  When you click on that category, it shows the "From [full price]" instead of "From [50% off discounted price]".  

Is there a way to do that?  

Also in another thread I have modified the SP to make the products sorted by price, but they are still sorted by "position", as opposed to price (@OrderBy = 10).
Hace 12 años
Why do some questions get ignored and others have many replies?
Hace 12 años
Do you have multiple variants for a product?
Hace 12 años
skhan wrote:
Do you have multiple variants for a product?


Yes, I do.  It shows the full price "From $xx.xx" instead of the discounted price.
Hace 12 años
If anyone can point me in the right direction I would be appreciative.
Hace 12 años
OK well here is the hack.  I don't know if it is the best approach but it works so far.

In the CatalogController.cs, I created this method.

        private decimal GetDiscountedProductPrice(ProductVariant productVariant)
        {
            decimal taxRate = decimal.Zero;
            decimal oldPriceBase = _taxService.GetProductPrice(productVariant, productVariant.OldPrice, out taxRate);
            decimal finalPriceWithoutDiscountBase = _taxService.GetProductPrice(productVariant, _priceCalculationService.GetFinalPrice(productVariant, false), out taxRate);
            decimal finalPriceWithDiscountBase = _taxService.GetProductPrice(productVariant, _priceCalculationService.GetFinalPrice(productVariant, true), out taxRate);

            decimal oldPrice = _currencyService.ConvertFromPrimaryStoreCurrency(oldPriceBase, _workContext.WorkingCurrency);
            decimal finalPriceWithoutDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(finalPriceWithoutDiscountBase, _workContext.WorkingCurrency);
            decimal finalPriceWithDiscount = _currencyService.ConvertFromPrimaryStoreCurrency(finalPriceWithDiscountBase, _workContext.WorkingCurrency);

            return finalPriceWithDiscount;
        }


I then set the single variants with

decimal finalPrice = GetDiscountedProductPrice(productVariant);
//_currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, _workContext.WorkingCurrency);

and the multiple variants with

                                        decimal fromPrice = GetDiscountedProductPrice(productVariant); //_currencyService.ConvertFromPrimaryStoreCurrency(fromPriceBase, _workContext.WorkingCurrency);

Let me know if you think there is a cleaner way.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.