私はmagento 1.7を使用しています。製品の詳細価格には、カスタムオプションと構成可能な製品オプションがあります。
私がやりたいことは、「18.50 - 55.90」のように製品ページのどこかに表示する必要があるよりも、最低合計価格オプションが 18.50 で最高合計価格オプションが 55.90 の場合のように、範囲内のすべてのオプションの価格を表示することです。 .
前もって感謝します。
私はmagento 1.7を使用しています。製品の詳細価格には、カスタムオプションと構成可能な製品オプションがあります。
私がやりたいことは、「18.50 - 55.90」のように製品ページのどこかに表示する必要があるよりも、最低合計価格オプションが 18.50 で最高合計価格オプションが 55.90 の場合のように、範囲内のすべてのオプションの価格を表示することです。 .
前もって感謝します。
以下のコードを試してください
//load configurable product
$product = Mage::getModel('catalog/product')->load(some_id);
//load all children
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$product);
foreach($childProducts as $child){
$_child = Mage::getModel('catalog/product')->load($child->getId());
$childPrice = $_child->getPrice();
//compare the $childPrice
}
またはインラインクエリの場合は次のようになります
<?php
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $db->query('SELECT a.product_id, a.product_super_attribute_id, ap.product_super_attribute_id, ap.pricing_value FROM catalog_product_super_attribute AS a INNER JOIN catalog_product_super_attribute_pricing AS ap ON a.product_super_attribute_id=ap.product_super_attribute_id WHERE a.product_id='.$_product->getId().' ORDER BY ap.pricing_value DESC LIMIT 1');
$rows = $result->fetch();
echo 'From '.Mage::helper('core')->currency($_product->getPrice()).' to '.Mage::helper('core')->currency($rows ['pricing_value']+$_product->getPrice());
?>
編集 (オプション)
$prices = array();
$associated = $_product->getTypeInstance(true)->getAssociatedProductCollection($_product)
->addAttributeToSelect('special_pric$
foreach ($associated as $assoc) {
$prices[] = $assoc->getSpecialPrice();
}
if (count($prices)) {
$min_price = min($prices);
$max_price = max($prices);
} else {
$min_price = 0;
$max_price = 0;
}