Error: Call to a member function getType() on null: Category not found