我需要在<head>部分中设置打开的图形价格分组产品。

我可以以这种方式获得简单产品的价格:

<meta property="og:price:amount" content="<?php echo $_product->getPriceHtml($_item, true) ?>">
.

它很好。但是...... 如何获得分组产品的价格(与最低价格相关的产品价格)?

有帮助吗?

解决方案

我解决了以这种方式获得了相关的上一份产品的价格(我的产品的价格对于每个产品都是相同的,所以我需要检查最低):

<meta property="og:price:amount" content="<?php 

$product = Mage::getModel('catalog/product');
$product->load(Mage::registry('current_product')->getId());
$grouped_product_model = Mage::getModel('catalog/product_type_grouped');
$groupedParentId = $grouped_product_model->getParentIdsByChild($product->getId());
$_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);

foreach($_associatedProducts as $_associatedProduct) {
    if($ogPrice = $_associatedProduct->getPrice()) {
        $ogPrice = $_associatedProduct->getPrice();
    }
}

$ogPrice = number_format((float)$ogPrice, 2, '.', '');
echo $ogPrice . " Euro";

?>" />
.

许可以下: CC-BY-SA归因
scroll top