Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

What is purpose of events
 
Vipan Kumar
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2012-08-27
Ludhiana, Punjab, India
 

I am working on quick preview of product in magento community version 1.7. i have download a extension which working as same. I found some line of code which is i am unable to purpose and motive please explain these things

Events: why do we execute these events in quick view controller

catalog_controller_product_init_before
catalog_controller_product_init
catalog_controller_product_init_after

and some function following why use them please any body explain these i want to understand them what they work

getUpdate, addHandle, loadLayoutUpdates, getCustomLayoutUpdate

$update $this->getLayout()->getUpdate();
        
$update->addHandle('default');
        

        
$update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
        
$update->addHandle('PRODUCT_'.$product->getId());

        
$this->addActionLayoutHandles();

        
$this->loadLayoutUpdates();

        
$update->addUpdate($product->getCustomLayoutUpdate());

        
$update->merge(strtolower($this->getFullActionName()).'_FINAL');

        
$this->generateLayoutXml()->generateLayoutBlocks();

we can just load template file directly in template through widget so why we need call layout updates. i have attached controller file

File Attachments
IndexController.php  (File Size: 7KB - Downloads: 17)
 
Magento Community Magento Community
Magento Community
Magento Community
 
satish
Enthusiast
 
Total Posts:  812
Joined:  2008-03-24
34,mantri Sadan,Shivaji Nagar,Nagpur,MS,India 4400
 

There is event observer concept in Magento so.
This helps in avoiding core files to be touched.

In XML you can set an observer to listen to an event.

So when an event is fired an observer will be informed and it can call a function of a class where some code can be placed.

There are lots of documents on net related to this.
You need to go through them.

Satish

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top