如何在magento中获得可配置的产品价格范围?

Jal*_*tel 8 php magento magento-1.7

我需要配置产品价格范围

下图是我的要求

对于产品名称:$ 140 - 310我使用下面的代码

if(Mage::getSingleton('customer/session')->isLoggedIn())
{
        // Get group Id
        $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
}
else
{
        $groupId = 0;
}     
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $db->query('SELECT price ,final_price, min_price, max_price, tier_price, group_price FROM catalog_product_index_price WHERE entity_id='.$_product->getId().' AND customer_group_id ='.$groupId.' ORDER BY customer_group_id ASC LIMIT 1');
$rows = $result->fetch();
Run Code Online (Sandbox Code Playgroud)

我还需要配置产品的常规价格范围.我也认为我的产品名称之后的范围是错误的,因为我Your Price have a price $135怎样才能获得最低价格和最高特价以及正常价格?

我怎么能得到它?

感谢致敬

小智 2

你可以使用这样的东西

$prices = array();
$associated = $_product->getTypeInstance(true)->getAssociatedProductCollection($_product)
->addAttributeToSelect('special_price');

foreach ($associated as $assoc) {
    $prices[] = $assoc->getSpecialPrice();
}
// calculate min max price here
if (count($prices)) {
    $min_price = min($prices);
    $max_price = max($prices);
} else {
    $min_price = 0;
    $max_price = 0;
}
Run Code Online (Sandbox Code Playgroud)

也许不是完美的解决方案,但它有效