[Magento] check if prodcut is new

here is the code :) (à mettre dans un helper de module)

public function isProductNew($product) {
        $today = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        $new_from = $product->getData('news_from_date');
        $new_to   = $product->getData('news_to_date');

        return ($new_from && $new_from <= $today && (!$new_to || $new_to >= $today));
}

Exemple d'appel dans le template :

if($this->helper('MONMODULE')->isProductNew($_product)):
    echo 'Nouveauté';
endif;

categorie: