Forums / All Other Contributions/Addons / Attribute image replaces main product image on select [Support Thread]

Attribute image replaces main product image on select [Support Thread]

Views: 44,652

Results 61 to 80 of 177
7 May 2011, 4:03 PM
#62
novastar avatar

novastar

Zen Follower

Join Date:
Jul 2009
Posts:
127
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

Yeah I figured, how difficult do you think it would be. I'm alright with coding, but I've never written an app for my self outside of a few log in scripts.
The other thing that I wanted to know is how to update the cart so that it shows the attribute image that was selected when it was added to the cart. this is really only noticeable for an attribute like color but currently it shows the image of the original.

31 Aug 2011, 7:30 PM
#63
tranced avatar

tranced

New Zenner

Join Date:
Aug 2011
Posts:
6
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

I'd like to add a note about this add-on.

It works with Image Handler 3, as long as you EXPLICITLY specify both medium image width & medium image height. Also, this add-on is dependent upon your main product image img tag being wrapped in a div with ID="productImageMain" because the javascript replaces the elements within the container of that ID name.

If you don't want to specify a width or height for image handler (in admin config>images) for whatever reason (I didn't want to specify medium heights because I only wanted the width defined for height to auto-size proportionally), just alter the attributes.php..

find this line:

$parameters=' onchange="getattribimage('.'\'id[' . $products_options_names->fields['products_options_id'] . ']\''.','. MEDIUM_IMAGE_WIDTH.', '.MEDIUM_IMAGE_HEIGHT.',' this.value,'.$_GET['products_id'].');"';

change to:

$parameters=' onchange="getattribimage('.'\'id[' . $products_options_names->fields['products_options_id'] . ']\''.', height, width, this.value,'.$_GET['products_id'].');"';

...where height is the pixel height WITHOUT a "px" suffix and width in the same format. the point is that both width and height must be specified or else this won't work. and to reiterate, the image must be wrapped in a container with ID of productMainImage

One more thing.. the image doesn't revert to the default main image once you select an attribute and it gets replaced. You must create a default attribute (for example, if the image base is white in color) and assign an image to the "default" attribute, regardless of if its the same as your main product image.

24 Oct 2011, 9:30 PM
#64
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

Does anyone know how to get this working with Lightbox? The main image comes up in the lightbox, but once the images swap, the new images just come up in a regular popup box.

Danielle

30 Nov 2016, 5:47 AM
#65
lrfowler24 avatar

lrfowler24

New Zenner

Join Date:
Feb 2010
Posts:
74
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

I couldn't get past the SQL query...
SQL query:

INSERT INTO products_options_types VALUES (6, 'Link');
MySQL said: Documentation

#1062 - Duplicate entry '6' for key 'PRIMARY'

30 Nov 2016, 1:27 PM
#66
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

lrfowler24:

I couldn't get past the SQL query...
SQL query:

INSERT INTO products_options_types VALUES (6, 'Link');
MySQL said: Documentation

#1062 - Duplicate entry '6' for key 'PRIMARY'

Just came across this message. Yeah, the sql in the sql_run.txt file is not written with the concept of other products_options_types having been added or any other flexibility and it is provided with an existing table prefix which if applied within the tools->install sql patches window will more than likely cause errors.

May I suggest the following sql for first time installation. If run a second time, it will attempt to add another products_options_types_id with the same name which would be a problem so if there is a problem with running this install script, I suggest following up with the uninstall script before attempting to install again. Oh wait, I just realized that there is not an uninstall script... I include that below as well.. :/

Install script to be placed in admin->tools->install sql patches:

SELECT @products_options_types_id := pot.products_options_types_id+1
            FROM `products_options_types` pot    
            order by pot.products_options_types_id desc limit 1;

INSERT INTO `products_options_types` (products_options_types_id, products_options_types_name) VALUES (@products_options_type_id, 'Link');

INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value,
        configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', @products_options_type_id, 'Numeric value of the link product option type', 6, 0, now(), NULL, NULL);

Removal sql also to be placed in admin->tools->install sql patches (if removal is desired or if attempting to rerun the above install sql):

DELETE FROM `products_options_types` WHERE products_options_types_name = 'Link';
DELETE FROM `configuration` WHERE configuration_key = 'PRODUCTS_OPTIONS_TYPE_LINK';

If run within phpmyadmin, the table(s) need to be prefaced with the DB_PREFIX value found in includes/configure.php and admin/includes/configure.php (should be the same in both). The table name is identified by the text immediately after FROM and the text immediately after INTO. The backquotes on the table names are unnecessary, but were maintained as the original author had used them.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

