Referencing already existing files that are not managed within drupal's file_managed table can be done with the imce_filefield module. However, it will work on generic filefield and image widgets by default but not on the commerce file widget. This can easily be implemented by using hook_file_imce_filefield_supported_widgets_alter as stated here http://drupal.org/node/1960016. So by adding this code to the module, the IMCE for filefield will work out of the box:

function commerce_file_imce_filefield_supported_widgets_alter(&$widgets) {
  // $widgets is originally defined as array('file_generic', 'image_image'). Adding support for commerce file.
  $widgets[] = 'commerce_file_generic';
}

With that you will have the "Allow users to select files from IMCE File Browser for this field" when editing the commerce file field, and thus be able to add files that already exist on the server but are not managed by Drupal on the create/edit form. If the files are are not managed by drupal yet, the imce_filefield module will add it to the database with the proper scheme (private:// in the case of commerce file).

Comments

bojanz’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Active » Fixed
Issue tags: +possible-backport

Published 7.x-2.x (see https://drupal.org/node/1395488#comment-7658191) which doesn't have this problem, since it uses a regular filefield.

Tagging this for a backport (since this fix is easily committable to 7.x-1.x).

bohemier’s picture

Great work! thanks

Automatically closed -- issue fixed for 2 weeks with no activity.