We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Channel Entries API Error: Undefined property: EE::$stats

How Do I?

EXODev's avatar
EXODev
4 posts
8 years ago
EXODev's avatar EXODev
A PHP Error was encountered Severity: Notice Message: Undefined property: EE::$stats Filename: api/Api_channel_entries.php

The API library is loaded successfully:

ee()->load->library('api');
 ee()->api->instantiate('channel_entries');
 ee()->api->instantiate('channel_fields');

and I am making sure the API user has permission (SuperAdmin).

The data array looks like this:

$data = array(
'title'         => $tTourTitle, 
'field_id_127'  => $tTourDuration, 
'field_id_136'  => $pCountry, 
'field_id_137'  => "$tTourCity", 
'field_id_141'  => "$tIncludes",  
'field_id_142'  => "$tExcludes", 
'field_id_143'  => "$tNotes", 
'field_id_144'  => "$tDescription", 
'field_id_145'  => "$pTour->Opt", 
'field_id_149'  => $tTourPreferred 
);

and I am executing the call according to EE 2.11.1 documentation:

ee()->api_channel_fields->setup_entry_settings($this->aEESettings['experiences_channel_id'], $data);

if($pTourId !== ''){
  $updateResult = ee()->api_channel_entries->save_entry($data, $this->aEESettings['experiences_channel_id'], $pTourId);
} else {
  $updateResult = ee()->api_channel_entries->save_entry($data, $this->aEESettings['experiences_channel_id']);
}

Why would I get this stats object error? Do I need to load any other models/apis to get this working?

Not sure if this matters, but we are using the Structure AddOn.

Follow-up edit: if I comment the line of code in question, then the code runs through successfully. All entries appear in the back-end, however, they are not rendered in the front-end - unless the entry is accessed and saved in the back-end. Are these two issues related?

Thanks in advance for your input.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.