30 Nov 2016, 11:13 PM
#67
lrfowler24 avatar

lrfowler24

New Zenner

Join Date:
Feb 2010
Posts:
74
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

Just came across this message. Yeah, the sql in the sql_run.txt file is not written with the concept of other products_options_types having been added or any other flexibility and it is provided with an existing table prefix which if applied within the tools->install sql patches window will more than likely cause errors.

May I suggest the following sql for first time installation. If run a second time, it will attempt to add another products_options_types_id with the same name which would be a problem so if there is a problem with running this install script, I suggest following up with the uninstall script before attempting to install again. Oh wait, I just realized that there is not an uninstall script... I include that below as well.. :/

Install script to be placed in admin->tools->install sql patches:

SELECT @products_options_types_id := pot.products_options_types_id+1
FROM products_options_types pot
order by pot.products_options_types_id desc limit 1;

INSERT INTO products_options_types (products_options_types_id, products_options_types_name) VALUES (@products_options_type_id, 'Link');

INSERT INTO configuration (configuration_title, configuration_key, configuration_value,
configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', @products_options_type_id, 'Numeric value of the link product option type', 6, 0, now(), NULL, NULL);

> 
> Removal sql also to be placed in admin->tools->install sql patches (if removal is desired or if attempting to rerun the above install sql):
> ```
DELETE FROM `products_options_types` WHERE products_options_types_name = 'Link';
DELETE FROM `configuration` WHERE configuration_key = 'PRODUCTS_OPTIONS_TYPE_LINK';

If run within phpmyadmin, the table(s) need to be prefaced with the DB_PREFIX value found in includes/configure.php and admin/includes/configure.php (should be the same in both). The table name is identified by the text immediately after FROM and the text immediately after INTO. The backquotes on the table names are unnecessary, but were maintained as the original author had used them.

..........I wasn't able to run the first code......I got an error................. so then I ran the uninstall code............ and I ran the first code and still got an error. Can you do a teamviewer session?

30 Nov 2016, 11:14 PM
#68
lrfowler24 avatar

lrfowler24

New Zenner

Join Date:
Feb 2010
Posts:
74
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

lrfowler24:

..........I wasn't able to run the first code......I got an error................. so then I ran the uninstall code............ and I ran the first code and still got an error. Can you do a teamviewer session?

the error - WARNING: An Error occurred, please refresh the page and try again.

30 Nov 2016, 11:23 PM
#69
lrfowler24 avatar

lrfowler24

New Zenner

Join Date:
Feb 2010
Posts:
74
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

so.....first I tried doing this code in phpmyadmin (I forgot about admin - Tools)....
INSERT INTO zen_products_options_types VALUES (6, 'Link');

INSERT INTO zen_configuration VALUES ('','Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', '6', 'Numeric value of the link product option type', 6, 0, NULL, '', NULL, NULL);
.......but..........I noticed there was no zen_products_options_types ......so I changed it to INSERT INTO products_options_types VALUES (6, 'Link');

30 Nov 2016, 11:26 PM
#70
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

lrfowler24:

the error - WARNING: An Error occurred, please refresh the page and try again.

Sorry, there was a typo in the original query (@products_options_type_id should have been @products_options_types_id) :

SELECT @products_options_types_id := pot.products_options_types_id+1
            FROM `products_options_types` pot    
            order by pot.products_options_types_id desc limit 1;

INSERT INTO `products_options_types` (products_options_types_id, products_options_types_name) VALUES (@products_options_types_id, 'Link');

INSERT INTO `configuration` (configuration_title, configuration_key, configuration_value,
        configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', @products_options_types_id, 'Numeric value of the link product option type', 6, 0, now(), NULL, NULL);

I don't know why an error occurred with the removal as I just ran it (twice) to see if I would get an error...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

30 Nov 2016, 11:35 PM
#71
lrfowler24 avatar

lrfowler24

New Zenner

Join Date:
Feb 2010
Posts:
74
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

Sorry, there was a typo in the original query (@products_options_type_id should have been @products_options_types_id) :

SELECT @products_options_types_id := pot.products_options_types_id+1
FROM products_options_types pot
order by pot.products_options_types_id desc limit 1;

INSERT INTO products_options_types (products_options_types_id, products_options_types_name) VALUES (@products_options_types_id, 'Link');

INSERT INTO configuration (configuration_title, configuration_key, configuration_value,
configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Link product option type', 'PRODUCTS_OPTIONS_TYPE_LINK', @products_options_types_id, 'Numeric value of the link product option type', 6, 0, now(), NULL, NULL);

>  
> I don't know why an error occurred with the removal as I just ran it (twice) to see if I would get an error...

THAT WORKED!....so does it work with drop-down boxes?
1 Dec 2016, 12:19 AM
#73
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

lrfowler24:

THAT WORKED!....so does it work with drop-down boxes?
Wish I could answer this. I just happened to take a look at the thread because it had popped up in my recent messages a few times and I was curious about the plugin. Seeing related posts and the query with which you were having difficulty I realized what the likely problem was and so tried to provide a solution to that. Beyond that I am not familiar with the operation nor what is necessary for it to "work". I did see a few other "issues" with the provided attribute.php file which should be placed in one's override folder rather (includes/modules/YOUR_TEMPLATE) instead of in the "core" path as provided. Further with the way ZC 1.5.5 has modified the attributes.php file, there is an improved way to implement what this does that doesn't/shouldn't require modifying the in-store version of that file.
lrfowler24:

I'm lost now....it doesn't work at all...
http://leoandmo.com/index.php?main_page=product_info&cPath=1_23_24&products_id=81
Again, at the moment unsure what is needed to make it work, perhaps someone familiar with the plugin will chime in. Suggestion would be to look back at the recent posts on issues identified and also providing more information about your setup (ie. ZC version).

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

1 Dec 2016, 12:55 AM
#74
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

lrfowler24:

I'm lost now....it doesn't work at all...
http://leoandmo.com/index.php?main_page=product_info&cPath=1_23_24&products_id=81
Because this plugin likely uses javascript (or equivalent) to swap the images, I ran that page through an html validator (https://validator.w3.org/check?uri=http%3A%2F%2Fleoandmo.com%2Findex.php%3Fmain_page%3Dproduct_info%26cPath%3D1_23_24%26products_id%3D81&charset=%28detect+automatically%29&doctype=Inline&group=0%29 and had 47 errors. I don't know if that is a factor in the lack of operation, but certainly want your pages to validate to ensure javascript operations and for your pages to be looked upon favorably.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Dec 2016, 11:49 AM
#75
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

I've gotten this to work as well as updated it to use ajax.php instead of the provided additional root file. Also, have moved the attributes.php related code primarily out of attributes file and into an observer file. Just thought about something more that I could do to further remove the code out a little. Having looked through the remainder of this thread am considering what would be necessary to incorporate changes made by other plugins like colorbox. Oh, and two other things incorporated as discussed in here is the switch back to the default image in absence of an attribute defined image and bypassing the "bigger_image" load if such an image is not present in the system as well as other ZC standardization such as using DIR_WS_IMAGES for the images directory, moving the jscript_main code into its own file, and properly sequencing the javascript to provide appropriate javascript "validation".

I've attempted to contact the most recent author/updater and haven't heard anything yet, but as soon as I complete the remaining items I want to address, I will post the changes made to support updating this plugin.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

18 Dec 2016, 5:31 PM
#76
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

I've gotten this to work as well as updated it to use ajax.php instead of the provided additional root file. Also, have moved the attributes.php related code primarily out of attributes file and into an observer file. Just thought about something more that I could do to further remove the code out a little. Having looked through the remainder of this thread am considering what would be necessary to incorporate changes made by other plugins like colorbox. Oh, and two other things incorporated as discussed in here is the switch back to the default image in absence of an attribute defined image and bypassing the "bigger_image" load if such an image is not present in the system as well as other ZC standardization such as using DIR_WS_IMAGES for the images directory, moving the jscript_main code into its own file, and properly sequencing the javascript to provide appropriate javascript "validation".

I've attempted to contact the most recent author/updater and haven't heard anything yet, but as soon as I complete the remaining items I want to address, I will post the changes made to support updating this plugin.
Just uploaded version 1.5.6 of this plugin.

Writeup was:

  • Modified approach to display the swapped attribute image to use ZC's ajax method instead of an additional file from this plugin.- Updated the install SQL to account for other products_options_types having been added.
  • Used POST related transfer of data rather than the URL to improve on security.
  • Added that if an attribute selected does not have an image associated with it that the default/main product's image would be displayed.
  • Added javascript to load the attribute image if the product information page is displayed with the attribute(s) already selected.
  • Incorporated the module main_product_image.php code to support Image Handler operation on the attribute file.
  • Moved added attributes related code into an observer file with minor modifications made to the provided attributes.php file associated with ZC 1.5.5's version of the file. Additional effort would be needed to completely remove all modifications and instead use more of a javascript insertion/modification.
  • Modified/expanded the readme instructions.
  • Added a SQL query to be run if determined necessary because of not updating to ZC 1.5.5 and missing database records.
  • Modified code to use ZC standard defined variables/constants rather than hard-coded (i.e. DIR_WS_IMAGES instead of 'images/')
  • Made use of an image such as bigger_picture.jpg optional where the standard 'larger image' (TEXT_CLICK_TO_ENLARGE) text will be shown if the file does not exist.
  • Resequenced the javascript so that expected variables/data would be in scope, minimizing the processing needed to display/correct the javascript code.
  • Reduced the amount of code that needed to be merged versus added by pulling the javascript code added by this module out of jscript_main.php and putting it into its own jscript_ file.
  • Moved an extra function demonstrated to be called only by this plugin into the observer class, although the code that calls the zen_link function doesn't provide all of the data necessary to use the function to its maximum extent. The code remains intact, but does not appear to provide the intended operation/capability.
  • As compared to the previous version, the additional attribute images will be displayed if the attribute image style is selected to be 6, but will be removed if set as 7. In both conditions 6 and 7, the attribute image will be swapped with the main product image upon selection.

It should be available from the location identified in post 1 of this thread which is here when it has been reviewed and approved by one of the ZC volunteers. (ie. please be patient while the code undergoes the necessary review cycle prior to being made available here.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

19 Dec 2016, 9:58 PM
#77
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

Hello there,
Thanks for all your efforts in updating this module. I am not currently using attribute images, but I just had a query as to whether using this module, if it would cause the slight slowdown in zencart that is talked about in the optimisation page for zencart? Currently I have the option set to false in the config, as recommended. But it would be interesting to know if this module ignores that.

Regards,
James

19 Dec 2016, 10:10 PM
#78
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

HeathenMagic:

Hello there,
Thanks for all your efforts in updating this module. I am not currently using attribute images, but I just had a query as to whether using this module, if it would cause the slight slowdown in zencart that is talked about in the optimisation page for zencart? Currently I have the option set to false in the config, as recommended. But it would be interesting to know if this module ignores that.

Regards,
James
Could you please elaborate on the above? Which article, which setting?

From observation I did see the possibility of change response time possibly being slow, but it didn't prevent me as a user from moving on to the next action, whether it was to change attribute selections again or to carry on with add-to-cart. The delay was completely dependent on the data transfer/response speed. I could for example use one device and have lightening response, and another slow as molasses, but the slow device was slow in everything not just image swap.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

19 Dec 2016, 10:41 PM
#79
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: Attribute image replaces main product image on select [Support Thread]

https://www.zen-cart.com/content.php?63-how-do-i-speed-up-my-site> . In Admin->Configuration->Attribute Settings, there are a few switches which, if turned off, will reduce the number of queries used to calculate and display product information:

  • Enable Downloads -- If you're not doing downloads on your site, turn this off.
  • Enable Price Factor -- If you're not using price-by-attributes support, turn this off to stop those calculations and the related queries
  • Enable Qty Price Discount -- If you're not doing quantity discounts, turn this off
  • Enable Attribute Images -- If you're not adding images to your attributes, turn this off

I understand it won't be possible to make it have no impact when attribute images are being used.

Regards,
James

20 Dec 2016, 11:24 PM
#80
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

HeathenMagic:

https://www.zen-cart.com/content.php?63-how-do-i-speed-up-my-site

I understand it won't be possible to make it have no impact when attribute images are being used.

Regards,
James
If the image setting for the option name isn't 6 or 7, then no swap will occur nor be attempted and the javascript will load waiting to be activated, but not do anything and therefore there would be no slowdown related to the attributes image specifically, just the additional javascript associated with possibly loading.

It does not currently respect those settings though, ie. if the attribute image style is set to 6 or 7, it will still "inquire" about the presence of attribute image information and if found associated with the product/attribute combination will move forward with the next action (which would be to pull the same image as already on screen and try to update it to be the same as it was for each selected attribute that doesn't have an alternate image selected...)

Can look to see what efficiencies can be obtained by inspecting that setting. Seems that basically everything "front facing" would be disabled/bypassed as none of the javascript would apply and therefore not need to be pushed to the browser at least that which is pertinent to the plugin. (There's a few JS functions present that are not called by this plugin, but they seem to be one of those, hey someone added it, used it, and expects it... things but it doesn't do anything for this software.)

So effectively it seems that the slowdown would all be in querying the database and returning the base image on every selection if it is even possible for the attribute's image setting to be identified as 6 or 7. Though I guess more could be done with the javascript to identify the last image loaded and if different than the current/new image then to pass the information rather than to pass it on every attribute selection change. (ie. A little further JS refinement possible.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...