2011-11-24 63 views
7

我们有产品的混合物,其中一些使用specialPrice,一些使用Catalog Rules Sets。Magento:获得优惠价格

我需要在我的前台显示我所有产品的折扣百分比。

我们使用$ _product-> getSpecialPrice()来获得折扣价格,但是对于基于目录规则的价格的产品而言,这是失败的。

是否有可能根据目录规则或specialPrice获得折扣价格?

+1

尝试$ _product-> getFinalPrice() –

回答

10

试试这个片段: 这一个会计算价格规则。

Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice()); 

是你在找什么?

+0

是否有拉这个数据更快的方法?当然产品页面不会像这样拉动价格? –

+1

目前我认为有1种方法。特别是在产品收集形成的阶段。所以,如果你需要这样的自定义行为,我会建议你写一个自定义模块的自定义资源模块,实现与规则表和应用规则的连接。 –

12

是的,你可以使用$_product->getFinalPrice()

下面是三个价格的区别:

$regularPrice = number_format($_product->getPrice(), 2);

$discountedPrice = number_format($_product->getFinalPrice(), 2);

$specialPrice = number_format($_product->getSpecialPrice(), 2);

+0

谢谢! – asherrard