5

I have a Feeds import set up to import products into Drupal Commerce (from csv). My product type has a number of term reference fields that also need to be assigned a value by import. Most of these work fine (e.g.: field_product_unit, field_product_discount_category), except one: field_product_group. I'm searching the taxonomy term by term name.

Importing the product group used to work at some point, but for some reason or other, it stopped working. Not a single value gets imported. I can't pinpoint when it quit on me. I don't see an obvious difference between the fields that do work, and the one that doesn't. The only slight difference is that product groups are hierarchical, and the other taxonomy lists don't use hierarchy.

I don't get any error messages or "I can't find this term" notices.

I've tried the following:

  • checked and double-checked the names of the terms matching the csv values: they do.
  • importing my taxonomy term name into a text field (to make sure it could find the input field): works fine.
  • my taxonomy lists all use multilingual names and descriptions. To avoid a mix-up there, I reset it to a single language: no difference

How do I proceed now? How can I figure out what's going wrong?

2 Answers 2

4

As a first step, you could check whether the field has been parsed properly:

In sites/all/modules/feeds/plugins/FeedsProcessor.inc:

Add debug($item) after line 180:

  public function process(FeedsSource $source, FeedsParserResult $parser_result) {
    $state = $source->state(FEEDS_PROCESS);

    while ($item = $parser_result->shiftItem()) {
       debug($item); // debug entry

      // Check if this item already exists.
      $entity_id = $this->existingEntityId($source, $parser_result);
     ...

debug() is a core function that lets you print out debugging information:

https://api.drupal.org/api/drupal/includes!common.inc/function/debug/7 and/or

http://blog.boombatower.com/drupal-7-debug-and-simpletest-verbose?utm_source=buffer&utm_campaign=Buffer&utm_content=buffer5ee6f&utm_medium=twitter

The result will be processed using drupal_set_message(), and will appear in http://example.com/admin/reports/dblog (probably, depending on your configuration).

You'll get one notice for each imported line, like:

User notice:

array (
  'title' => 'This is a test title',
  'body' => 'And a test body',
  'tax' => 'And a taxonomy term',
  '' => '',
)

Alternative: download (from http://drupal.org/project/devel, or drush dl devel) and enable the Development module (Devel in admin/modules), or drush en devel and use drupal_debug() or another tool from the devel module.

4
  • eww dblog :). you mean ddor drupal_debug from the Devel module right :) (i can't stare at the dblog in phpmyadmin its too small an area to view meaningful messages :D)
    – tenken
    Dec 20, 2013 at 0:01
  • no, I did mean debug(), clarified in my answer. drupal_debug is certainly an option as well.
    – Ursula
    Dec 20, 2013 at 0:41
  • Thanks for your help. I haven't had the time yet to try your suggestions - the company is closing for christmas holidays and our customers need everything done right away. I will make sure to get back to you though. Dec 20, 2013 at 13:25
  • YESSSSS! I found it! My taxonomy list turned out to contain orphaned child items (from a batch delete operation gone wrong) that were being selected instead of the terms in the hierarchy. I discovered this by calling debug() in taxonomy.inc for the found and not found terms. When all term were reported to be found, I thought to compare the found tid's to the ones I should be finding. Bingo! Now onto Google to find out how to kill the orphaned children. Jan 5, 2014 at 19:56
0

If the products are tagged with more than one group, the field won't be processed as singular terms because they will be arrays, right? I ran into this challenge recently and solved it with the Feeds Tamper Module.

On exporting my nodes from views as CSV files I chose the field "Taxonomy all terms" and chose the vocabulary. By default, Views will separate this field's multiple tags with a comma, but you can change the delimiter - I like pipes so I used them.

Then on your Feeds Import settings you can hit the tamper tab, and for that field, choose Explode. Tamper then will prompt you for the delimiter you chose, in this case, a pipe.

Hope this helps: https://drupal.org/project/feeds_tamper

1
  • Thankfully products can only belong to one group. Not that I won't try out the feeds_tamper module anyway; I've just tried to not have to get to know that one yet. Dec 20, 2013 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.