Hi there,
why this module doesn't work in a order file field?
I'm using Ubercart 3 and Drupal 7

Thank you in advance

CommentFileSizeAuthor
#8 2040889-entity-hooks.patch3.59 KBlongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Project: File (Field) Paths » Ubercart
Version: 7.x-1.x-dev » 7.x-3.5

Because for some odd reason the creation of an Ubercart order doesn't trigger hook_entity_*(), which implies that it's not really a valid entity or it's doing something weird that doesn't let other contrib play nicely with it.

In either case, it's Ubercarts problem (until proven otherwise) and there's not much I can do to help.
Cheers,
Deciphered.

TR’s picture

Category: bug » support

If you're talking about Ubercart file downloads, Ubercart doesn't use File fields for that because those wouldn't allow us to control access and download limits like we need to for a paid file download.

Deciphered’s picture

Category: support » bug

No, he's talking about attaching a File based field to the Order entity, or atleast that's what I did based of his issue. I can't say why one would do that, just that it should work.

Basically, add a File field to the Order entity with some File (Field) Path settings, then manually create an order, if hook_entity_insert or hook_entity_update where being triggered the file would get renamed as per the configuration, but in my local testing neither hook was being called on the creation of the order, which is very odd, because all Entities trigger these hooks.

longwave’s picture

Status: Active » Postponed (maintainer needs more info)

@mavdiablo: Please give more details on your problem, including steps to reproduce - you presumably added a file field to an order, where did you then try to use this field? Include URLs and any configuration changes you made.

mavdiablo’s picture

I'm sorry.
I posted my question in the wrong place.
I had to post it on the module file (field) paths.
When a user complete an order, the administrator should be able to upload a file in order entity by the administration side and the user is able to view it in his order history.
Unfortunately, when the administrator loads the file, the rules set by file field paths module are not applied.

longwave’s picture

Title: Uc order field upload » File (Field) Paths module does not work when file is attached to an order
Status: Postponed (maintainer needs more info) » Active
Deciphered’s picture

Title: File (Field) Paths module does not work when file is attached to an order » hook_entity_update/insert/* not invoked by manually editing/creating uc_order

You should keep in mind that File (Field) Paths not working is just a symptom of a greater issue. Any module that relies on hook_entity_update/insert/etc will also fail in this scenario, not just File (Field) Paths.

longwave’s picture

Status: Active » Needs review
FileSize
3.59 KB

The attached patch adds the entity presave, insert, update and delete hooks, including a test borrowed from entity module. I haven't actually tested this with Filefield Paths, if someone can do this and confirm it works it can be committed.

longwave’s picture

Status: Needs review » Fixed

Briefly tested this with Filefield Paths, files attached to orders are correctly moved and renamed now where they were not before. Committed.

Status: Fixed » Closed (fixed)

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