Set a sugar_config variable during a package install

John Mertic —  October 28, 2013 — 8 Comments

Saw this great question on the forums recently…

I have created a custom package from studio and published (I got a zip file); also this can be installed smoothly in any other installation. But I want to add some custom entries in to sugarcrm config array during installation of this package; how can I achieve this ?

This is actually pretty easy with the the Configurator class interface, which helps avoid trying to manually add the entries to the config_override.php file itself. See the code snippet below, which you could add to a post_execute script

John Mertic


John Mertic manages the strategic ISV alliances program for SugarCRM, having several years of techincal experience bringing solutions to market with several SugarCRM technology partners. A frequent conference speaker and an avid writer, he has been published in php|architect, IBM Developerworks, and in the Apple Developer Connection, and is the author of the book 'The Definitive Guide to SugarCRM: Better Business Applications' and the book 'Building on SugarCRM: Creating Applications the Easy Way'. He is also president of the OpenSocial foundation, guiding them in solving interoperability issues for enterprise application providers worldwide.

8 responses to Set a sugar_config variable during a package install


    I am having an issue with my email blasts going out with an “” at the top.
    Is there a way to prevent this? The test doesn’t show it but when the real email comes in that  is the first thing that appears on the top left hand side.


    Andy, will have our support team pick this up. Thanks!


    How do I remove a item in array variable config with a pre_uninstall.php script?


    As Pedro Alberto says, How do I REMOVE a item in array variable config with a pre_uninstall.php script? Both Sugar6 and Sugar7.



    I think you ought to be able to use unset() to do this. As far as I can tell handleOverride() serializes the config array back out. unset() will remove the key from the array. I will warn that I have not tested this.

    This method is same for Sugar 6 and Sugar 7.

    $configurator = new Configurator();
    if (!isset($configurator->config['test_key1'])) {


    As far as I can tell, the best you can do is set the value to false.
    I have been trying this with adding/removing a referer.

    It does do array diffs to see what is there to save, but those do not remove any empty values. If it’s in the orginal config, but not in the save config, it’s still there after the diff and therefore saves.

    When you look at /modules/Configurator/Configurator.php in the handleOverride function, lines 108-115
    If the value is not empty, set it.
    If the value is false, set it to false.
    No other option.

    Adding such as:
    $configurator->config[‘http_referer’][‘list’][] = ‘’;
    Gives you:
    $sugar_config[‘http_referer’][‘list’][] = ‘’;

    Then on the remove:
    $configurator->config[‘http_referer’][‘list’][{key}] = false;
    Gives you:
    $sugar_config[‘http_referer’][‘list’][] = false;

    But then you are stuck with $sugar_config[‘http_referer’][‘list’][] = false; forever.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s