Support is offline. We are back Monday 23 November, 09:00.

Is it possible to UPDATE content - Update TAGS in CONTENT #9800

Open rusasadmins opened this topic Monday, 10 June 2019 · 33 replies
Author

Is it possible to UPDATE content with an import file?

  1. if I provided an import file with 3 fields and one of the fields included the unique username, which was also a field in the article (unique), could I use it to update other fields in the table?

For example:
Import File:
First Name
Last Name
Phone Number
User Name

In the ARTICLEs I have fields:
First Name, Last Name, Phone Number, user Name

Could I UPDATE these records on the import?

  1. If my import file included:
    User Group
    User Name

Could I 'import' into the user table, but only UPDATE the data and adjust the 'group' that the person is assigned to?

thanks,
Laura

Support

Hello Laura,

Users are updated based on their emailaddress. If the emailaddress exists, the user is updated, if the emailaddress does not exist the user is added unless you have set the option Skip new items to Yes.

To update user groups you would need 2 fields minimal:
[ul]
[li]email[/li]
[li]usergroup_name or usergroup_path[/li]
[/ul]

You would use the usegroup_path if you have a nested structure for your user groups like:
Location A/Dayworkers
Location B/Dayworkers

If you would only specify Dayworkers, CSVI would not know which group you meant.

Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

How about updating Joomla ARTICLES?

thanks,
Laura

Support

Hello Laura,

  1. if I provided an import file with 3 fields and one of the fields included the unique username, which was also a field in the article (unique), could I use it to update other fields in the table?

For example:
Import File:
First Name
Last Name
Phone Number
User Name

In the ARTICLEs I have fields:
First Name, Last Name, Phone Number, user Name

Could I UPDATE these records on the import?

For regular Joomla content import, title or alias and catid or category_path are the needed fields. Since you do not have those fields you cannot update these fields using regular content import. How are these fields stored in database? Are these Joomla custom fields for Articles?

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

Actually,
I could 'provide' the article title and the article id even in my view...

If I did and the article id already existed, would it be able to update the 'custom fields'?

I would do this as a different template, and I would just include 'people' that already exist. People are 'articles' in the system.

thanks,
-- Laura

Support

Hello Laura,

If I did and the article id already existed, would it be able to update the 'custom fields'?

Yes you can update the custom fields for existing articles. You can either provide article id or title/alias and catid/category_path fields in your import. With these fields RO CSVI will check if there is any matching article and update the custom fields else a new article will be created with custom fields.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

When I created my fieldmapper list, I don't see an option for the Article id? I see title, catid, but not article id...

So when I ran my template, it didn't 'find' the article, and added a new one...

I uploaded my 'field mapper list'...

When I created the field mapper, since there is no ID, it's not 'matching up'...I selected to 'skip' the id...

Screen Shot 2019-11-22 at 9.58.13 AM.png

thanks,
Laura

Author

Ok, forget my last post... I figured it out...

using this documentation: https://rolandd.com/documentation/ro-csvi/joomla-content/joomla-content#import

I changed my view to include

  • alias
  • category_path

And it worked beautifully!!!

Now I'm going to create a view to change the custom fields and see how that works.

Last question, how about TAGS? If I need to update the tags, but SOME tags I want to keep? I assume I have to do that manually?

Because I'm using TAGS to determine 'groups' people are assigned to, and that doesn't come in the import.

thanks,
Laura

Author

Great news...

I was able to update:

  • users
  • content

Thank you!

I think for TAGS I will have to do this manually... because as I said above, I need to KEEP some of the tags, based on the path structure, but other tags, I need to remove...

So for example the tags that are within 'PEOPLE', those I have to replace from my feed...

but the other tags... I need to KEEP, because those are set in joomla

Support

Hello Laura,

So for example the tags that are within 'PEOPLE', those I have to replace from my feed...

but the other tags... I need to KEEP, because those are set in joomla

For replacing tags, you can delete those specific tags you need to replace using tag_delete with value set to Y. You can then import new tags. These tags can be then used in Joomla content import.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

If I set tag_delete, will it delete ALL of the tags?

I do NOT want to remove ALL tags, I just want to remove specific ones...

For example...

I have a tag hierarchy for 'research groups', this determines the research groups they are in... these tags I do NOT want to delete...because they change them in Joomla.

