This is my first Drupal issue, so I apologize if I'm doing it wrong. Please tell me how to correct it.

I have spent two hours trying to track down a root cause for an issue with option_images. I've applied the patch to show image previews on the product screen and I'm using option_images 6.x-1.x-dev.

This problem is intermittent, which makes it difficult. Some of my products and attribute sets work great, and some do not. I cannot tell why. The ones that work have a populated $node->option_images array. The ones that do not work do not have this array filled (see the debug output near the bottom of the first screenshot).

I can view the filesystem of the webserver and see that images are uploaded to default/files/option-images.
Also, I can see the option images in the preview on the edit product page.

I have searched through existing issues on this site and have not found a fix.
I am absolutely stumped.

This thing is pretty kickass otherwise, btw. Thanks :)

Any ideas?

Screenshots:
product edit
result (note debug output with no option_images array)

Comments

SimpleAsCouldBe’s picture

Issue summary: View changes

trying to get inline images to work

SimpleAsCouldBe’s picture

Issue summary: View changes

that didn't do it :)

SimpleAsCouldBe’s picture

Issue summary: View changes

trying again

SimpleAsCouldBe’s picture

Issue summary: View changes

images!

SimpleAsCouldBe’s picture

StatusFileSize
new43.27 KB

Update: The module does seem to be querying the database. (screenshot). Too many times though. I see 4 queries for 4 different images, but I only have two option_images for this product. The images it is querying the db for are from a different product which has a different attribute set assigned.

queries.

SimpleAsCouldBe’s picture

I logged out the behavior of uc_option_image_nodeapi and calls to uc_option_image_load.

Here is the difference between working and non working calls:

working

option_image: hook_nodeapi(): $op: load
option_image: load
option_image: 45
option_image: 45
option_image: 45
option_image: 45
option_image: hook_nodeapi(): $op: view
option_image: view
option_image: 379
option_image: 379
option_image: 379
option_image: 379
option_image: 88
option_image: hook_nodeapi(): $op: alter

not working

option_image: hook_nodeapi(): $op: load
option_image: load
option_image: hook_nodeapi(): $op: view
option_image: view
option_image: hook_nodeapi(): $op: alter

After further investigation, I've discovered that my problem attributes are not in the $enabled_attributes variable. How on earth do they get there? I see no UI option to enable this...

$enabled_attributes = variable_get('uc_option_image_attributes', array());

SimpleAsCouldBe’s picture

Oh dear god. This is it: http://drupal.org/node/1087492

After hours turning into days of digging through code entrails... I love when Drupal saves me work, but sometimes the settings are so hidden it causes absurdity like this.

Specifically, attributes must be enabled: /admin/store/settings/attributes

SimpleAsCouldBe’s picture

I think this should be filed and fixed as a 'usability bug'. I am embarassed to have spent so much time hunting this down as a code bug, but I can't be the only one (just the only one who's publicly recorded the process). What threw me off is that it lets me add and preview option images--why wouldn't it show them? Must be a bug, right?

I suggest:
* disable the uploading and preview of option images for attributes that are not enabled for option images.

SimpleAsCouldBe’s picture

Issue summary: View changes

clarification