d1m007 / gshoppingflux

PrestaShop Google Shopping Flux Module
100 stars 61 forks source link

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

Open JMauclair opened 3 years ago

JMauclair commented 3 years ago

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.