请按照以下步骤更改超级属性价格
首次使用观察者“ catalog_product_get_final_price”。使观察者像这样:
打开您的模块config.xml并使用以下代码:
<events>
    <catalog_product_get_final_price>
        <observers>
            <Setblue_Banner_Model_Observer>
                <type>singleton</type>
                <class>Setblue_Banner_Model_Observer</class>
                <method>getFinalPrice</method>
            </Setblue_Banner_Model_Observer>
        </observers>
    </catalog_product_get_final_price>
</events>
现在在模型中以及下面的代码中制作Observer.php文件
<?php
class Setblue_Banner_Model_Observer
{
 public function getFinalPrice(Varien_Event_Observer $observer) {
  $event   = $observer->getEvent();
        $product = $event->getProduct();
        $qty     = $event->getQty();
  $selectedAttributes = array();
  if ($product->getCustomOption('attributes')) {
   Mage::log('yes-----', null, 'confPricing.log');
   $selectedAttributes = unserialize($product->getCustomOption('attributes')->getValue());
  }
  if (sizeof($selectedAttributes)) return $this->getSimpleProductPrice($qty, $product);
    }
 public function getSimpleProductPrice($qty=null, $product)
    {
  $cfgId = $product->getId();
        $product->getTypeInstance(true)
            ->setStoreFilter($product->getStore(), $product);
        $attributes = $product->getTypeInstance(true)
            ->getConfigurableAttributes($product);
        $selectedAttributes = array();
        if ($product->getCustomOption('attributes')) {
            $selectedAttributes = unserialize($product->getCustomOption('attributes')->getValue());
        }
        $db = Mage::getSingleton('core/resource')->getConnection('core_read');
        $dbMeta = Mage::getSingleton('core/resource');
        $sql = <<<SQL
SELECT main_table.entity_id FROM {$dbMeta->getTableName('catalog/product')} `main_table` INNER JOIN
{$dbMeta->getTableName('catalog/product_super_link')} `sl` ON sl.parent_id = {$cfgId}
SQL;
        foreach($selectedAttributes as $attributeId => $optionId) {
            $alias = "a{$attributeId}";
            $sql .= ' INNER JOIN ' . $dbMeta->getTableName('catalog/product') . "_int" . " $alias ON $alias.entity_id = main_table.entity_id AND $alias.attribute_id = $attributeId AND $alias.value = $optionId AND $alias.entity_id = sl.product_id";
        }
        $id = $db->fetchOne($sql);
        //Mage::log(Mage::getModel("catalog/product")->load($id)->getFinalPrice($qty), null, 'confPricing.log');
        //return
        $fp = Mage::getModel("catalog/product")->load($id)->getFinalPrice($qty);
        return $product->setFinalPrice($fp);
 }
}
?>
现在打开app / design / frontend / default / yourtheme / template / catalog / product / view / type / options / configurable.phtml并将以下代码粘贴到文件中的任何位置
<ul class="productIds" style="display:none;">
    <?php
        $configurableProduct = Mage::getModel('catalog/product')->load($_product->getId());
        $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$configurableProduct);
        foreach($childProducts as $child) {
            $_productObj = Mage::getModel('catalog/product')->load($child->getId());
            ?>
            <li id='simple_<?php echo $child->getId(); ?>'><?php echo Mage::helper('core')->currency($_productObj->getFinalPrice()); ?></li>
        <?php   
        }
    ?>
</ul>
现在打开js / varien / configurable.js并按如下所示更改reloadPrice函数,或者也可以替换整个函数
reloadPrice: function(){
    if (this.config.disablePriceReload) {
        return;
    }
    var price    = 0;
    var oldPrice = 0;
    for(var i=this.settings.length-1;i>=0;i--){
        var selected = this.settings[i].options[this.settings[i].selectedIndex];
        if(selected.config){
            price    += parseFloat(selected.config.price);
            oldPrice += parseFloat(selected.config.oldPrice);
        }
    }
    /* Edit Code By Chandresh Rana*/
     //optionsPrice.changePrice('config', {'price': price, 'oldPrice': oldPrice});
     optionsPrice.reload();
     var existingProducts = new Object();
     for(var i=this.settings.length-1;i>=0;i--)
     {
         var selected = this.settings[i].options[this.settings[i].selectedIndex];
         if(selected.config)
         {
            for(var iproducts=0;iproducts<selected.config.products.length;iproducts++)
            {
                var usedAsKey = selected.config.products[iproducts]+"";
                if(existingProducts[usedAsKey]==undefined)
                {
                    existingProducts[usedAsKey]=1;
                }
                else
                {
                    existingProducts[usedAsKey]=existingProducts[usedAsKey]+1;
                }
             }
         }
     }
     for (var keyValue in existingProducts)
     {
        for ( var keyValueInner in existingProducts)
         {
            if(Number(existingProducts[keyValueInner])<Number(existingProducts[keyValue]))
            {
                delete existingProducts[keyValueInner];
            }
         }
     }
     var sizeOfExistingProducts=0;
     var currentSimpleProductId = "";
     for ( var keyValue in existingProducts)
     {
        currentSimpleProductId = keyValue;
        sizeOfExistingProducts=sizeOfExistingProducts+1
     }
     if(sizeOfExistingProducts==1)
     {
        if($('product-price-'+this.config.productId)){
            $('product-price-'+this.config.productId).innerHTML = jQuery("#simple_"+currentSimpleProductId).html();
        }
     }
    // End Code By Chandresh Rana
    return price;
    if($('product-price-'+this.config.productId)){
        $('product-price-'+this.config.productId).innerHTML = price;
    }
    this.reloadOldPrice();
},
代码摘自:http : //chandreshrana.blogspot.in/2016/03/set-simple-product-price-instead-of.html