setIsNew example



    /** * {@inheritdoc} */
    public function getProductAttribute(ListProduct $product)
    {
        $attribute = new MarketingAttribute();

        $today = new DateTime();

        $attribute->setIsNew(false);

        if ($product->getCreatedAt() instanceof DateTimeInterface) {
            $diff = $today->diff($product->getCreatedAt());
            $marker = (int) $this->config->get('markAsNew');

            $attribute->setIsNew(
                $diff->days <= $marker || $product->getCreatedAt() > $today
            );
        }

        $attribute->setComingSoon(
            
Home | Imprint | This part of the site doesn't use cookies.