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

tony_p4620282
tony_p4620282

I am trying to utilize this plugin to import an xml file, I have a simple xml file. '

1-61tommememeTest
<login_details>
    <unique_ref>1-61</unique_ref>
   <login_name>tony</login_name>
    <login>tony</login>
    <password>tony</password>
    <file1>Test1</file1>
    <file2/>
    <file3/>
    <file4/>
</login_details>

' but can only manage to import 3 nodes I wrongly thought I could simply append this code "$postBlog = $blogPost::create(['unique_ref' => $item->unique_ref, 'slug' => Str::slug($item->unique_ref), 'login_name' => $item->login_name, 'login' =>$item->login);" but the last node does not update the database any help would be gratefully appreciated as I am new to coding in October frame work

Last updated

tony_p4620282
tony_p4620282

I Found this piece of code that works foreach ($xmls->login_details as $row => $data) { try { if (!$refno_prop = array_get($data, 'refno_prop')) { } /*

  • Find or create / $post = Post::make(); if ($this->update_existing) { $post = $this->findDuplicatePost($data) ?: $post; } $postExists = $post->exists; /
  • Set attributes */ $except = ['id', 'categories', 'author_email'];

    foreach (array_except($data, $except) as $attribute => $value) {
    $post->{$attribute} = $value ?: null;
    }
    $post->forceSave();
    /*
  • Log results */ if ($postExists) { $this->logUpdated(); } } catch (Exception $ex) { $this->logError($row, $ex->getMessage()); } } but now I need to one of the nodes as a slug and also I need to prevent it from adding the same data into database any thougts would help

Last updated

1-2 of 2

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