Hi,

Is there a plan about to port to D7?

Recently I got a D7-compatible version from some upgrade tool, want to share it with maintainers.

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

latulipeblanche’s picture

Title: Port to D7? » Port to D7 + Commerce ?

... and is there a plan to make the D7-compatible version also compatible with Drupal Commerce ?

pillarsdotnet’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Needs work

Patch no longer applies.

I created a 7.x-1.x branch and ran Coder Upgrade on it. The result is untested as I no longer use uc_option_images on any of my sites, but at least it provides a starting point.

See 7.x-1.0-alpha1 release.

latulipeblanche’s picture

Tnx a lot, I hope that someone is able to make it a Commerce _Option_Images.
Paul

Babalu’s picture

d7 version of uc_option_images depends on imagecache, but imagecache is in drupal 7 core

kristin.e’s picture

@ Babalu - I can't see a d7 realease of option images. do you have a link to something?
kristin.e

christelle41’s picture

After a first installation test on the 7.x-1.0-alpha1 release, some problems appeared :

  • In the .info file, dependancy on imagacache is mentionned but this is part of d7 core.
  • After enabling the module, an error sql message : "Base table or view not found: 1146 Table 'atoutecho.files' doesn't exist". Indeed, in the .install file in line 15, the table "files" is mentionned, whereas in d7, its equivalent is named filed-managed

I'm getting on testing this release and try my best to get it work.

Babalu’s picture

@ kristin.e - View all releases

p4trizio’s picture

I got same errors as #6

Poieo’s picture

Subscribing.

rofsky’s picture

+1 on #6, I removed the dependency on the .info file, then renamed the files references to file_managed. Looks like there is an issue with how hook_node_load.

Inspecting the $node object within the function shows that the version id is passed as an array index outside the node object.

hook_node_load is expecting an array of nodes.

It looks like the 6.x version expects 1 node. Whats odd is the 7.x alpha branch uses the 7.x syntax for the hook, but is expecting only 1 node.

I wrapped the inside of the uc_option_image_node_load in a for each, it got rid of that error, but then I had some errors later on in the files.

Has anyone else had any luck with this module? Is anyone else working on it?

Message me if you would like to work on this together or start a more current branch for 7.x

samgreco’s picture

Anything happening with this module? Could really use it. Unfortunately I have no coding skills.

kiwi_steve’s picture

Same as above... keen to use it, but I don't have the knowledge to easily jump in and help at this point.

aacraig’s picture

FileSize
5.75 KB

I've done a proper port of this module to D7.

I've taken the liberty of rewriting the module completely, in order to take full advantage of the many changes in the UC and D7 APIs.

The functionality of the module remains unchanged except as follows:

  • Form placement may differ to better fit the UC3 workflow
  • The default image has been removed, as it is usually the first thing to be configured, and I don't know of any sites using the default image in production. Instead, the module shows no image for attributes that haven't been configured to show an image.
  • Default settings may be set at the attribute level, and options and individual product instances will use those defaults if the setting isn't overridden.
  • I have added the ability to show the option images inline with the option selection element, or when selected, or both. The image style displayed may be set separately for both modes.

I hope this is useful to everyone, and that D7 sites can now also enjoy this great and useful module!

aacraig’s picture

FileSize
5.89 KB

Left behind a debug print statement.

This is a clean version.

aacraig’s picture

FileSize
5.87 KB

Final version, I hope :)

This corrects an error in hook_schema which didn't come out until I installed the module on another site.

aacraig’s picture

FileSize
5.98 KB

Sorry for the barrage of updates, but as I install and use the module on a soon-to-be-in-production site, I'm finding small improvements and bugs to fix.

Poieo’s picture

@aacraig - Thanks for all your work getting this ready for D7!

Couple questions:

It appears the option images only work for radio style select lists. Is this intentional? I believe the D6 version worked with select lists as well.

You have the same form on both the attribute edit screen and the option edit screen. It would seem to be more clear if you only had the display options on the attribute edit screen and the image field on the option edit screen.

aacraig’s picture

The last version of the module I attached works for all methods except text input, at least that's the intention, and if it doesn't, that's a bug.

