<p>Please make sure the tag <a href="https://github.com/clearbold/craftimport/blob/master/services/CraftImportService.php#L18-L22" rel="nofollow">settings in CraftImportService.php</a> are set properly.</p>

CC BY-SA 3.0
2014-06-27T17:26:56.060Z
D'OH!!! This was one of the first things I tried to do with almost zero frame of reference. Of course I'd mess this up. Thanks Nate!
Caroline from Aquarian
CC BY-SA 3.0
2014-06-27T16:50:47.347Z
2014-06-27T17:05:22.440Z
2014-06-27T17:05:22.440Z
Natetronn
<p>Hello kind helper folk,</p>

<p>I'm working with Simple Craft XML Import, which has a handful of older code in it. I've managed to get through most of it to the very end.</p>

<p>The last thing it does is saves tags. My tags are saved, but now it has to relate it back to the entry and Craft appears to be saving them but not relating them back correctly, and not throwing an error.</p>

<p>The saveRelations function appears to need:  </p>

<p><code>an instance of Craft\FieldModel</code> provided in arg 1</p>

<p><code>an instance of Craft\BaseElementModel</code> provided in arg 2</p>

<p>.. the data in arg 3.</p>

<p>I have the following code:</p>

<pre><code>                $tagFieldRecord = FieldRecord::model()-&gt;findByPk($tagFieldId);

                $tagFieldModel = FieldModel::populateModel($tagFieldRecord);

                $entryRecord = EntryRecord::model()-&gt;findById($entryRecord['elementId']);

                $entryModel = EntryModel::populateModel($entryRecord);

                craft()-&gt;relations-&gt;saveRelations($tagFieldModel, $entryModel, $tags);
</code></pre>

<p>Everything appears to have saved in the db tables - tags and the relations, but when I go to the entries in the back end, there are no tags.</p>

<p>Is there a good db value to look in on and change to get these to work?</p>

<p>Also, is there something in my code I can change to make this happen through the code and not hacking the db?</p>

CC BY-SA 3.0
2014-06-27T16:34:35.943Z
Did you set [these settings?](https://github.com/clearbold/craftimport/blob/master/services/CraftImportService.php#L18-L22)
Natetronn
CC BY-SA 3.0
2014-06-27T16:39:57.230Z
Good question!! Yes I set all the settings. Everything imported as desired/expected - but the relationship of the tags to the entries does not appear to have saved when I go to look at the entries in the CP. There was no error code at all.
Caroline from Aquarian
CC BY-SA 3.0
2014-06-27T16:45:39.203Z
I re-examined them and they were wrong. Ugh I feel like such an idiot. Thank you!
Caroline from Aquarian
CC BY-SA 3.0
2014-06-27T16:49:25.550Z
@Natetronn, post that as a real answer so Petroglyph can declare you the winner and you can get your much deserved points. :)
Lindsey D
<tags><php>
Tag relations not saving
# Tag relations not saving

(Asked by: username_0 on 2014-06-27)

Hello kind helper folk,
I'm working with Simple Craft XML Import, which has a handful of older code in it. I've managed to get through most of it to the very end.
The last thing it does is saves tags. My tags are saved, but now it has to relate it back to the entry and Craft appears to be saving them but not relating them back correctly, and not throwing an error.
The saveRelations function appears to need:  
an instance of Craft\FieldModel provided in arg 1
an instance of Craft\BaseElementModel provided in arg 2
.. the data in arg 3.
I have the following code:
                $tagFieldRecord = FieldRecord::model()->findByPk($tagFieldId);

                $tagFieldModel = FieldModel::populateModel($tagFieldRecord);

                $entryRecord = EntryRecord::model()->findById($entryRecord['elementId']);

                $entryModel = EntryModel::populateModel($entryRecord);

                craft()->relations->saveRelations($tagFieldModel, $entryModel, $tags);

Everything appears to have saved in the db tables - tags and the relations, but when I go to the entries in the back end, there are no tags.
Is there a good db value to look in on and change to get these to work?
Also, is there something in my code I can change to make this happen through the code and not hacking the db?

**Tags:** tags, php
> **Comments:**
> **username_1**: Did you set [these settings?](https://github.com/clearbold/craftimport/blob/master/services/CraftImportService.php#L18-L22)  
> **username_0**: Good question!! Yes I set all the settings. Everything imported as desired/expected - but the relationship of the tags to the entries does not appear to have saved when I go to look at the entries in the CP. There was no error code at all.  
> **username_0**: I re-examined them and they were wrong. Ugh I feel like such an idiot. Thank you!  
> **username_2**: @Natetronn, post that as a real answer so Petroglyph can declare you the winner and you can get your much deserved points. :)  

---

## 1 answers

### Answer by username_1 on 2014-06-27. Score: 4 | Accepted answer

Please make sure the tag [settings in CraftImportService.php](https://github.com/clearbold/craftimport/blob/master/services/CraftImportService.php#L18-L22) are set properly.

> **Comments:**
> **username_0**: D'OH!!! This was one of the first things I tried to do with almost zero frame of reference. Of course I'd mess this up. Thanks Nate!  

---

