The following function works only for simple products (when they have an special price, a sale label is attached to the product image):
public function getLabels($product) {
$labels = [];
if ($product->getSpecialPrice()) {
$labels['sale'] = 'Sale';
}
return $labels;
}
Now I am wondering how to combine a check that works for simple products and for configurable products (thus also in the case that all child products of a configurable product have an special price).
Best Answer
try this code block on listing page ( works for me ) , in my case all child products have same price and special price is applied, you can use logic something like this: