I'm trying to import an cvs file with explode feeds tamper function, but can't get it to work, Do need to do something more then setting up the tamper rule and check the checkbox on the import page? (tried both alpha and dev version)

CVS file

Title, Body, CCK Multi field
A, Text1, row1||row2||row3
B, Text2, row1||row2||row3

This error also gets displayed (with latest dev)

Warning: Invalid argument supplied for foreach() in feeds_tamper_feeds_after_import() (line 88 of /sites/all/modules/feeds_tamper/feeds_tamper.module).
CommentFileSizeAuthor
#21 CSV.txt279 bytesjlhs
#4 feeds_tamper.module.patch673 bytesDave Kopecek
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

twistor’s picture

Assigned: Unassigned » twistor
Status: Active » Postponed (maintainer needs more info)

Is this still a problem with the latest version?

Dave Kopecek’s picture

I'm having a similar issue:

warning: Invalid argument supplied for foreach() in <removed>\sites\all\modules\feeds_tamper\feeds_tamper.module on line 85.

I'm also importing CSV data. Note that this data is being imported to at data table. The feed importer is not attached to a node. Line 85 in feeds_tamper_feeds_after_import is:

85: foreach ($store[$importer->id][$source->feed_nid] as $guid => $references) {

There's a reference here to feed_nid. Line 85's loop is building up to a node_save(). Since this importer is saving to a data table this might be the issue.

Dave Kopecek’s picture

Fixed it - I think:

Added test for $importer->process instance type:

if ($importer->processor instanceOf FeedsFeedNodeProcessor ) {

To feeds_tamper_feeds_after_import:

/**
* Implementation of hook_feeds_after_import().
*/
function feeds_tamper_feeds_after_import(FeedsImporter $importer, FeedsSource $source) {
 if ($importer->processor instanceOf FeedsFeedNodeProcessor ) {
  $store = variable_get('feeds_tamper_node_references', array());
  foreach ($store[$importer->id][$source->feed_nid] as $guid => $references) {
    $query_s = "SELECT nid from {feeds_node_item} WHERE guid = '%s'";
    $node = node_load(db_fetch_object(db_query($query_s, $guid))->nid);
    $i = 0;
    foreach ($references as $ref) {
      $nid = db_fetch_object(db_query($query_s, $ref))->nid;
      $node->field_ref[$i]['nid'] = $nid;
      $i++;
    }
    node_save($node);
  }
  variable_del('feeds_tamper_node_references');
 }
}

Dave Kopecek’s picture

FileSize
673 bytes

Patch for #3

twistor’s picture

Status: Postponed (maintainer needs more info) » Fixed

I ended up just removing that stuff.

http://drupal.org/cvs?commit=489868

Status: Fixed » Closed (fixed)

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

Ayesh’s picture

Title: Can't get explode to work with CVS parser » Can't get explode to work with CSV parser
Status: Closed (fixed) » Active

I'm still having the problem. I didn't patch yet but I thought it would work as promised.
For multi-value text field, I created a CCK text field with unlimited and 10 fields(tried both).

Please show me a direction.

johnv’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Category: support » bug

Subscribe, doesn't work on D7 either.

johnv’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Category: bug » support

sorry, tampered the wrong field. Works very nice in D7!

mattbk’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

I am having this issue with D7 version as well.

mattbk’s picture

Okay, my problem was fixed with this patch: http://drupal.org/node/1062744#comment-4259728

robin.prieschl’s picture

I am having a similar problem with version 6.x-1.0-beta2. Also installed the dev release with no luck.

Has anyone gotten this to work in Drupal 6. I cannot import to Keywords as it imports them as 1 keyword and the other is I have a multiselect select field and it is not selecting multiple options. These are both in the same import.

inversed’s picture

I seem to be having this problem using the latest 7.x dev version when importing to a taxonomy term reference field in a node using the Feeds node processor. The tamper is getting ignored with no error message. The node stores the imploded contents of the field to the taxonomy.

Any ideas?

jlhs’s picture

I so badly need to add attach multiple taxonomy terms to nodes and products I have. With no success. (Using Drupal 7, Feeds Dev, Feeds Tamper Dev.)

1. I have added tamper module to my tags column for my CSV file and chosen explode.

2. I have set the limit input area to 3 (Supposing that was the maximum number of tags I would have) Or is that not how it works.

3. Then tested with two taxonomy terms in the CSV tags column, comma separated.

4. Uploaded the CSV file via feeds only to get failure, the first term was inserted into the node. The second term was not.

5. Tried using || twin pipes to separate the taxonomy terms and changed the setting to || twin pipes in feeds tamper module for my tags/taxonomy terms.

6. Still no success. I always get only the first term out of the multiple terms added, the rest are discarded : \

Regards from Josh. Hope to be able to use what looks like a 'brilliant' module if this could be sorted out : \

jlhs’s picture

Does anyone know how to get tamper (Explode function) to be able take comma separated tags out of a single column so they end up attached to a node properly and not just one out of the multiple terms but all the comma separated multiple terms or is this a severe crippling bug that only allows one taxonomy term through and not the others?

johnv’s picture

jlhs, I have no problem using Feeds Tamper. Are the other fields in your import file imported correctly?
- Did you first try an import (of more then one node) with only single-term fields?
- The normal delimiter in your file should not be a comma (because you use it for the multi-term)
- make sure you set the correct delimiter in 'CSV parser'
Some other problems I encountered previously:
- make the first column a dummy column
- do not use space or underscore in your column title.

jlhs’s picture

Thankyou John.

I went though and tried all your suggestions. But for me, I do not get any success unfortunately. No matter what I only get a single term come through.

Thanks for sharing and I am glad you have had taxonomy success.

jlhs’s picture

Hi John,

I got multiple comma separated taxonomy terms to work by setting the the explode function of tamper to 0

Very happy : )

dimitriseng’s picture

@ jlhs, johnv and all, I have tried your suggestions above also with the dev version and I stil cannot get this to work, only the first term is imported. Would you please be able to list the steps you took in order to get this to work and possible an exampllextract of your csv file?

@jhls, you mention that you managed to get this to work by "setting the explode function of tamper to 0", what do you mean by that? Do you mean the limit? When I set this to 0, it is changed to 1 as per the design. I have tried various values but nothing works.

Any help would be appreciated, thank you.

rfay’s picture

I have no trouble using this with CSV. There's a video of an import using Feeds tamper at http://vimeo.com/25722743

jlhs’s picture

FileSize
279 bytes

Hello dimitriseng,

I have attached a CSV file in the style I use, saved as a text file so I could attach it. With simple comma separation all the way through works fine with feeds tamper nothing fancy here. I not even using a semi colon to separate, commas all the way through with the obligatory quotation marks around the content of each column.

String separator (As Comma)
,

Limit
1

That is all

You are right: If you put in zero you will find the setting is automatically changed to 1, so putting in 1 should do the same thing. I did not know this at the time of posting.

If it doesn't work the first time delete the tamper setting and then try the tamper setting a fresh, thats what I did.

I am running the latest DEV version of Feeds, latest DEV version of Tamper and latest DEV version of Drupal Commerce Feeds.

That is all.

See attached CSV layout.

dimitriseng’s picture

@ rfay. Thanks for pointing me to those very useful videos.

@ jlhs. Thank you for the detailed explanation. I have deleted and recreated everything and I managed to get multiple tags imported.

@ all. However, I noticed the following 2 things which might require further investigation, so I provide some more information below in case this is of interest to somebody.

* In the Feeds importer's settings, if I select "Replace existing nodes" then this works as expected and all specified tags are assigned correctly to the node. However, if select "Update existing nodes", in my case if during an update I set a different tag to the node then the new tag is added to the node, but the old one is still selected, which is not the expected behaviour. I am not sure if this would be a Feeds or a Feeds Tamper issue. If this is working for anybody please let me know as I might be doing something wrong...

For example, if at the first update I assign "tag1,tag2" to a node, then this is done properly. If for the second update I set "tag3,tag4", if I select "Replace existing nodes" then tag3 and tag4 will be assigned to the node. If I select "Update existing nodes" then the node ends up having all of tag1, tag2, tag3 and tag4 assigned...

* In the Feeds Tamper configuration for the explode plugin, I would expect the "Limit" to work as described, which the way I understand it is that if I set this to 1, then the string should be considered as only 1 tag irrespective of how many I have specifed, but however, if I set it to 1 or 10, the behaviour is the same, if I have more than 1 tags then they will be considered as separate tags and exploded by FT.

rfay’s picture

I'm actually having this problem right now with a node import (and taxonomy terms)

rfay’s picture

We resolved the problem by updating to latest dev. Accidentally had the latest stable.

It's probably time for a release on this fantastic module.

Summit’s picture

Subscribing, +1 for release!
greetings, Martijn

wizonesolutions’s picture

I'm on 6.x-1.x experiencing the same issue...have tried changing the delimiter for the tags to a semicolon, but no luck. Continuing to fiddle with it.

wizonesolutions’s picture

Oh, it seems my tamper plugin won't enable! o_o researching...

wizonesolutions’s picture

Still getting this even after resolving other issue...a real puzzler. When semicolon-delimited, it doesn't even explode them. When comma-delimited, the commas are removed and it becomes one long tag.

jlhs’s picture

I had to reinstall Drupal,

Now have set up tamper,

with latest dev version of tamper, latest dev of feeds and latest dev of commerce feeds. Tried everything inbetween, reinstalled. Tried it all yada yada. to sit here for hour while food burned on the stove without success.

No matter what, I can only get one taxonomy term to come through, when I need around 3 taxonomy terms per item to come through.

This is such a huge crippling issue.

jlhs’s picture

Ok, I found the problem.

I had made a new vocabulary in Drupal,

I had set Number of values in field setting for taxonomy vocabulary to 1 the standard setting unchanged.

I set that to unlimited and the problem is solved. Everything is working as it should be.

Worth checking this if you are not getting multiple taxonomy terms through.

twistor’s picture

Status: Active » Fixed

CSV parser should be working fine in both devs. Other problems should get their own issue.

wizonesolutions’s picture

Just discovered that explode is not my issue; the issue is that by the time the plugin received the field, it is empty for some reason!

Bizarre since a single tag is definitely entered into the node...I don't even know how to classify this issue. I'm trying to identify the call stack via Xdebug so I can see if I can figure out where things break down.

twistor’s picture

@wizonesolutions, What is the parser/source you're mapping from?

wizonesolutions’s picture

What a strange issue. Probably a fail from me not reading the documentation. I had some uppercase characters in my source field names. This caused some problems. Changing them to lowercase made birds sing and butterflies flutter. Plus, my explode plugin then functioned.

Definitively fixed for me. Documenting this here in case someone needs it.

wizonesolutions’s picture

@twistor It seems I figured it out before I saw your comment. I was mapping from a CSV, if that's what you mean? Yeah, it'd be the CSV parser. Feeds works fine with it, but in the FeedsSource (I think it is) object it keys the fields with munged names. It lowercases them, for one; dunno what it does with spaces. But that was my issue. I discovered it by using Xdebug and digging in to see what the value was. dpm($source) wouldn't tell me for some reason! Just came up blank.

Status: Fixed » Closed (fixed)

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

dimitriseng’s picture

Status: Closed (fixed) » Needs work

I am using Feeds 6.x-1.0-beta11 and I have upgraded Feeds Tamper to beta4. I am still getting the issues mentioned in my comment #22. Using the CSV parser, everything seems to be working ok when setting to "Replace existing nodes", but I am still getting the issue described in #22 when setting to "Update existing nodes".

I set this back to "needs work", unless somebody can confirm that this is working for them, thank you.

jlhs’s picture

Hello dimitriseng,

Have you set the number of values in your field setting for taxonomy vocabulary to unlimited?

If it is still set to the default of 1 then you will only ever get one term coming through.

Realised this was something I had to watch out for and remember when setting up products or nodes to work with feeds.

dimitriseng’s picture

Hi jlhs, thanks for the quick reply.

In #22 I mentioned 2 issues. I had resolved previously the issue you mention above using the procedure you describe in #37.

However, I am still having the other issue, which I have copied again here:

Copied from #22:

"* In the Feeds importer's settings, if I select "Replace existing nodes" then this works as expected and all specified tags are assigned correctly to the node. However, if select "Update existing nodes", in my case if during an update I set a different tag to the node then the new tag is added to the node, but the old one is still selected, which is not the expected behaviour. I am not sure if this would be a Feeds or a Feeds Tamper issue. If this is working for anybody please let me know as I might be doing something wrong...

For example, if at the first update I assign "tag1,tag2" to a node, then this is done properly. If for the second update I set "tag3,tag4", if I select "Replace existing nodes" then tag3 and tag4 will be assigned to the node. If I select "Update existing nodes" then the node ends up having all of tag1, tag2, tag3 and tag4 assigned..."

I can get the functionality required by selecting "Replace Existing Nodes" but I think that it would be great if we could also get the "Update existing nodes" to work.

Can you or anybody else try this by using "Replace Existing Nodes" to confirm if this is working as expected or not? Thank you again.

tonkatuph’s picture

I must be doing something wrong. I'm following all the steps the best of m knowledge and I still end up with one taxonomy term rather than having multiple terms. For instance:

"partNum","make","model","description","price","title","image","years"

"AT11820","Kia","Sorento","12 Piece Accent Trim","125","2011-2012 Kia Sorento 12 Piece Accent Trim","http://www.qaausa.com/images/sorento/at11820.jpg|Kia Sorento Accent Trim|Kia Sorento Accent Trim","2011,2012"

I try to explode the years but they always come up as one term instead of two separate terms. I've patched and used feed tamper to no avail, I need further assistance.

Using latest release on drupal 7.

tonkatuph’s picture

I think I got it to work. My goal was to have the "years" be separate terms. It seems like the feeds tamper explode feature was not working for me. I tried "2011,2012", but it would output as one term. So I tried having different years such as year1 year2 year3 ect ect and targeting them into the years when mapping and it seems to work.
Any thoughts?
Thank you.

Summit’s picture

Hi,
Could it be that feeds tamper has problems with numbers?
Greetings, Martijn

criznach’s picture

I can confirm that the field names must be lower case. Stepping through the code you'll see a comparison that fails due to case, just before feeds_tamper tries to call the plugin callback. This affects more than just explode... None of my tamper plugins were running at all until I fixed this. Spaces didn't make a difference with the CSV parser for me, but Mixed Case definitely broke things. Multiple taxonomy terms are now working.

yang_yi_cn’s picture

@criznach can you point out which line is having that issue?

criznach’s picture

It's been a while since I looked at it, but I think it's line 56 in 6.x-1.0-beta4+14-dev (2012-Apr-24)

$is_array = is_array($item[$element_key]);

That check fails because $element_key is always set to lower case on line 42:

$importer_instances[drupal_strtolower($element_key)] = $instance;

yang_yi_cn’s picture

ok, I can confirm that this is still an issue in feeds_tamper.module

function feeds_tamper_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
...
  foreach ($importer_instances as $element_key => $instance) {
    if (strpos($element_key, 'Blank source ') === 0) {
      $blank_mappings[] = $element_key;
    }
    // Special case for FeedsCSVParser.
    elseif ($csv) {
      unset($importer_instances[$element_key]);
      $importer_instances[drupal_strtolower($element_key)] = $instance;
    }
  }

  $plugins = feeds_tamper_get_plugins();
  foreach ($result->items as $item_key => &$item) {
    // Add the blank sources to the item.
    foreach ($blank_mappings as $blank) {
      $item[$blank] = '';
    }
    foreach ($importer_instances as $element_key => $instances) {
      if (isset($item[$element_key])) {
        foreach ($instances as $instance) {
          $plugin = $plugins[$instance->plugin_id];
          $is_array = is_array($item[$element_key]);
...
yang_yi_cn’s picture

does anyone know what the first lowercase do?

criznach’s picture

It looks like this was a decision made in FeedsCSVParser, and feeds tamper converts to lower case for compatibility. In the 6.x release of feeds, the FeedsCSVParser class explicitly converts header columns to lower case. See the parseHeader() and getSourceElement() functions.

A quick fix might be to convert the feeds_tamper_feeds_after_parse() $item array keys to lowercase. Then you may have collisions if there are similar keys that only differ by case. And it's passed by reference so this might mess something else up down the line. Maybe test against a lower cased copy of the keys.

The most robust fix would be to change FeedsCSVParser to respect case, then feeds tamper could remove the drupal_strtolower() calls. But... This might break existing imports after an upgrade. Not sure why they made the decision to convert to lower, so I don't know if this is doable.

criznach’s picture

Duplicate? Unfortunately it's been postponed so the fix might need to be in feeds tamper for now.

http://drupal.org/node/1133724

twistor’s picture

Assigned: twistor » Unassigned
Status: Needs work » Closed (fixed)

This should not have been re-opened.