magento:特定制造商的旧价格的不同格式

时间:2015-10-22 20:15:44

标签: php magento magento-1.9

如果有特定制造商(即Apple),我希望有不同格式的旧价格。

我想我必须在/template/catalog/product/price.html上的 p class =“old-price”上添加类似的东西,但我很确定这是错的:

<?php $manufacturer = Mage::getModel('catalog/product');?>
<?php if ($manufacturer && in_array($manufacturer = $product->getAttributeText('manufacturer'), array('Apple')) : ?>

关于如何实现这一目标的任何想法?

2 个答案:

答案 0 :(得分:0)

假设manufacturer是产品属性,并且您在指定的路径中使用了默认的Magento模板之一,那么您应该已经在$_product中加载了产品型号,您可以通过像这样的魔术方法使用制造商:

$manufacturer = $_product->getManufacturer();

所以实现可能是这样的:

<?php $isOldPrice = (in_array($_product->getManufacturer(), array('Apple'))); ?>
<p<?php if ($isOldPrice) : ?> class="old-price"<?php endif; ?>>Your price here</p>

答案 1 :(得分:0)

正确的语法是:

<?php $manufacturer = $_product->getAttributeText('manufacturer');?>
<?php if ($manufacturer && in_array($_product->getAttributeText('manufacturer'), array('Apple'))) : ?>
相关问题