I'm not sure if another module is conflicting and somehow hiding this functionality, but I was under the impression that it was available.

I am using the latest version of Feeds (7.x-2.0-alpha7). When configuring the mapping, Published date is available to me; Created date and Updated date are not. I was under the impression (from the issues queue) that these should be available.

Some details of configuration are:
Attached to: [none] (form). Import on submission.
Fetcher: SQL Fetcher
Parser: SQL parser (Feeds SQL module)
Processor: Node processor

Am I incorrect in thinking that Created date and Updated date should be mapping options, or am I missing something else?

I've searched the issues queue and upgraded the module without luck. I was going to use rules or dig through the code to circumvent the issue, but wanted to see if someone knew the solution. Thanks for any advice.

Comments

mrtoner’s picture

Bump. An explanation of *Published date* as it relates to the **target** is in order, as it is for *URL* and *GUID*. None of those fields is actually a visible part of the node and the documentation does not make it clear that if a site builder wants to make use of those data then additional fields need to be added to feed items.

Once this information is clarified (please!), this issue should be made a feature request.

Anonymous’s picture

Issue summary: View changes

I also have a use case for the created date. After migrating, all nodes have current date on "authored on", however, I need the authored on date to be the original 'post date' from my source. Any help is appreciated.

megachriz’s picture

Title: Mapping to 'created date' and 'updated date' not available » Add a mapper for Updated date (changed)
Version: 7.x-2.0-alpha7 » 7.x-2.x-dev
Category: Support request » Feature request

The mapper "Published date (created)" will map to "created", so that's one is already available. There isn't a mapper available for mapping to "Updated date (changed)". This would be a feature request.

sachinwable’s picture

This patch does it.

sachinwable’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: feeds-mapper-for-updated-date-1891404-4-D7.patch, failed testing.

sachinwable’s picture

What is the reason above patch is failed? It gets applied on my machine.

megachriz’s picture

The patch should be made against the Feeds repository, not against the Drupal repository.
I got these errors when trying to apply the patch:

error: sites/all/modules/contrib/feeds/feeds_import/feeds_import.feeds_importer_default.inc: No such file or directory
error: sites/all/modules/contrib/feeds/feeds_import/feeds_import.test: No such file or directory
error: sites/all/modules/contrib/feeds/plugins/FeedsNodeProcessor.inc: No such file or directory

ashrafabed’s picture

sachinwable, you'll have to create a repository with only the (latest dev version of the) feeds module in it, rather than your whole website in it:

git clone --branch 7.x-2.x http://git.drupal.org/project/feeds.git 
cd feeds

Then create the patch from that repository, and it should pass.

twistor’s picture

This won't work anyway, since node_save() sets the changed time. The patch would have to manually set the updated time with a separate db call, after save() is called.

This sounds like a no-go.

sachinwable’s picture

This should pass now. Its working as expected.

sachinwable’s picture

Status: Needs work » Needs review
sachinwable’s picture

Status: Needs review » Needs work

The last submitted patch, 11: feeds-mapper-for-updated-date-1891404-11-D7.patch, failed testing.

sachinwable’s picture

Status: Needs work » Needs review
StatusFileSize
new2.51 KB
sachinwable’s picture

Assigned: Unassigned » sachinwable

Status: Needs review » Needs work

The last submitted patch, 15: feeds-mapper-for-updated-date-1891404-15-D7.patch, failed testing.

sachinwable’s picture

Status: Needs work » Needs review
StatusFileSize
new1.81 KB

Updating label in .test file causes failure in test? Have removed it.

Status: Needs review » Needs work

The last submitted patch, 18: feeds-mapper-for-updated-date-1891404-18-D7.patch, failed testing.

The last submitted patch, 18: feeds-mapper-for-updated-date-1891404-18-D7.patch, failed testing.

sachinwable’s picture

Status: Needs work » Needs review
StatusFileSize
new2.49 KB

Status: Needs review » Needs work

The last submitted patch, 21: feeds-mapper-for-updated-date-1891404-21-D7.patch, failed testing.

sachinwable’s picture

StatusFileSize
new2.46 KB
sachinwable’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: feeds-mapper-for-updated-date-1891404-23-D7.patch, failed testing.

