Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Error: Call to a member function getLanguages() on null #96

Open
JMauclair opened this issue Jul 6, 2021 · 0 comments

Comments

@JMauclair
Copy link

Hi,

I'm developping a custom module which generate categories, when I start the category generation I have the following error :

Fatal error: Uncaught Error: Call to a member function getLanguages() on null in C:\wamp64\www***\modules\gshoppingflux\gshoppingflux.php on line 160

To reproduce ->

Launch this php script :

`<?php

require dirname(FILE) . '../../../../config/config.inc.php';
require dirname(FILE) . '../../../../classes/Category.php';

$id_lang = Context::getContext()->language->id;

$mainCat = new Category;
$mainCat->id_parent = 2;
$mainCat->description = createMultiLangField("");
$mainCat->meta_description = createMultiLangField("
");
$mainCat->meta_title = createMultiLangField("");
$mainCat->is_root_category = false;
$mainCat->name = createMultiLangField("
");
$mainCat->link_rewrite = createMultiLangField("**");
$mainCat->add();

$rootBrandId = $mainCat->id;

echo $bool;

function createMultiLangField($field)
{
$languages = Language::getLanguages(false);
$res = array();
foreach ($languages AS $lang)
$res[$lang['id_lang']] = $field;
return $res;
}
?>`

*** values are to protect potential sensitive informations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant