Skip Navigation
Expand
Trouble accessing custom configuration settings from Customer Portal Framework version 3
Answer ID 6578   |   Last Review Date 11/16/2020

Why am I having intermittent trouble accessing custom configurations using the Config::getConfig method? 

Environment:

Customer Portal framework version 3.x
Oracle B2C Service

Issue:

I am trying to use the Config::getConfig method of the Customer Portal 3 API to retrieve the values of custom configuration settings. It works inconsistently, occasionally throwing a failure message.

Resolution:

By design, Config::getConfig in Customer Portal framework version 3 does not support retrieval of custom configuration settings. As such, it should not be used for this purpose as it is not guaranteed that it will work correctly.

Custom configuration settings are available through the Connect PHP APIs. A developer can leverage that API for custom configuration retrieval. Here is some sample code from its documentation to give you an idea of how this might look:

try {
    // To use the predefined names for custom configuration settings
    require_once( get_cfg_var( 'doc_root' ) . '/include/config/config.phph' );
    // Fetching by ID
    $cfg = RNCPHP\Configuration::fetch( 1000007 );
    // Fetching by ID using the constants defined by config.phph above
    $cfg2 = RNCPHP\Configuration::fetch( CUSTOM_CFG_TEST_SITE_INT_DefaultSameMinMax );
    // Fetching by Name
    $cfg3 = RNCPHP\Configuration::fetch( "CUSTOM_CFG_TEST_SITE_INT_DefaultSameMinMax" )
    // Examining the properties of the retrieved objects
    echo "My ID: {$cfg->ID}, {$cfg2->ID}, and {$cfg3->ID}\n";
    echo "My Value: {$cfg->Value}, {$cfg2->Value}, and {$cfg3->Value}\n";
    echo "My DataType: {$cfg->DataType->LookupName}, {$cfg2->DataType->LookupName}, and {$cfg3->DataType->LookupName}\n";
} catch ( \Exception $err ) {
    echo $err->getMessage();
}

Notes:

See the following documentation for more information: