1

My website has a custom module (created by someone else), that pulls in third-party data from an API and uses the Channel Entries API to add or update new entries in ExpressionEngine.

Recently, we have had to add some custom fields to the channel in question, to hold manually-entered info (that is in addition to the fields entered/updated by the API). Since the API will null out fields that aren't specifically passed to the update_entry function, I was able to adjust the module to retrieve info from those fields and include them in the update_entry array. BUT, some of the custom fields we have to add are Matrix fields and they are still being cleared out. I'm at a total loss on how to resolve this. The update_entry is clearing the '1' flag out of the Matrix field in channel_data -- the underlying matrix_data content remains intact (but without the '1', won't display).

Any suggestions on how to handle this would be appreciated -- I've been going around and around with this for days. Here is the code in question:

private function _update_event($entry, $event)
{
    $data = $this->_prepare_input($event, $entry);
    $this->EE->api_channel_fields->setup_entry_settings($this->channel_id, $data);

    $cd = $this->EE->db->get_where('channel_data', array('entry_id' => $entry['entry_id']));
               $res_arr = $cd->result_array();
                $new_entry_data = $res_arr[0];


                foreach($data as $data_field_name => $data_field_value) {
                    $new_entry_data[$data_field_name] = $data_field_value;

                }

    // if inserted successfully
    if($this->EE->api_channel_entries->update_entry($entry['entry_id'], $new_entry_data)) {

        if ($event->LocationPhone) {
            $this->_assignCategoryToEntry($entry, $event);
        }
        return true;
    }
    else {
        // there has been an error
        $errors = $this->EE->api_channel_entries->errors;
        //log error
        log_message('error', $this->_format_errors($errors));
        //$this->show_error($this->_format_errors($errors));
        return false;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.