config.xml
<?xml version="1.0"?>
<config>
<modules>
<Test_Test>
<version>0.1.0</version>
</Test_Test>
</modules>
<global>
<helpers>
<test>
<class>Test_Test_Helper</class>
</test>
</helpers>
<models>
<test>
<class>Test_Test_Model</class>
<resourceModel>test_mysql4</resourceModel>
</test>
</models>
</global>
<frontend>
<events>
<catalog_product_collection_load_after> <!-- identifier of the event we want to catch -->
<observers>
<catalog_product_collection_load_after_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>test/observer</class> <!-- observers class alias -->
<method>catalogProductLoadAfter</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</catalog_product_collection_load_after_handler>
</observers>
</catalog_product_collection_load_after>
</events>
</frontend>
</config>
Observer.php
<?php
class Test_Test_Model_Observer
{
public function catalogProductLoadAfter(Varien_Event_Observer $observer)
{
$collection = $observer->getEvent()->getCollection();
foreach ($collection as $product)
{
$produ = Mage::getModel('catalog/product')->load($product->getId())->getData('discountatt');
$originalprice = $product->getPrice();
$customprice = $originalprice+$produ;
$product->setPrice($customprice);
// $product->setData('my_price',$customprice);
}
// echo '<pre>';print_r($produ); exit;
// $product = $observer->getEvent()->getProduct();
/*$originalprice = $product->getPrice();
$product->setPrice($customprice);*/
}
}