From a functional point of view, you can actually set any setting at any level, and then override later on -- that is, you can set the image style in the attribute form, then later on set an image in the option form, then, for a single product, you could actually override both and have a single product display with a different image style and image.

The UI reflects that functionality, which is why the form is the same for all three.

Poieo’s picture

Thanks for the feedback on the UI.

Regarding the selection method, everything works great for radio buttons. But, as soon as I change to a select this all the image disappear. I can see the div that is supposed to contain them, but it's empty.

aacraig’s picture

For the select element, make sure you've activated "selected display". It won't show the images inline in the select drop down, as that's not part of the HTML standard, and only Firefox supports images in options, as far as I know.

With selected display activated, the selected option's image will display.

Anonymous’s picture

Thanks so much for your work on this @aacraig, it's working nicely for me.

We're displaying available colours in a grid, so I'd love to have each option image filename included in the $node->attributes array, but perhaps it's wishful thinking. I can work around it.

jake.litwicki’s picture

Spectacular work aacraig. You should make an official release because I personally see this as invaluable, I can only imagine countless others would as well.

norbert.broadsword@gmail.com’s picture

Absolutely outstanding! Couple of things I've noticed - I had already created a list of options (Called Label Image) and then installed the module. I then dutifully uploaded images in "Option Images for Label Image" where you get the list of options. Despite uploading al the images, they didn't appear. I had to actually go into Store, Attributes and then upload the images individually to each option. No big deal though.

Also, is there any way that the label text can be hidden? In my case, the shopper is actually choosing an image so there is no need to actually display the text of the label, only the image and the radio button. I've been banging my head over this all afternoon!

