as the title says, I’m trying to add a custom logic hook into a module, but when I attempt to use it, I get the following message:
Fatal error: Cannot redeclare class OppPunt in /var/www/html/briocrm/custom/Extension/modules/Opportunities/Ext/LogicHooks/OppPunt.php on line 4
I’ve been looking for similar issues, but all of them relate to default classes of Suite/SugarCRM like OAuthToken.
What I want to achieve is to calculate and and to the record some score we use to rank our opportunities, as far as I’ve tested it, my code is ok. I’ll leave it here.
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class OppPunt {
var $a;
function puntuarOpp ($bean, $event, $arguments) {
if ($bean->calification_c == 1){$a = 1;}
else if ($bean->calification_c == 2){$a = 3;}
else if ($bean->calification_c == 3){$a = 5;};
$prob = $bean->probability;
$cost = $bean->amount;
$valor = round($prob*$cost*$a/100000);
$bean->opportunity_value_c = $valor;
}
}
?>
Any help would be greately appreciated. I’m stucked in here.
don’t put your hook file “OppPunt.php” in /custom/Extension/modules/Opportunities/Ext/LogicHooks/ this is only for the definition that defines your hook
Thanks Matt, I was following the developer guide, but you’re right, once I moved the file “OppPunt.php” to the folder /custom/modules/Opportunities it stopped sending the fatal error message, but now the logick hook is not working and I can’t find why, I’ve already checked the log and enabled the errors display option in index.php. The only thing I get is this
[DEPRECATED] SugarBean.php: preprocess_fields_on_save() is deprecated.
Another thing I noticed is that the file /custom/Opportunities/Ext/LogicHooks/logichooks.ext.php used to show a copy of the code in my OppPunt.php, back when OppPunt.php was in /custom/Extension…/Ext/LogicHooks, but now logichooks.ext.php is empty. Does it has anything to do with my hook not working?
Ok, the logic hook is working, the problem seems to be somewhere else. Supposedly I should do a QR&R to let the changes apply, but, somethings wrong with the computer I’m using for testing and development, no every change applies immediately, but they do until after I restart the computer, that’s why I thought the logic hook wasn’t working, I saw it work until the next day.