We have a content-type basic page in Drupal that has a date field. We use this code in a custom module to delete field collection data in Drupal 7. At Sreyas, we are well-resourced with Drupal developers who have vast experience in developing an application in the latest version of Drupal. Apart from Drupal development, we offer services in other CMS platforms like WordPress, Magento, Joomla, etc.
//Use a query to get all nodes of your particular content type. $results = db_query("SELECT nid FROM node WHERE type='your- content-type'"); $nids = array(); foreach($results as $result) { $nids[] = $result->nid; } foreach($nids as $nid) { //use for loop for testing $node = node_load($nid); foreach ($node->field_international_activity[LANGUAGE_NONE]as$key=> $value) { // Build array of field collection values. $field_collection_item_values[] = $value['value']; // Unset them. unset($node->field_international_activity[LANGUAGE_NONE][$key]); } // Delete field collection items. entity_delete_multiple('field_collection_item', $field_collection_item_values); node_save($node); }
Leave a Reply