我需要在特定类别中所有产品的价格附近显示一个文本。
我发现这段代码可以工作,但它只适用于一个特定的类别。我需要把119、120、121、122等等…更多的类别id,而不是只有一个。
你能帮我吗?
<?php $category = Mage::getModel('catalog/layer')->getCurrentCategory();?>
<?php if($category->getId()==119): ?>
<span class="price-specification">
<?php echo $this->__('Price per meter.'); ?><br />
<?php echo $this->__('Sold only in multiples of three.'); ?>
</span>
<?php endif; ?>
要在1个以上的特定类别中显示文本,只需执行以下操作:
- 创建一个包含要在其中显示此文本的所有类别id的数组。例如:$arr = array(19, 120, 121, 122);
-
现在取代
if($分类-> getId () = = 119):
输入以下代码:
if(in_array($category->getId(),$arr)):