I am using the block rewrite below to add two fields to module Amasty_Shopby.
<?php
class Etre_Amshopby_Block_Rewrite_Shopby_Adminhtml_Filter_Edit_Tab_General extends Amasty_Shopby_Block_Adminhtml_Filter_Edit_Tab_General
{
protected function _prepareRegularForm()
{
$fldSet3 = $this->_form->addFieldset('etre_amshopby_extra', array('legend'=> $this->__('Bonus Options by Etre')));
$fldSet3->addField('labelOnFrontend', 'select', array(
'label' => $this->__('Show Label on Frontend'),
'name' => 'displayLabelFrontEnd',
'values' => $this->yesno,
'required' => true
));
$fldSet3->addField('labelInDropdown', 'select', array(
'label' => $this->__('Show Label in Dropdown'),
'name' => 'displayLabelInDropdown',
'values' => $this->yesno,
'required' => true
));
parent::_prepareRegularForm();
}
}
The fields show up but they do not save. I'm not sure what the most appropriate way to handle this is.
My guess is part of what needs to be done is each of these fields needs to be added to the Amasty filter table in the DB but I have setup few SQL install scripts within Magento modules so I am unsure as to how I should proceed.
The save action for the filter form is below. My fields are displayed when Zend_Debug::dump($data) is called within this action.
public function saveAction()
{
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('amshopby/filter');
$data = $this->getRequest()->getPost();
if ($data) {
$model->setData($data);
$model->setId($id);
if ($model->getData('display_type') == Amasty_Shopby_Model_Catalog_Layer_Filter_Price::DT_FROMTO) {
$model->setData('from_to_widget', true);
}
try {
$model->save();
Mage::getSingleton('adminhtml/session')->setFormData(false);
$msg = Mage::helper('amshopby')->__('Filter properties have been successfully saved');
Mage::getSingleton('adminhtml/session')->addSuccess($msg);
if ($this->getRequest()->getParam('continue')){
$this->_redirect('*/*/edit', array('id' => $model->getId()));
}
else {
$this->_redirect('*/*');
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $id));
}
$this->invalidateCache();
return;
}
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amshopby')->__('Unable to find a filter to save'));
$this->_redirect('*/*/');
}