Magento – Label in Catalog view for Special Price (Magento 2)

magento2special-price

I want to put a label for Special Price in caltalog view. Therefore I tried some code from final_price.phtml like this:

<?php if ($block->hasSpecialPrice()): ?>
    test
<?php endif; ?>

I try to use it in my list.phtml here:

app/design/frontend/name/theme/Magento_Caltalog/templates/product/list.phtml

But it doesen't work that way here. How ist the the correct if statement to do that in list.phtml?

Best Answer

I replaced block with product, now it works that way:

<?php if (($_product->getSpecialPrice())): ?>test<?php endif; ?>
Related Topic