Have an extension and want to enable it if $field1 == $field2
and if not extension be disable.
can enable it with line below but can not disable it when if is not true!
protected function _beforeSave()
{
$value = $this->getValue();
$fieldConf = $this->getFieldConfig();
if ($value) {
try {
$fields2 = Mage::getStoreConfig('carriers/module/fields2');
$fields1 = Mage::getStoreConfig('carriers/module/fields1');
$condition = empty($fields2) || !$fields2 || empty($fields1) || !$fields1;
if ($condition) {
$err = Mage::helper('module')->__('extension not registered.');
Mage::throwException($err);
}
if($field1 == $field2) {
Mage::getConfig()->saveConfig('carriers/module/active', 1)->reinit();
Mage::app()->getConfig()->reinit();
} else {
Mage::getConfig()->saveConfig('carriers/module/active', 0)->reinit();
Mage::app()->getConfig()->reinit();
$err = Mage::helper('module')->__('Is not valid and Disabled.');
Mage::throwException($err);
}
}
catch (Exception $e) {
Mage::throwException($e->getMessage());
return $this;
}
}
return $this;
}