Jump to content

 

Soneritics

Member Since 19 Jan 2017
Offline Last Active Jan 30 2020 03:31 PM
-----

#316225 Fn_Get_Company_Data() Gives The Wrong Information

Posted by Soneritics on 07 June 2019 - 01:27 PM

I've been debugging the Cs Cart code to see what happens.
 
I came up with the following code as a solution to get a simple array with key/values.
 

function getCompanyData(int $companyId): array
{
    $section = Settings::instance()->getSectionByName('Company');
    $settingsData = Settings::instance()->getList(
        $section['section_id'], 
        0, 
        false, 
        $companyId, 
        CART_LANGUAGE
    );

    $result = [];
    foreach ($settingsData['main'] as $setting) {
        $result[$setting['name']] = $setting['value'];
    }
    
    return $result;
}

You can see the file app/controllers/backend/companies.php around line 466 to 467 for how this is done in Cs Cart.