Php magento:特定制造商的旧价格的不同格式
如果有特定的制造商(如苹果),我希望有不同的产品旧价格格式 我想我必须在/template/catalog/product/price.html上添加类似的内容,但我敢肯定这是错误的:Php magento:特定制造商的旧价格的不同格式,php,magento,magento-1.9,Php,Magento,Magento 1.9,如果有特定的制造商(如苹果),我希望有不同的产品旧价格格式 我想我必须在/template/catalog/product/price.html上添加类似的内容,但我敢肯定这是错误的: <?php $manufacturer = Mage::getModel('catalog/product');?> <?php if ($manufacturer && in_array($manufacturer = $product->getAttributeText
<?php $manufacturer = Mage::getModel('catalog/product');?>
<?php if ($manufacturer && in_array($manufacturer = $product->getAttributeText('manufacturer'), array('Apple')) : ?>
假设manufacturer
是一个产品属性,并且您正在指定的路径中使用一个默认的Magento模板,那么您应该已经在$\u 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>
>你的价格在这里
正确的语法是:
<?php $manufacturer = $_product->getAttributeText('manufacturer');?>
<?php if ($manufacturer && in_array($_product->getAttributeText('manufacturer'), array('Apple'))) : ?>
非常感谢您的友好回复,这对我帮助很大!