Skip to content

Instantly share code, notes, and snippets.

@MatthieuScarset
Created November 12, 2015 14:45
Show Gist options
  • Save MatthieuScarset/4709ec3bee691c1c7707 to your computer and use it in GitHub Desktop.
Save MatthieuScarset/4709ec3bee691c1c7707 to your computer and use it in GitHub Desktop.
Load all Drupal Commerce License
$q = db_select('commerce_license', 'l');
// $q->condition('l.type', your_type');
// $q->condition('l.status', 2); // 2 = active
$q->fields('l', array('license_id') );
$lids = $q->execute()->fetchCol();
$ls = entity_load('commerce_license', $lids);
dpm($ls);
foreach($ls as $l){
$info = $l->wrapper->getPropertyInfo();
if( ! $info['edition_start']['type'] ) {
dpm( 'erreur with license ' );
dpm($l);
}
else {
$edition = $l->wrapper->edition_start->value();
if( empty($edition) ) {
// $l->edition_start['und'][0]['value'] = 1;
// entity_save('commerce_license', $l);
dpm($l);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment