1.9.2.2 instead of 19.2.2, fix comment with --- and remove unecessary space in xml tag
Source Link

Using Magento Version 191.9.2.2

<?xml version="1.0"?>
<config> 
 <modules>
        < YourFolderinLOCAL_YourModulename><YourFolderinLOCAL_YourModulename>
            <version>0.0.1</version>
        </ YourFolderinLOCAL_YourModulename>
    </modules>
    <global>
        <models>
            < YourFolderinLOCALYourModulename> <<YourFolderinLOCALYourModulename><!--- Al lovwercase in my case- -- >
                <class>Your_Model</class> <class><!-- not needed in my case -->
            </ YourFolderinLOCALYourModulename>
        </models>
        
    </global>
    <frontend>
    <events>
            <catalog_product_get_final_price>
                <observers>
                    < YourFolderinLOCAL_YourModulename_model_observer><YourFolderinLOCAL_YourModulename_model_observer>
                        <type>singleton</type>
                        <class> YourFolderinLOCAL_YourModulename_Model_Observer</class>
                        <method>simpleProductPrice</method>
                    </ YourFolderinLOCAL_YourModulenameg_model_observer>
                </observers>
            </catalog_product_get_final_price>
            
        </events>
        </frontend>
</config>

Using Magento Version 19.2.2

<?xml version="1.0"?>
<config> 
 <modules>
        < YourFolderinLOCAL_YourModulename>
            <version>0.0.1</version>
        </ YourFolderinLOCAL_YourModulename>
    </modules>
    <global>
        <models>
            < YourFolderinLOCALYourModulename> <!--- Al lovwercase in my case--- >
                <class>Your_Model</class> <!-- not needed in my case -->
            </ YourFolderinLOCALYourModulename>
        </models>
        
    </global>
    <frontend>
    <events>
            <catalog_product_get_final_price>
                <observers>
                    < YourFolderinLOCAL_YourModulename_model_observer>
                        <type>singleton</type>
                        <class> YourFolderinLOCAL_YourModulename_Model_Observer</class>
                        <method>simpleProductPrice</method>
                    </ YourFolderinLOCAL_YourModulenameg_model_observer>
                </observers>
            </catalog_product_get_final_price>
            
        </events>
        </frontend>
</config>

Using Magento Version 1.9.2.2

<?xml version="1.0"?>
<config> 
 <modules>
        <YourFolderinLOCAL_YourModulename>
            <version>0.0.1</version>
        </YourFolderinLOCAL_YourModulename>
    </modules>
    <global>
        <models>
            <YourFolderinLOCALYourModulename><!-- Al lovwercase in my case -->
                <class>Your_Model</class><!-- not needed in my case -->
            </YourFolderinLOCALYourModulename>
        </models>
        
    </global>
    <frontend>
    <events>
            <catalog_product_get_final_price>
                <observers>
                    <YourFolderinLOCAL_YourModulename_model_observer>
                        <type>singleton</type>
                        <class> YourFolderinLOCAL_YourModulename_Model_Observer</class>
                        <method>simpleProductPrice</method>
                    </YourFolderinLOCAL_YourModulenameg_model_observer>
                </observers>
            </catalog_product_get_final_price>
            
        </events>
        </frontend>
</config>
added 34 characters in body
Source Link
Zeeshan
  • 51
  • 1
  • 5

Using Magento Version 19.2.2

May be slightly better solution, use 'Observer' approach instead of hacking the core or even overriding the default Model Price class i.e. app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php

May be slightly better solution, use 'Observer' approach instead of hacking the core or even overriding the default Model Price class i.e. app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php

Using Magento Version 19.2.2

May be slightly better solution, use 'Observer' approach instead of hacking the core or even overriding the default Model Price class i.e. app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php

Source Link
Zeeshan
  • 51
  • 1
  • 5

May be slightly better solution, use 'Observer' approach instead of hacking the core or even overriding the default Model Price class i.e. app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php

All you have to do is to use Alan's code within your newly created Observer the only difference is instead of returning

Mage::getModel("catalog/product")->load($id)->getFinalPrice($qty);

Replace it with the following:

$fp = Mage::getModel("catalog/product")->load($id)->getFinalPrice($qty);
return $product->setFinalPrice($fp);

Follow this Observer.php

class YourFolderinLOCAL_YourModulename_Model_Observer 
{
    
     public function simpleProductPrice(Varien_Event_Observer $observer) {
        $event   = $observer->getEvent();
        $product = $event->getProduct();
        $qty     = $event->getQty();
        //Mage::log($observer, null, 'confPricing.log');
        // process percentage discounts only for simple products
        
            
            $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);
    }
    
    
}

Config.xml

<?xml version="1.0"?>
<config> 
 <modules>
        < YourFolderinLOCAL_YourModulename>
            <version>0.0.1</version>
        </ YourFolderinLOCAL_YourModulename>
    </modules>
    <global>
        <models>
            < YourFolderinLOCALYourModulename> <!--- Al lovwercase in my case--- >
                <class>Your_Model</class> <!-- not needed in my case -->
            </ YourFolderinLOCALYourModulename>
        </models>
        
    </global>
    <frontend>
    <events>
            <catalog_product_get_final_price>
                <observers>
                    < YourFolderinLOCAL_YourModulename_model_observer>
                        <type>singleton</type>
                        <class> YourFolderinLOCAL_YourModulename_Model_Observer</class>
                        <method>simpleProductPrice</method>
                    </ YourFolderinLOCAL_YourModulenameg_model_observer>
                </observers>
            </catalog_product_get_final_price>
            
        </events>
        </frontend>
</config>

Hope it solves the problem.. :)