简体   繁体   English

Magento,如何从分组产品中获取价格数组?

[英]Magento, how to get price array from grouped products?

I am looking to retrieve an array with all of the final_prices for a grouped product.我正在寻找一个包含所有 final_prices 分组产品的数组。

The goal is to be able to use this information in product/view.phtml and display a price range that reads From: $25.00 - $899.00目标是能够在 product/view.phtml 中使用此信息并显示价格范围为:$25.00 - $899.00

I have been able to get the array somewhat working in price.phtml using:我已经能够让数组在 price.phtml 中使用:

$prices = array ($_taxHelper->getPrice($_product, $_product->getFinalPrice()));
print_r ($prices);

This will give me the array, but in the price fields of each grouped item.这将为我提供数组,但在每个分组项目的价格字段中。 I need to be able to get the data and then I am thinking to use php's min & max functions to get the values with ease and display the data as shown above.我需要能够获取数据,然后我正在考虑使用 php 的 min & max 函数轻松获取值并显示如上所示的数据。

This data needs to be able to be used in the view.phtml file so this creates a bit more trouble.该数据需要能够在 view.phtml 文件中使用,因此会产生更多麻烦。 I have tried using price in view.phtml but it seems the function becomes quite unhappy outside of the price loop.我曾尝试在 view.phtml 中使用价格,但似乎 function 在价格循环之外变得非常不满意。

Any help would be greatly appreciated!任何帮助将不胜感激!

Cheers!干杯!

Sorry the timing, but you could just do the following:对不起时间,但您可以执行以下操作:

Mage::getModel('catalog/product')->setStoreId($theStoreId)->load($theid)->getData('group_price');

When you do so, you will get the array with all the settings for the group.当您这样做时,您将获得包含该组所有设置的阵列。 If you are in the customer cart phtml, is even easier:如果您在客户购物车 phtml 中,则更容易:

$this->getProduct()->getData('group_price')

You could try this in view.phtml file:你可以在 view.phtml 文件中试试这个:

$prices = array (Mage::helper('tax')->getPrice($_product, $_product->getFinalPrice()));
print_r ($prices);

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM