This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

point4d27635
point4d27635

Hello. I'm trying to add an import\export feature to my plugin. I followed this guide: https://octobercms.com/docs/backend/import-export Export works fine, but when i try to import same file or new, it throws an error listing all rows in the file. Message next to row number contains just column name. There is no any specific errors, how do i find the source of this problem? Thanks.

point4d27635
point4d27635
labsinet52956
labsinet52956

add the following text to your class:

    public function importData($results, $sessionKey = null)
    {

Subscriber::unguard();
        foreach ($results as $row => $data) {

            try {
                $subscriber = new Subscriber;
                $subscriber->fill($data);
                $subscriber->save();

                $this->logCreated();
            }
            catch (\Exception $ex) {
                $this->logError($row, $ex->getMessage());
            }

        }
        Subscriber::reguard();
    }
}

this example based to https://octobercms.com/docs/backend/import-export

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.