做到了。就是这样。
1)将文件从复制基:
应用程序/设计/前端/碱/默认/模板/目录/产品/ list.phtml 应用程序/设计/前端/碱/默认/模板/目录/product/view.phtml
到您的自定义设计包。
应用程序/设计/前端/ mydesignpackage /default/template/catalog/product/list.phtml 应用程序/设计/前端/ mydesignpackage /default/template/catalog/product/view.phtml
在的列表中。PHTML找到线(约行86)
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
紧接着,插入下面的代码:
<?php
//get all categories associated with this product
$categories = $_product->getCategoryIds();
$clearance_category = 134; //clearance category id
if(in_array($clearance_category, $categories)) {
$clearancetag='<div class="clearance-tag">Clearance</div>';
}
else {
$clearancetag='';
}
?>
再往下找了很长的线:
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
,并插入您刚刚关闭之前的变量</a>
标记:
null, true) ?>" /><?php echo $clearancetag ?></a>
照顾产品网格。
Next显示产品视图中的清除图标。我只是在说明旁边显示它。
在view.phtml 找到行:
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
并立即粘贴代码之后:
<?php
//get all categories associated with this product
$categories = $_product->getCategoryIds();
$clearance_category = 134; //clearance category id
if(in_array($clearance_category, $categories)) {
echo '<div class="clearance-tag">CLEARANCE</div>';
}
?>
我敢肯定有这样做的,硬编码的更优雅的方式您的类别ID并不理想。但它为我工作,并希望它可以帮助其他人。
谢谢,但我仍然不确定如何将DIV元素添加到每个单独产品的标记中。 情景是:用户正在浏览“家具”类别。某些产品旁边会出现一个图标,表示它们也出现在“清除”类别中。 实际上,我将“清除”项目分配给一个称为“清除”的类别,并且需要找到突出显示这些项目的方式,而不管您处于哪个类别页面。 你所描述的内容对于了解它还是有用的,它会帮助我完成各种其他事情,所以谢谢。 – elMarquis
我明白你的意思了。我将不得不再想一想。 – clockworkgeek