Heim  >  Artikel  >  Backend-Entwicklung  >  Magento给产品添加“new”或者折扣数量标签 magento new label. discount label_PHP教程

Magento给产品添加“new”或者折扣数量标签 magento new label. discount label_PHP教程

WBOY
WBOYOriginal
2016-07-14 10:11:57912Durchsuche

文章最底部有效果图。

给新产品添加“new”的标签。给折扣产品,显示出折扣的数量。

这个可以自己写一段代码加在到模板文件夹下面的catalog/product/list.phtml中。 以下是代码

timestamp(time()); ?>



                                $new_str_tm = strtotime($_product->getNews_from_date());
                $new_end_tm = strtotime($_product->getNews_to_date());
                ?>
               


                   
                   
                   
               

                0): ?>
                $new_str_tm) && (!$new_end_tm) ) ): ?>
                   
NEW

               
               
               
                                    $spe_end_tm = strtotime($_product->getSpecial_to_date());
                    $spe_str_tm = strtotime($_product->getSpecial_from_date());
                    $spe_pri = $_product->getSpecial_price();
                ?>
                getResource()->getAttribute('price')->getFrontend()->getValue($_product) ?>
                $spe_str_tm) && (!$spe_end_tm) ) ): ?>
                   
                   
                   
%

                   
               
               


上面的这段代码插入到相应的位置。。最好是放在    这个后面

这个弄好后。还要改CSS。让其显示在相应的位置。

.products-grid .ico_new_bg { height:33px; font-size:14px; line-height:24px; color:#ffffff; background:url("../images/ico_bg.png"); position:absolute; margin: -10px -10px 0; padding:0 10px 0; z-index:10; }
.products-grid .ico_percent_bg { height:33px; font-size:14px; line-height:24px; color:#ffffff; background:url("../images/ico_bg.png"); position:absolute; margin: -10px -10px 0; padding:0 10px 0; z-index:10; }


这段CSS代码添加到styles.css下面。添加到/* View Type: Grid */ 这个下面。.products-grid li.item,在这一行后面添加上两行代码。

margin的位置自己调整适合自己网站的。

  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477287.htmlTechArticle文章最底部有效果图。 给新产品添加new的标签。给折扣产品,显示出折扣的数量。 这个可以自己写一段代码加在到模板文件夹下面的cata...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn