Badge icons

Hi,
template contains the badge icons and badge css classes. Is there a trick to display them

2 answers

Profile photo of Jindra Hejlí­k 0.00 $tone April 13, 2011
Public

Sorry for the late response…
I thought the displaying badge icons in the catalog view (see att.pic). I did not find any div class=badge in the app/design natris folder, so I tried the following steps and it works well…

1) Add this code to the end this file: app/code/core/Mage/Catalog/Model/Product.php

PHP Code:

    public function isNew($date=null)

    {

        if(
$date==null) {

        
$date $this->getResource()->formatDate(time());

        }

        

        if(!
$this->getData('news_from_date')) {

        return 
false;

        }

        

        
$current_date = new DateTime($date); // compare date

        
$from_date = new DateTime($this->getData('news_from_date')); // begin date

        
$to_date = new DateTime($this->getData('news_to_date')); // end date

        

        
$return = ($current_date >= $from_date && $current_date <= $to_date);

        

        return 
$return;

    } 

        public function 
isSpecial($date=null)

    {

        if(
$date==null) {

        
$date $this->getResource()->formatDate(time());

        }

        

        if(!
$this->getData('special_from_date')) {

        return 
false;

        }

        

        
$current_date = new DateTime($date); // compare date

        
$from_date = new DateTime($this->getData('special_from_date')); // begin date

        
$to_date = new DateTime($this->getData('special_to_date')); // end date

        

        
$return = ($current_date >= $from_date && $current_date <= $to_date);

        

        return 
$return;

    } 




2) Open file app/design/frontend/default/jm_natris/template/catalog/product/list.phtml and replace code:

a) old code for view image in list mode:

HTML Code:

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135,102); ?>" width="135" height="102" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>

new code:

HTML Code:

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image">
	<?php if ($_product->isNew() == true): ?><div class="badge-new"><div class="badge"></div></div><?php endif; ?>
	<?php if ($_product->isSpecial() == true): ?><div class="badge-hot"><div class="badge"></div></div><?php endif; ?>
	<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135,102); ?>" width="135" height="102" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>

b) old code for view image in grid mode:

HTML Code:

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135,102); ?>" width="135" height="102" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" /></a>

new code:

HTML Code:

<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" class="product-image">
	<?php if ($_product->isNew() == true): ?><div class="badge-new"><div class="badge"></div></div><?php endif; ?>
	<?php if ($_product->isSpecial() == true): ?><div class="badge-hot"><div class="badge"></div></div><?php endif; ?>
	<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135,102); ?>" width="135" height="102" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
</a>

You can display icons in the view product this way, for example in the product name.
Perhaps this will be useful to someone.

Jindra Hejlik

#2

This question is now closed

Written By

Comments