0

i'm writing a observer based on this event

controller_action_predispatch_adminhtml_catalog_product_edit

public function currentUser(Varien_Event_Observer $observer) {
   $product = $observer->getEvent()->getProduct();

}

But i can't get the product through the event object which is null, how can i get product through this event?

2 Answers 2

1

You can't get the product object through this event because this event is just a call when Edit method is called in product controller.

Controller is called when product is edit.


class Mage_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Controller_Action

public function editAction()

{
     Mage::dispatchEvent('catalog_product_edit_action', array('product' =>  $product));
}
0

You will be getting the id of the product which is getting edited with the following code and once you get the id you can load the product

public function productEdit($observer){
    $productId = Mage::app()->getRequest()->getParam('id');
    $product = Mage::getModel('catalog/product')->load($productId);
}
1
  • i already found a answer alternative way of finding product id as same as your answer, thanks for your reply
    – hkguile
    Commented Aug 10, 2016 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.