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
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.
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