Fn_Get_Company_Data() Gives The Wrong Information

Hi,

I'm trying to get my company's address and phone number. For this, I use the fn_get_company_data() function.

I made sure my company ID was right. Even tried providing the language URL as second parameter, but doesn't work either.

Some data is correct, some is not. The name is correct, and so are the URLs. But I also get the following:

[address] => Boston street
[city] => Boston
[state] => MA
[country] => US
[zipcode] => 02125
[email] => simtech@example.com
[phone] => 555555555
[fax] => +555555555
[url] => http://example.com

This simply isn't my company data :)

In the admin panel I do see the correct information.

I use the following URL:

https://***/***.php?dispatch=companies.update&company_id=1&descr_sl=nl

I'm on version 4.9.3.SP1 and I have the Ultimate edition.

For testing purposes I tried the following:

fn_get_company_data(1, 'nl')

Just returned the wrong info as placed above.

Can anyone help me out?

Kind regards,

Jordi

Hi,

I'm trying to get my company's address and phone number. For this, I use the fn_get_company_data() function.

I made sure my company ID was right. Even tried providing the language URL as second parameter, but doesn't work either.

Some data is correct, some is not. The name is correct, and so are the URLs. But I also get the following:

[address] => Boston street
[city] => Boston
[state] => MA
[country] => US
[zipcode] => 02125
[email] => simtech@example.com
[phone] => 555555555
[fax] => +555555555
[url] => http://example.com

This simply isn't my company data :)

In the admin panel I do see the correct information.

I use the following URL:

https://***/***.php?dispatch=companies.update&company_id=1&descr_sl=nl

I'm on version 4.9.3.SP1 and I have the Ultimate edition.

For testing purposes I tried the following:

fn_get_company_data(1, 'nl')

Just returned the wrong info as placed above.

Can anyone help me out?

Kind regards,

Jordi

Can you query the ```?:companies``` table directly and see what all the table columns hold?

Hi,

The companies table also has the incorrect data.

Wondering where my data is stored then :confused:

Hi,

I'm trying to get my company's address and phone number. For this, I use the fn_get_company_data() function.

I made sure my company ID was right. Even tried providing the language URL as second parameter, but doesn't work either.

Some data is correct, some is not. The name is correct, and so are the URLs. But I also get the following:

[address] => Boston street
[city] => Boston
[state] => MA
[country] => US
[zipcode] => 02125
[email] => simtech@example.com
[phone] => 555555555
[fax] => +555555555
[url] => http://example.com

This simply isn't my company data :)

In the admin panel I do see the correct information.

I use the following URL:

https://***/***.php?dispatch=companies.update&company_id=1&descr_sl=nl

I'm on version 4.9.3.SP1 and I have the Ultimate edition.

For testing purposes I tried the following:

fn_get_company_data(1, 'nl')

Just returned the wrong info as placed above.

Can anyone help me out?

Kind regards,

Jordi

We faced such bug as well. Some data is got from ?:companies table and another part is from ?:settings_objects

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.