1

I have a Feed which imports data from a CSV file. I import data of products, namely title, price, category, etc. However, in order to provide a friendly URL, I send a customized field, which is in different languages and completely verbose, for example: Shoes for female scientists. I want to use this description as part of the clean friendly URL, so I would need to use some function like pathauto_cleanstring(). However, the update takes ages to complete. Is there a faster way, for example directly on import?

This code is executed on a call to mymodule_cronapi via Elysia Cron, and through curl PHP function:

   $results = db_query('SELECT nid, title FROM node WHERE type= :product', array(":product" => "product") );
    foreach($results as $row){
        $node = node_load($row->nid);
        $node_wrapper = entity_metadata_wrapper('node', $node);
        $node_wrapper->field_product_url->set(pathauto_cleanstring($row->title));
        $node_wrapper->save();
    } // foreach

1 Answer 1

1

You should be able to use Feeds Tamper to create your URLs based on values in your CSV: https://www.drupal.org/project/feeds_tamper

1
  • But I don't see nowhere in the GUI where I can choose pathauto_cleanstring or equivalent, which is what I need. URLencode or URLdecode won't do the trick, and the raw regular pattern probably won't either.
    – Cesar
    Nov 16, 2016 at 7:20

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.