sachinwable’s picture

Status: Needs work » Needs review
StatusFileSize
new1.73 KB

Status: Needs review » Needs work

The last submitted patch, 26: feeds-mapper-for-updated-date-1891404-26-D7.patch, failed testing.

twistor’s picture

Why are you changing the feeds_import feature?

Also, please address #10. I'm open to any clever ideas.

jchmura’s picture

Is there any way to work around this issue, so that the "updated" date reflects the date that it was last updated prior to import? Otherwise, all forum topics include "Edited by: username on 08/17/2015 - 00:08 Reason: Created by FeedsNodeProcessor" Has anybody been able to solve this problem?

megachriz’s picture

Status: Needs work » Needs review
StatusFileSize
new3.11 KB

Here is a patch with a possible implementation:

  1. When mapping happens, the value for "changed" is set to $node->feeds_changed instead of $node->changed, since the property "changed" will be overwritten upon a node save call.
  2. Since the node module sets the "changed" property node before invoking the presave hooks, this property can be set in feeds_node_presave():
    // Update "changed" value if there was mapped to that.
    if (isset($node->feeds_changed)) {
      $node->changed = $node->feeds_changed;
    }
    

An other possible implementation is to add an extra database call - like twistor suggested in #10 - to FeedsNodeProcessor::entitySave(). The current implementation however, saves the need for that extra database call.
An alternative of setting $node->feeds_changed is to set a value on the $node->feeds_item object.

A test method called testChangedTarget() is added to the FeedsRSStoNodesTest test class to ensure mapping to "changed" works as expected. It's debatable if this test should perhaps be moved over to an other test class, since it uses a CSV as a source instead of a RSS feed as the class name suggests.

filsterjisah’s picture

Status: Needs review » Reviewed & tested by the community

Tested: after selecting via UI, "changed" timestamp gets correctly mapped.

twistor’s picture

Status: Reviewed & tested by the community » Needs work

Could we do the $node->feeds_item change? It's not a huge deal, but it lowers the risk of conflicting with another attribute named feeds_chagned. I know feeds is our namespace, but it seems safer to me.

Other than that, this is exactly the clever solution I was hoping for, awesome.

megachriz’s picture

Assigned: sachinwable » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.14 KB
new1.08 KB

The value for the node's "changed" property is now temporary stored on $node->feeds_item->node_changed. I named the property on the feeds_item object "node_changed" to avoid eventually future collisions, should the feeds_item table ever get a "changed" column. And also to make it clear that the value is meant to be set on the node object.

jenlampton’s picture

Status: Needs review » Needs work

I've applied the patch, and can now see 'Modified date' in addition to 'Published date' but when I import data into this field the 'Updated date' on my node is not being set.

Question - is the 'Modified date' supposed to be the same thing as the 'Updated date'? If so, can we please change the names to match?

If not, let's please change the title of this issue :)

jenlampton’s picture

edit: deleted duplicate post.

megachriz’s picture

Status: Needs work » Needs review
StatusFileSize
new3.16 KB
new689 bytes

Good suggestion, jenlampton. I've changed the label from 'Modified date' to 'Updated date', since Views also uses this label for the same thing. Patch is also a reroll.

Note that when a node is resaved after the import, the value set by Feeds for 'Updated date' will be lost. The node module always sets this value to the current time when a node is saved, regardless if this happened programmatically or by an user's action.

If this patch still passes tests, I think this is ready.

twistor’s picture

+++ b/plugins/FeedsNodeProcessor.inc
@@ -239,6 +239,9 @@ class FeedsNodeProcessor extends FeedsProcessor {
+      case 'changed':
+        $target_node->feeds_item->node_changed = feeds_to_unixtime($value, REQUEST_TIME);
+        break;

Can we get a comment here saying that this value will be set in feeds_node_presave()?

megachriz’s picture

Good suggestion, twistor. I added a comment to the above specified code.

twistor’s picture

Status: Needs review » Reviewed & tested by the community

  • MegaChriz committed cb7f5c6 on 7.x-2.x
    Issue #1891404 by MegaChriz, twistor, jenlampton: Add a mapper for...
megachriz’s picture

Status: Reviewed & tested by the community » Fixed

Committed #38. Thanks all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.