I also have a tag hierarchy for PEOPLE, THIS I want to REPLACE (because my import file tells me where to 'put people', into specific areas of the site.

thanks,
Laura

Support

Hello Laura,

If I set tag_delete, will it delete ALL of the tags?

This will delete only the tags you have set value as Y and not all the tags.

I have a tag hierarchy for 'research groups', this determines the research groups they are in... these tags I do NOT want to delete...because they change them in Joomla.

If you do not want to delete a tag set tag_delete as N for that particular row in your import file.

I also have a tag hierarchy for PEOPLE, THIS I want to REPLACE (because my import file tells me where to 'put people', into specific areas of the site.

When deleting a tag RO CSVI looks for its path and alias. So you need to set these fields in your import file along with tag_delete set to Y. For example if you want to delete a child tag which is under parent tag. You need to set path as parent-tag/child-tag and alias as child-tag and tag_delete as Y. Remember all these can be done with Joomla tag import operation.

Let me know if you need any more clarification.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

Tharuna,
Hi, here is the situation, my import is an import for CONTENT/ARTICLE

My CONTENT HAS THIS: already stored in the database
Jane is in the tag of professors and ptl and research group of engineering

article-alias tags
Jane . People/Faculty/Professors|People/Faculty/PTL|Research-Group/Engineering

If now, when I update Jane I want the tags to be: (I get this from my feed)

article-alias . tags
Jane . People/GraduateStudents

BUT I want to keep her in the Research-Group/Enginnering
I want to REMOVE her from People/Faculty/Professors|People/Faculty/PTL

You see Research-group/engineering is a tag that we assign in Joomla, it does not come from an outside feed.

What will happen?

thanks,
Laura

Support

Hello Laura,

This is a complex situation. The main problem is, the tag(s) to be removed is not in the import file so RO CSVI has no clue to remove these tags. From the point of view of RO CSVI, tags are just tags, whether they come in via a feed or are added via Joomla.

The basic question is, how would the system know which tags to delete?

There doesn't happen to be a feed that lists which tags has been removed from an entity?

Kind regards,

RolandD

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

I COULD give you the 'list' of the tags that I would WANT to be removed, as I know the exact paths for those tags.

I can either:

  1. give a list of tags for that specific article that should be removed (I can include the paths, ids, etc)
  2. give a list of all tags (even if they are not for that specific article) that need to be removed

THEN I can give or include another field for the tags to be ADDED.

let me know what you think would make the most sense.

I just can't have all of the tags removed, since some tags are being modified locally in joomla.

thanks,
Laura

Support

Hello Laura,

I COULD give you the 'list' of the tags that I would WANT to be removed, as I know the exact paths for those tags.

If you know the tags then you can create a CSV file with alias, path and tag_delete field set to Y and use Joomla tags import to remove these tags. By doing this import the relation between the deleted tag and the article is also removed. You can then add the new tag to the articles using Joomla content import.

THEN I can give or include another field for the tags to be ADDED.

You can add new tags to the same CSV file in the above import without setting any value to tag_delete field. RO CSVI will add these new tags.

I just can't have all of the tags removed, since some tags are being modified locally in joomla.

You don't have to remove all tags. Just add the tags to be removed and tags to be added in same import file. You can manage your tags using Joomla tags import template.

You need to do two import here, one is for managing your tags and the other is Joomla content import as you are doing now to link the tags to your articles.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

I think I found a small issue with my 'tag updates'...

So to do this right, let me give you background...

I have a FEED that will have the 'most current' tags that a person should be assinged to
I want to store a FIELD as an extra custom field with the 'current version of tags stored'
This way I can compare them to see IF tags need to be updated, and I can use the 'current tags' to be used to define which tags to DELETE. (as I don't want to delete all tags).

I thought that by using a custom field, I could use that as a 'backup' of what someone is assigned, and I don't have to 'flatten the data'.

BUT, when I put data in the custom fields, since a '|' was used, your system inserted it as 2 records in the fields table...

Here is my example...

My import view to the custom field that I call - originaltags

  1. Import I use:
	 1447 	 Martin, Richard 	 richard-martin 	 rmartin 	 people/faculty/professors|people/staff/technical-staff 	 people/faculty
  1. when I go to the site table fields_values I see
field_id	item_id	value
105 	 1447 	 people/faculty/professors
105 	 1447 	 people/staff/technical-staff

Which does not help me at all, because I really wanted to keep the string:
people/faculty/professors|people/staff/technical-staff

SO when I do this, do you recommend I put " " around the content?

I seem to always make things one step more complicated...

thanks,
Laura

Support

Hello Laura,
With custom fields, multiple values are separated by | and so when RO CSVI gets the value with | it is inserted as individual values. That is the logic of RO CSVI code for all multiple values imported. Using "" around the content will not help. You need to use any other character other than | to have the value inserted as one. If the custom field value is just for reference, why not use any other character like # or $ or ^ instead of |?

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

Ok, but here is the issue, I do not see in the CONTENT for ROCSVI tag_delete

I only see this in the tags table, but I do NOT want to delete the tags in the database, I want to just delete them from the CONTENT records...

so I created a view that shows:
articleid title alias category_path tag_delete tags
1403 Motto, Douglas douglas-motto people/staff Y people/affiliated-faculty/associate-graduate-faculty-member|people/affiliated-faculty/full-graduate

but it seems that I can't remove his tags this way...

I'm creating my sql #1, which would REMOVE the tags from the article
sql #2 will add the tags for the article

thanks,
Laura

Support

Hello Laura,

Ok, but here is the issue, I do not see in the CONTENT for ROCSVI tag_delete

tag_delete field is only for Joomla tags import and not supported with Joomla content import operation.

I only see this in the tags table, but I do NOT want to delete the tags in the database, I want to just delete them from the CONTENT records...

Removing the relation between a tag and content is not possible now. There is no code added for it yet.

so I created a view that shows:
articleid title alias category_path tag_delete tags
1403 Motto, Douglas douglas-motto people/staff Y people/affiliated-faculty/associate-graduate-faculty-member|people/affiliated-faculty/full-graduate

but it seems that I can't remove his tags this way...

This will not work, tag_delete is not supported in Joomla content import operation.

I'm creating my sql #1, which would REMOVE the tags from the article
sql #2 will add the tags for the article

Yes, If you know the id of the tags then it should be possible with sql queries.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

I ran an 'update' import using one of your templates to update all of my tags for all of my articles.

It seemed to work perfectly fine.

I also tested by removing 2 records from the tag-contentmap table for 2 articles, just to see if the data got added properly, when I ran the update script from rocsvi, and it did!

When I go to any of my articles, I see the tags listed properly.

Problem:
When I edit any articles that are in the people category, I receive an error:

Screen Shot 2019-12-10 at 11.50.11 AM.png

After some research it seems that this error could occur when there is a problem in the assets table...also, I'm only seeing this error with articles that I have updated using csvpro...

I tried the following:

  1. rebuild all menu items
  2. rebuild all categories
  3. enter each category (for those articles) and resaved the category
  4. rebuild the categories again

sometimes I don't get the error, but either way my change is usually saved no matter what.

Also, when I try to update something in one of the CUSTOM FIELDS, that data is NOT saved

Any ideas?

What did I break?

What can I send to you to help me debug? Unfortunately I cannot give you login access.

thanks,
Laura

Support

Hello Laura,
Can you send us the latest import debug log, template XML and your import file? There is no details on what the error could be when article is saved. It just says "Save failed with following error". Send me the requested details. I will run the import and check. I will see if i can reproduce the issue.

Also is the custom fields update in the same import? If not send me the debug log of that import to check.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

For the error, I know it doesn't show any more details, even when I turn on debuger, and error handling it still doesn't show. when I looked up in the joomla forums / google, I found that the error like that signifies something is corrupt in the ASSETS table...

I'm attaching my people update fields and tags, I update my fields and tags at the same time.

When I go into any records that are within the category of 'people', I have the same problem.

If I need to, I could create a new people category, move all of the sub categories over, and see if that rebuilds the 'assets', but I will wait until you look at the log before I do that, because once I do, I will have to make lots of adjustments, to my data sql, fields, etc.

thanks,
LAura

Support

Hello Laura,
As per the import debug log, tags are imported for articles and also custom fields. There is nothing wrong i could see from debug log. If you can give me details of specific custom field which you are having problem with, i can check that in debug log.

For the article error, it could be something to do with people category. Was this people category created using RO CSVI?

How about you create a temp people category and import articles in there? You can test it with one article and see how it goes.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

I have discovered the exact problem...

  1. I created a new category
  2. I COPIED my articles into this new category
    (when I 'moved them', I still had errors in these articles
  3. I tested, and can edit the articles as needed --> GOOD
  4. I took one article (article title: Doug Motto), and REMOVED the only tag set for this person, so he had NO TAGS
  5. The other 21 articles all had tags (each just had 1 tag)

I ran my update script
In the TAGS field had the tag: People/Administrative Staff (for example), just 1 tag

When I went into Doug Motto
---> everything worked perfectly
---> tag was added back properly
---> fields were editable
---> content was editable

When I went to edit any of the other 21 articles
---> SAME ERROR AS BEFORE, it's as if the record is corrupted
---> They have 1 tag as the others

Can you try something like this in your system, where you HAVE a tag in a record, then run the update with the same tag again... see if it corrupts the data?

thanks,
Laura

Support

Hello Laura,
Thank you for the detailed information. I was able to reproduce this issue, for me the error was on article for which the tag has been removed and added again on import. But anyways the error is because of #__ucm_content and #__ucm_base table which was related to tags. I have fixed the issue with the attached patch file. Can you load the attached patch file and run your import? Let me know on how it goes.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

Tharuna& Roland,
Hi, it worked!!! I have tested a few times with the same article

  • with the tag
  • removed the tag
  • without the tag
  • with another tag

and it all worked, and no more corruption!

thanks,
Laura

Author

Now, I tried to run it with 22 records, just to see how it works...

I got an error:
duplicate primary key = 4098

I looked at that record:
core_content_id = 4098
content_item_id = 2538
tag_id = 51

and
core_content_id = 4098
content_item_id = 2538
tag_id = 101

Here is the record:
Screen Shot 2019-12-18 at 9.58.50 AM.png

I attached the download log

It looks like the records are all being updated (although there is nothing to update in this run)

When I try to edit that record, I'm NOT getting any errors, so it's not corrupted.

I can ADD another tag manually to that record, and it works properly.

I don't want to run this script on all of my records until we are sure that it won't corrupt the data.

Question, do you think I should be able to run the script against all records, and it will 'fix' the error that I'm having, or will I have to move them to different categories, then run the script? Note, when I move to a different category, I have to make sure all of my fields work with that category before the move, so I don't lose any data. I have about 20 fields.

thanks,
Laura

Support

Hello Laura,

It looks like the records are all being updated (although there is nothing to update in this run)

Every time a tag is imported for an article, the existing row in the database is deleted and a new row is inserted. So there is no update when it comes to linking tags with articles.

Question, do you think I should be able to run the script against all records, and it will 'fix' the error that I'm having,

No this will not fix the duplicate entry error. We need to find what is causing this error.

or will I have to move them to different categories, then run the script? Note, when I move to a different category, I have to make sure all of my fields work with that category before the move, so I don't lose any data. I have about 20 fields.

If we can find the cause for duplicate entry error then i guess you don't need to move the category. The duplicate error is not because of the category but there is already an entry in database with same details. Can you run the below query in your phpMyAdmin and tell me how many rows you see?

SELECT * FROM `j17_contentitem_tag_map` WHERE `core_content_id`= 4098 and `tag_id` = 101;

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

I have 1 record in this result for tag_id = 101

I also ran this so you can see all of the rows...

SELECT * FROM `j17_contentitem_tag_map` WHERE `core_content_id`= 4098

type_alias core_content_id content_item_id tag_id tag_date type_id
com_content.article 4098 2538 51 2019-12-18 13:36:23 1
com_content.article 4098 2538 55 2019-12-18 13:36:23 1
com_content.article 4098 2538 96 2019-12-18 13:36:23 1
com_content.article 4098 2538 101 2019-12-18 13:36:23 1

please note, it seems I have 2 errors...

  1. Is the error from BEFORE, when I couldn't update my records, that is what I was referencing with the categories, any article in the category from before, got 'corrupted', so I can't edit the article without getting an 'error
  2. Once I ran the script for just my 22 records, WITH YOUR PATCH, I do not get the error on those records.
  3. The current error is just 'stopping' the program from running

Let me know what other queries I can run to assist.

thanks,
Laura

Author
  1. I REMOVED all tags from the record we are having an issue with
    Adjusted Charles, so he did not have any tags.

  2. Ran tags import again

  3. error: duplicate entry: 4118 for key primary

checked record:
added properly

  • admin staff
  • technical staff

did not add: associate professor

SELECT * FROM `j17_contentitem_tag_map` WHERE `core_content_id`= 4118

2 records:

Action	type_alias	core_content_id	content_item_id	tag_id	tag_date	type_id
com_content.article 	 4118 	 2538 	 51 	 2019-12-19 10:33:14 	 1
com_content.article 	 4118 	 2538 	 101 	 2019-12-19 10:33:14 	 1

His entry in my 'update list': (see last field, 3 tags should have been added for him) - last field is the tag

2538 	 Hedrick, Charles 	 charles-hedrick 	 people/staff 	 1 	 Charles 	 Hedrick 	 Charles Hedrick 	 LCSR Director 	 Core 217 	 (848)445-3088 	 mailto:hedrick@rutgers.edu 	 people/staff/technical-staff|people/staff/administrative-staff|people/affiliated-faculty/associate-graduate-faculty-member

Tag table listing:
id . parent_id . left rt . level . path
51 100 51 52 3 people/staff/administrative-staff
101 100 53 54 3 people/staff/technical-staff
96 94 37 38 3 people/affiliated-faculty/associate-graduate-faculty-member

could the error be because both tags that are being added have the SAME parent_id??? That is the only common thread...

thanks,
Laura

Support

Hello Laura,
Thank you for detailed explanation. I ran a test import with your tags and can reproduce the duplicate entry error issue. I have fixed it with the attached patch file. Can you give a try by loading the patch file? The patch file has the changes which i sent earlier so you just have to load this latest patch file for new changes. Let me know how your import goes.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Author

Excellent!

I ran test #2 with 23 records --> WORKED

  • my 'charles' record did not 'bomb' or error
  • I tested each of the articles and they can all still be edited

I will keep testing, and get back to you on my 'big test'.

thanks,
Laura

Support

Hello Laura,
Thank you for confirming that the patch is working. The fix will be included in our next RO CSVI release.

Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory

Log in to reply to this topic.