How difficult would it be to make the label display optional (I'm no coder so that might be a daft question!)

Thanks very much for porting this across to D7!

aacraig’s picture

You should be able to upload images in any one of three places -- the attribute form, the option form or the option form for a single product. The image that displays will be the most specific of the three for the given product.

If you can explain in more detail (URLs of the pages you do the uploading on, for instance) what you did that didn't work, I can help you more.

As for hiding the label text, that's a great idea. However, I'd like to see this port become an official release, so that issues can be properly opened and categorized before doing any further development.

kerrymick’s picture

I actually can't save the images on the product page under the options tab. When I try it throws the following error: Notice: Undefined index: options in uc_option_image_product_options_submit() (line 152 of /public_html/sites/all/modules/uc_option_image/uc_option_image.module). The images upload fine but when I hit submit is when I get the error.

aacraig’s picture

@kmuryphychi, this is working for me.

Can you confirm that we're talking about the same page:
edit any product
click on the "options" item under the tabs
scroll down below the options to the "Option Images" section
insert an image in one of the option fields

Is that what you did to get the error?

Are you using the latest version (from comment #16)?

hawkeye217’s picture

@aacraig: How about option images on the cart page?

Work was done for the D6 version here: http://drupal.org/node/256580#comment-2997674

I think it would involve simply adding uc_option_image_form_uc_cart_view_form_alter() to your code. I can try to work on it, but I figured you'd be able to get to it faster than I would since you're already familiar with the code...

aacraig’s picture

@hawkeye217: That's a great suggestion. I won't have time to work on this in the immediate future, and I'd really like to see this port added as an official release so we can have a real issue queue.

If no one else has done it by then, I'll be able to look into this in two week's time.

hawkeye217’s picture

@aacraig: Here is a function I hacked together that works for my particular needs. It assumes only one attribute per product, or at least the image attribute is the first in line of the rest. I know there are probably easier/cleaner ways to do it, but this fit my needs. Hopefully this can give you a good starting point...

function uc_option_image_form_uc_cart_view_form_alter(&$form, &$form_state)  {

  $count = count(uc_cart_get_contents());

  for ($i=0; $i<$count; $i++) {  
    $test= unserialize($form['items'][$i]['data']['#value']);

    $aid = key($test['attributes']);  // attribute id
    $oid = $test['attributes'][$aid];  // option id
    $pid = $form['items'][$i]['nid']['#value']; // node id

    $values = uc_option_image_values('uc_cart', array('aid' => $aid, 'pid' => $pid, 'oid' => $oid));

    if (isset($values['fid']['value'])) {
        $file = file_load($values['fid']['value']);
        $file->uri = str_replace('/uc_option_image','',$file->uri);
        $form['items'][$i]['image']['#item'] = (array) $file;
        $form['items'][$i]['image']['#item']['alt'] = '';
        $form['items'][$i]['image']['#item']['title'] = '';
      }
  }
}
fonant’s picture

Can't get the module from #16 to work, sadly. It looks just like what I need!

As norbert.broadsword found, uploading images and making changes to the image display options for individual products has no effect: I can upload an image, but on saving the product it disappears again. Product > Edit > Options page, in the "Option Images" section.

I've managed to upload a default image for the attribute option, but that doesn't display either. At least uploaded image and display settings are kept OK here. Store > Products > Attributes > Options

For the image to be swapped when a different option is chosen, I'm guessing that the uc_option_image.js file has to be included, but this isn't on my site. Nor do the images appear beside the options if I choose radio buttons.

Perhaps the lack of ability of setting the display options for the Product means that "Display an image inline next to each option title." and "Display an image showing the selected option(s)." are never checked?

fonant’s picture

OK, more research shows that the per-product images, and the display settings, are in fact stored in the database uc_option_image table OK.

So the problem is more that the per-product form doesn't update to show the databased details. So if you save the product options again, all the uploaded images and display settings are removed: you have to upload all the images and set the display settings again before clicking "Submit" on the product "Edit" > "Options" form.

Jawi’s picture

Title: Port to D7 Ubercart » Port to D7 + Commerce ?
Assigned: liberatr » Unassigned
FileSize
84.66 KB
129.24 KB

Nice work!
I'm using the module on my clients site
When adding new attribute options and upload an image for this option at the same time (/admin/store/products/attributes/5/options/add) I'm getting this error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 146 [:db_insert_placeholder_1] => uc_option_image [:db_insert_placeholder_2] => uc_option [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 1 ) in file_usage_add() (regel 661 van/home/idc/domains/domain.com/public_html/includes/file.inc).

The error does not occur when creating the attribute options first without the images and adding the images later on.
Any idea how I can fix this? (I'm not a coder..)

Is there a way to easily display both "attribute_options_selected_images" when displaying 2 different attributes on the product page?

Thanks for all support(Y)

Buckminster_Bond’s picture

Just like to report the same behaviour as #31 when using the module shared by aacraig in #16 - all works fantastically well at the attribute level.

However, if the requirement is for different attribute images to display for each product then the first time that the product is saved, it still works perfectly.

Unfortunately, if the product is then updated in anyway - for example the stock is adjusted, then all the option images all disappear.

aacraig’s picture

I've just been made a maintainer for the module, so I will have the official D7 release up this week, and I will incorporate a fix for the above issues in that release.

Anonymous’s picture

Thanks for your work on this aacraig - any progress on an official D7 release?

I have another issue to report when uploading option images under Store > Products > Attributes, it throws an "The website encountered an unexpected error." message. The option is created, but the image isn't uploaded. Looking at the logs I can see the following:

Warning: Parameter 1 to upload_replace_file_update() expected to be a reference, value given in module_invoke_all() (line 819 of /home/dannysau/public_html/includes/module.inc).

Also...

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'id' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 356 [:db_insert_placeholder_1] => uc_option_image [:db_insert_placeholder_2] => uc_option [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 664 of /home/dannysau/public_html/includes/file.inc).

However, when I edit that option and upload an image again everything works fine.

fonant’s picture

Just to note that I'm working on fixing bugs in my copy of this, as posted in #16. Shout if I'm duplicating effort!

aacraig’s picture

In a sense, yes. I have a 90% ready update which I plan to release in the next few days.

I suggest you contact me privately (info@aaroncraig.com) so we can diff / merge our work and then I'll release a complete version.

venecian’s picture

many mistakes, nothing displayed, without images, only checkbox I see in output. Why dont see upload images?

aacraig’s picture

I have committed a working version. Please try the 7.x dev release.

Anonymous’s picture

Hmm, I don't see any 7.x dev release on the main page.

Edit: oh, it's in the 'other releases' section. Sorry.

liberatr’s picture

afestein,

A new release has been generated from aacraig's commit a few weeks back, and I just published it.

Please look at http://drupal.org/node/241492/release

Poieo’s picture

There is a dpm left in the uc_option_image.theme.inc file on line 12.

Jawi’s picture

Aacraig, thanks for the work on the betaversion!

There is a dpm left in the uc_option_image.theme.inc file on line 12.

Same issue here.
Fatal error: Call to undefined function dpm() in /home/idc/domains/domains.com/public_html/sites/all/modules/uc_option_image/uc_option_image.theme.inc on line 12

I'll try to fix this

Jawi’s picture

Updating from #16 uc_option_image.tar_.gz delivered the following error:

Fatal error: Call to undefined function dpm() in /home/idc/domains/domain.com/public_html/sites/all/modules/uc_option_image/uc_option_image.theme.inc on line 12

liberatr’s picture

The call to dpm is commented out in beta2:
http://drupal.org/node/1703020

If you have Devel module installed it won't cause an error.

Jawi’s picture

FileSize
81.83 KB
152.23 KB

Greet work!!

Beta 2 version works for me with the devel-module on!!
Also the issues under #32

adding new attribute options and upload an image

are solved (NICE JOB!)

Still some strange things happen:

  • The selected images don't display correct with multiple product and multiple attributes in the catalog view.
aacraig’s picture

Hello all, and sorry for the absence. In the meantime I've been hired as the CTO of a startup, so I've moved to Dublin and have been swamped getting everything set up.

In all honesty, I don't believe I'll be able to get back to this before the end of the month, so if someone wants to jump in, that would be greatly appreciated. Otherwise I'll be able to spend some time on this towards the end of August.

Jawi’s picture

The javascript on the product page / node page seems to be ok.

Theire are some issues with the javascript in the catalog view.

We are trying to sove this by adjusting the javascript.

Indeed all help would be welcome

xacto’s picture

1st thank you aacraig for the effort on this port to 7. Congrats on your trip and new job!! hope all is well.

I am porting a Ubercart 6 site to 7. I cannot seem to get the image file system working.
Will not upload, or files will not save on "submit".

It seems some of you have a working version or patch.
Is there any new information or patches that fixe this upload image issue in the individual product attribute options page.

Trying to go through the code but haven't found the issue yet.

Thanks all for any help or information.

Jawi’s picture

I will help you on skype!

marcom2021’s picture

In the latest dev version of Ubercart there is an option to auto update the product price based on the selected attributes. (http://drupal.org/node/1380772#comment-6367078)
When this setting is enabled the option images dissapear as soon as an option is selected.

Any way to solve this?

Jawi’s picture

You should adjust the javascript

xacto’s picture

Well, being a drupal community, Any patches or commits made to the public module would be very helpful to many I assume. :-)

After playing with some of the javascript, I have noticed better integration with views displays would be helpful.
Creating a views "product node" "image field" using ajax for the image swap, could be very helpful, since most of us use views for our product displays.

Again, any patches or commits could help continue the public development of this module.

Thanks again.

Summit’s picture

Hi, How about the commerce port, is this still relevant? Would love to see this happening
greetings, Martijn

liberatr’s picture

Title: Port to D7 + Commerce ? » Port to D7 Ubercart
Assigned: Unassigned » liberatr

Actually, there is no reason to port this module to Drupal Commerce, their system for attaching multiple product entities to a Product Display takes care of our functionality, as long as you upload a picture with each Product.

djob’s picture

Hello
I have just installed the latest release 7.x-1.0-beta2 to Drupal core 7.15/Ubercart 7.x-3.2 and it work very well. Does exactly what I expected. Excellent, thank you.
Regards

jday’s picture

I'm having the same problems as #51

I've selected the 'display inline' option so every option image is displayed next to the label/input but once you make a selection, all option images disappear. I've removed the entire javascript file but that has not helped.

liberatr’s picture

Assigned: Unassigned » liberatr
Issue summary: View changes
Status: Needs work » Closed (fixed)

The bug from #51 and #57 is fixed in the 7.x-1.x-beta3 release.