1

We have a attribute 'short-description' in our product listing page. We want to escape html characters e.g. "&" => "&" , and append information to it when our admin hit 'save' in product editing page. Which file / method should I be looking into?

2 Answers 2

2

You shouldn't override the save method.
Use an observer.
You can observe the event catalog_product_save_before.
Your method could look like this:

public function catalogProductSaveBefore($observer) {
    $product = $observer->getEvent()->getProduct();
    $shortDescription = $product->getShortDescription();
    $shortDescription = ...process your short description here
    $product->setShortDescription($shortDescription); 
    Mage::getSingleton('adminhtml/session')->addNotice('your message for admin here');
}

Read more about how event observers work in here.

1
  • Works like a charm!! Commented Oct 8, 2014 at 1:05
0

You can start to debug from Mage_Adminhtml_Catalog_ProductController::saveAction(). This method holds product saving action. So you need to rewrite this controller file

File : app/code/core/Mage/Adminhtml/controller/Catalog/ProductController.php

public function saveAction()
{
     $short_descr = $this->getRequest()->getParam('shor_description');
     if ($short_descr != '') {
         //do something with it
     }
}

Hope it helps

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.