1

I am trying to import some data by using feeds importer. I want to check if there is any information under "equivalent" Source in the sheet. If there is no value, just skip the import. If it has, continue and finish the import process.

I saw there is an event called "Before saving an item imported via Recommended Product Import(importer name)."

Does anyone have any idea about how can I set the condition and action parameter for implementing this rule?

This is one column from my sheet and rule sheet (you can see some products have equivalent, some do not have):

enter image description here

enter image description here

1 Answer 1

1

Thanks everyone, I got the answer. Instead of using Rules, I created a "custom feeds module."

Steps:

  1. Create a folder named "custom_feeds"
  2. Create two files, one is "custom_feeds.info", another is "custom_feeds.module"
  3. Add following information in the .info file:
name = custom feeds module
description =custom feeds module
core = 7.x
package = Feeds
dependencies[] = feeds</code>
  1. Add following code in the .module file inside <?php ?>:
function custom_feeds_feeds_presave(FeedsSource $source, $entity, $item) {
  // check that this is fired only for the importer being used
  if($source->importer->id=='recommended_product_import'){
     // "equivalent" is the column name in excel sheet
     if(!strcmp($item['equivalent'],"")){
       $entity->feeds_item->skip = TRUE;
     }
  }
}

Your Answer

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

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