I am not able to display SALE labels on configurable products.

I am able to display NEW when I set a product as new for a certain period of time, however when I have a special price on a product I am not able to display the SALE label.

I am using Magento 2.3.2. Is there anything I can do? I saw that there is this issue already reported here Magento 2 configurable products issue but as I understood I should not be able to set a product as NEW as well.

Hopefully, someone can assist with this further.



Create a <div> with your SALE label on the product list page where you want to display the SALE label. For e.g.

<div class="sale_label" style="display: none;">//your sale label</div>

Now on the same file check if the current product is configurable product than check if its child products have a special price or not.

$configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);

$_children = $configProduct->getTypeInstance()->getUsedProducts($configProduct);
$salePrice = array();
foreach ($_children as $child){
    $salePrice[] = $child->getSpecialPrice();
if($salePrice != ''){ ?>
require(['jquery', 'jquery/ui'], function($){
   jQuery(document).ready( function() {
<?php } ?>

You can use it without Object Manager.

| improve this answer | |
  • This has probably a huge performance impact, if you load each product in the loop. – Alex Sep 10 at 8:09

Our solution for a customer was, to create a new attribute is_on_sale which is updated each time a configurable or it's simples are changed.

Then we simply use that attribute to display a sale label and also can filter by this attribute.

Not a super sophisticated solution, but it works.

Other solutions have the problem that you either need to load all simples in the product-list-loop which has a big performance impact or mess around with the indexers.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.