Home >php教程 >php手册 >Magento给产品添加“new”或者折扣数量标签 magento new label. discount label

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 10:57:541354browse

文章最底部有效果图。

给新产品添加“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的位置自己调整适合自己网站的。

  

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn