AnsweredAssumed Answered

Custom "Bean" ends up in Cannot redeclare class error

Question asked by gperez gperez on Feb 19, 2014
Latest reply on Feb 24, 2014 by gperez gperez
I need to add some fields to an Export report. So, I needed to modify the $query to make a new join and add the new fields. That can't be done en the /modules folder, but I found a solution here through /custom/modules folders:

http://forums.sugarcrm.com/f148/can-quotes-bean-quote-php-pulled-custom-folder-88105/

The idea is to copy the class that has the create_export_query() method. In my case, it's called oasis_Properties class. 

So, I created my "clone" in /custom/modules/oasis_Properties. The new file is named oasis_Properties_override.php and the class remains with the same name (can't change it without having errors as far as I can see)

To make this class work (instead of the original one in /modules/oasis_Properties) I made a file in /custom/Extension/applications/Ext/Include with this content: 
$beanFiles['oasis_Properties'] = 'custom/modules/oasis_Properties/oasis_Properties_override.php';

Then I performed a quick Rebuild and Repair. And it works! Al least for the export action. However, there's a problem in the Studio now. When I want to see the Relationships I get an error: 

Fatal error: Cannot redeclare class oasis_Properties in C:\projects\614OasisCrm\Site\modules\oasis_Properties\oasis_Properties.php on line74 

I can't solve this adding a "class_exists" check, because the problem is not in my custom file but in the original file, being called after mine.

Any clue on how to solve this?

Outcomes