/**
  * Default constructor for the Commerce License object.
  *
  * @param int $license_id
  *   License id if an existing license entity is to be loaded.
  */
 public function __construct($license_id = NULL)
 {
     $args = func_get_args();
     array_shift($args);
     $order_id = array_shift($args);
     if (is_null($order_id)) {
         $order_id = 0;
     }
     $order = commerce_order_load($order_id);
     if (!is_null($order_id)) {
         $license = commerce_license_get_order_licenses($order_id);
         if (!$license) {
             $this->setErrors("License for order id {$order_id} does not exist.");
             $this->setInitialized(FALSE);
             return;
         }
     }
     parent::__construct($license);
 }
 /**
  * This is helper function called inside createProgrammatically function will update organisation name in license
  * @param $order
  *  This is order object
  * @param $user
  *  This is user object
  */
 private function updateOrganisationInLicense($order, $user)
 {
     $licenses = commerce_license_get_order_licenses($order);
     foreach ($licenses as $license) {
         $license = entity_load_single('commerce_license', $license->license_id);
         $random_company_name = MPUtils::getCompanyName();
         $license->cle_name[LANGUAGE_NONE][0]['value'] = isset($user->field_organization_name[LANGUAGE_NONE][0]['value']) ? $user->field_organization_name[LANGUAGE_NONE][0]['value'] : $random_company_name;
         $license->synchronize();
     }
 }