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