Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attribute Sets Contribution


Recommended Posts

I was waiting for this question, I thought about the sort order and I realized that that opened another can of worms. I'll have to write an enhancement to either the products_attributes.php page or another new page.

 

Worst case you can edit the fields using your database interface tool, which most likely is phpMyAdmin.

 

Joey

 

joeyjgarcia-

 

I installed your contribute with no problems and it works great.  You have saved me  a lot of time and effort, and I really appreciate it.

 

I have a question, Is it possible to set the sort order of the attribute drop downs on the product info page ?

 

Thanks again for the awsome contribution.

Link to comment
Share on other sites

  • Replies 659
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for the quick reply!

 

It seems like the menu's are arranged alphabetically, by attribute set name. Is there an easy way to alter the product page to order the drop downs by the Attribute Set ID, rather than the Attribute Set Name. I could then just use a naming convention for the Attribute Set IDs, (eg 1 Width, 2 Length, etc) to change the order ?

 

 

I was waiting for this question, I thought about the sort order and I realized that that opened another can of worms.  I'll have to write an enhancement to either the products_attributes.php page or another new page. 

 

Worst case you can edit the fields using your database interface tool, which most likely is phpMyAdmin.

 

Joey

Link to comment
Share on other sites

Everyone wants it sorted their own way, once I do it one way for someone then someone else wants it another way. Therefore, I'm going to just let people use thei way it is, unless there is a bug.

 

People have two options:

 

1) In the Admin area, edit each product, set the Attribute Set for each product and my code will remove the product's attributes and re-add them via the Attribute Set you chose and now it will add in the sort order.

 

2) The change made to the products_info.php page was basically an "order by" clause the points to the sort_order field that I added in this version. If you want to order by another field, such as the products_attributes_id (like I do) then change it to whatever works. Just may sure the field is being pulled from the table in the query.

 

I knew adding this feature would cause some people some extra work, but if you don't want to order the Option Values using my order-by clause then don't change it.

 

If you're starting a new store, then you might as well use it because there is no extra work involved. If you have an existing store, you may have to just sit down one day and do approach #1.

 

Joey

 

 

Thanks for the quick reply!

 

It seems like the menu's are arranged alphabetically, by attribute set name.  Is there an easy way to alter the product page to order the drop downs by the Attribute Set ID, rather than the Attribute Set Name.  I could then just use a naming convention for the Attribute Set IDs, (eg 1 Width, 2 Length, etc) to change the order ?

Link to comment
Share on other sites

Can you please post the debug information so I can see what is killing the query?

 

On the language issue, somewhere you can set the language to Chinese and that will use another folder for that langauge.

 

For example:

 

For English use:

 

/catalog/admin/includes/languages/english/

 

For Chinese use:

 

/catalog/admin/includes/languages/chinese/

 

I'm not sure if you have to add it to hack it to use Chinese or you could hack your english files to show chinese, that would be the quickest but the least eloquent.

 

Joey

 

 

Joey:

I have installed many contributions in English and I always put English language file into Chinese folder. I do the same this time but encounter this problem at first time.

 

Strangely, though option_name can't show up but option_value_name can show up correctly....

 

 

My debug info"

 

attributeSet_sql = select * from products_attributes_sets where products_attributes_sets_id=3

option_id = 1

optionName_sql = select products_options_name from products_options where products_options_id=1

options_query_sql = select pov.products_options_values_name, pov.products_options_values_id from products_options_values pov, products_options_values_to_products_options pov2po where pov2po.products_options_id=1 and pov.products_options_values_id=pov2po.products_options_values_id order by pov.products_options_values_name

 

 

 

 

Michael

Link to comment
Share on other sites

Michael:

 

Run these queries to see if they return anything? Also double check if the option_id is correct (i.e., option_id=1 and not option_id=12)?

 

Use this information and verify it by looking into your database tables.

 

Joey

 

 

Joey:

I have installed many contributions in English and I always put English language file into Chinese folder. I do the same this time but encounter this problem at first time.

 

Strangely, though option_name can't show up but option_value_name can show up correctly....

My debug info"

 

attributeSet_sql = select * from products_attributes_sets where products_attributes_sets_id=3

option_id = 1

optionName_sql = select products_options_name from products_options where products_options_id=1

options_query_sql = select pov.products_options_values_name, pov.products_options_values_id from products_options_values pov, products_options_values_to_products_options pov2po where pov2po.products_options_id=1 and pov.products_options_values_id=pov2po.products_options_values_id order by pov.products_options_values_name

Michael

Link to comment
Share on other sites

attributeSet_sql = select * from products_attributes_sets where products_attributes_sets_id=2

option_id = 6

optionName_sql = select products_options_name from products_options where products_options_id=6 and language_id=4

options_query_sql = select pov.products_options_values_name, pov.products_options_values_id from products_options_values pov, products_options_values_to_products_options pov2po where pov2po.products_options_id=6 and pov.products_options_values_id=pov2po.products_options_values_id order by pov.products_options_values_name

 

 

I add language_id=(int)$languages_id in the $optionName_sql. It can correctly disply option name now when editing.

 

However, I still have the problem of losing other sets (and their attributes) assigned to a product when editing one set.

 

HELP

Michael

Link to comment
Share on other sites

attributeSet_sql = select * from products_attributes_sets where products_attributes_sets_id=2

option_id = 6

optionName_sql = select products_options_name from products_options where products_options_id=6 and language_id=4

options_query_sql = select pov.products_options_values_name, pov.products_options_values_id from products_options_values pov, products_options_values_to_products_options pov2po where pov2po.products_options_id=6 and pov.products_options_values_id=pov2po.products_options_values_id order by pov.products_options_values_name

I add language_id=(int)$languages_id in the $optionName_sql. It can correctly disply option name now when editing.

 

However, I still have the problem of losing other sets (and their attributes) assigned to a product when editing one set.

 

HELP

Michael

 

 

Joey:

 

I try to study your codes but I am not actually a programmer so that I can only guess. If I am right, my problem should come from the action=updateSets and jjj_xxx database functions. It seems the jjj_xxx function remove all references but not inserting those not edited back.

 

michael

Link to comment
Share on other sites

Joey:

 

I try to study your codes but I am not actually a programmer so that I can only guess. If I am right, my problem should come from the action=updateSets and jjj_xxx database functions. It seems the jjj_xxx function remove all references but not inserting those not edited back.

 

michael

 

function jjg_db_attributeSets($arr_attributeSetID, $productID, $action, $link = 'db_link'){

 

//remove all references to this product_id in these tables, and reinsert new ones

if( $action == 'update_product' || $action == 'delete_product_confirm'){

$delete_query = "delete from products_attributes where products_id=".$productID;

tep_db_query($delete_query, $link);

$delete_query = "delete from products_attributes_sets_to_products where products_id=".$productID;

tep_db_query($delete_query, $link);

}

//if you remove the product, then our work is done

if( $action == 'delete_product_confirm' ){

return;

}

 

 

Should it just delete the set being editing? Why delete all sets?

 

michael

Link to comment
Share on other sites

Joey,

I figured out what I needed to do, thanks for your help. I needed a method to order the Attributes by ID rather than by name, so I took your method for ordering the values and applied it to the $products_options_name_query.

Changing this:

 

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");

into this:

 

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_id");

 

Maybe in your next release you could add a "Weight" variable to the Attributes, like you did for the Attribute Values. I thought their was a contribution for just that thing, called Attribute Sorter, or something, but I couldn't find it. In any case, your work really helped me out, thanks again.

Link to comment
Share on other sites

Joey, this is an excellent contrib to osC. I don?t have an installation problem (aside from locating the 4.0 versions... all I see are the 2. ones).

 

This is a big one. I'm pretty sure you will be giving me insight and not code because this is probably too much work.

 

I would like to use the Attrib sets and have an image for each option. The site sells beads and there are over 100 different styles (those would be the different products) but there are only about 4 different color sets (ex 25 different products share the same color set). I would like to be able to have an image that would be assigned to each option.

 

So let?s say that Product #1 is selected. There is a drop down list with the colors for that product (the attrib set) and then some of the colors are more expensive (already a feature of osC). When a color is selected, the item picture changes to that exact product with the correct color.

 

I have tried to combine an image for each option with your contrib but it never worked out, especially since I already have a modded store with a "No more image pop-ups" contrib.

 

Any help would be much appreciated. (You would think that someone already made a contrib like this but I never found one).

 

Tracer

Lance Corporal in the United States Marine Corps

 

Head Support Admin: PNphpBBHacks

 

PNphpBB Support Team Member PNphpBB

Link to comment
Share on other sites

joey,

I added a sort_order line to the products_options Table, a slightly tedious procedure since I wasn't using phpMyAdmin and had to do it through the command line. Then I made the changes to products_attributes.php to add a sort order field to the Product Options section, and altered the case/switches to reflect, and update the new field. No problems in testing. If you are interested I'll send the changes to you, so you could add them to your next update.

 

Have a good one!

 

-exzero

Link to comment
Share on other sites

I think it has nothing to do with the database functions. Keep in mind that it works with my site and others that have tried it. Those db functions are used in the categories.php page.

 

Joey

 

 

Joey:

 

I try to study your codes but I am not actually a programmer so that I can only guess. If I am right, my problem should come from the action=updateSets and jjj_xxx database functions. It seems the jjj_xxx function remove all references but not inserting those not edited back.

 

michael

Link to comment
Share on other sites

Does option_id=6 match the option you expect? Or do you expect Option_id 16, or 61, 62, 63, 6x,....

 

You see, even though you get a single digit, it may still be the wrong one! Please verify that it is the correct one by looking at the products_options table.

 

Joey

 

 

attributeSet_sql = select * from products_attributes_sets where products_attributes_sets_id=2

option_id = 6

optionName_sql = select products_options_name from products_options where products_options_id=6 and language_id=4

options_query_sql = select pov.products_options_values_name, pov.products_options_values_id from products_options_values pov, products_options_values_to_products_options pov2po where pov2po.products_options_id=6 and pov.products_options_values_id=pov2po.products_options_values_id order by pov.products_options_values_name

I add language_id=(int)$languages_id in the $optionName_sql. It can correctly disply option name now when editing.

 

However, I still have the problem of losing other sets (and their attributes) assigned to a product when editing one set.

 

HELP

Michael

Link to comment
Share on other sites

I think you are catching on. It is very simple to have it order by another field, I sort my attributes but the table's id (primary key) and it works fine but so many people requested that so I threw that in. I hope I didn't make a mistake by adding that in.

 

Joey

 

 

 

 

 

Joey,

  I figured out what I needed to do, thanks for your help.  I needed a method to order the Attributes by ID rather than by name, so I took your method for ordering the values  and applied it to the $products_options_name_query.

Changing this:

 

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");

into this:

 

      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_id");

 

Maybe in your next release you could add a "Weight" variable to the Attributes, like you did for the Attribute Values.  I thought their was a contribution for just that thing, called Attribute Sorter, or something, but I couldn't find it.  In any case, your work really helped me out, thanks again.

Link to comment
Share on other sites

Ok, if you don't understand something I would recommend no messing with it! After a certain point I will say I can't help you.

 

The reason the I do a delete is because it is easier to just delete the set then re-add it instead of doing an update. The end result is the same and since there is no dependency on the primary key this approach is ok. If it was on the products_attributes table, that would be a different story since there is a dependency on the primary key.

 

Joey

 

 

 

function jjg_db_attributeSets($arr_attributeSetID, $productID, $action, $link = 'db_link'){

 

  //remove all references to this product_id in these tables, and reinsert new ones

  if( $action == 'update_product' || $action == 'delete_product_confirm'){

    $delete_query = "delete from products_attributes where products_id=".$productID;

    tep_db_query($delete_query, $link);

    $delete_query = "delete from products_attributes_sets_to_products where products_id=".$productID;

    tep_db_query($delete_query, $link);

  }

//if you remove the product, then our work is done

  if( $action == 'delete_product_confirm' ){

    return;

  }

Should it just delete the set being editing? Why delete all sets?

 

michael

Link to comment
Share on other sites

Please understand, when you update the Attribute Set it will show the changes on the FUTURE products that this set is applied to. My tool is only used to easily get the products attributes into the products_attributes table, once in that table you have to modify the attributes using the OLD method using osC's Products Attributes area.

 

You might be able to reapply the changes by re-editting the product and resetting the Attribute Set (after you midified the Attribute Set of course).

 

Joey

 

 

Joey

 

If i update an attribute set, none of the products that have that set are updated.  I have to do so manually.  And, when i update them all manually, the attribute set order reverses.  >_<

 

Thanks!

 

Dan

Link to comment
Share on other sites

Ok, you know you can't display an image in a drop-down list but you can do some custom coding to add some like a javascript "jump list". You've may have used one before where you make a selection from from a drop-down list and you "jump" to another page. I the same way you can have this list show an image of the selected bead when selected from a list and display it is a specified area on the product_info.php page.

 

You would need to do this with javascript and work with some arrays, simple for a web savvy person. I would make it an php include to bring in that file that inserts the javascript function.

 

Joey

 

 

Joey, this is an excellent contrib to osC. I don?t have an installation problem (aside from locating the 4.0 versions... all I see are the 2. ones).

 

This is a big one. I'm pretty sure you will be giving me insight and not code because this is probably too much work.

 

I would like to use the Attrib sets and have an image for each option. The site sells beads and there are over 100 different styles (those would be the different products) but  there are only about 4 different color sets (ex 25 different products share the same color set). I would like to be able to have an image that would be assigned to each option.

 

So let?s say that Product #1 is selected. There is a drop down list with the colors for that product (the attrib set) and then some of the colors are more expensive (already a feature of osC). When a color is selected, the item picture changes to that exact product with the correct color.

 

I have tried to combine an image for each option with your contrib but it never worked out, especially since I already have a modded store with a "No more image pop-ups" contrib.

 

Any help would be much appreciated. (You would think that someone already made a contrib like this but I never found one).

 

Tracer

Link to comment
Share on other sites

I don't follow. The product_options table doesn't affect the order of the drop-down list option values. The product_options table, in my case, has values like "sizes" or "colors" ( I actually only have 1 option for my whole eStore, "sizes") so sorting doesn't help in this table, at least for me. Sorting the products_attributes table orders the values in the drop down list on the products_info page. Maybe a screenshot will help.

 

I hope everything, other than the sort, is working.

 

Joey

 

 

joey,

    I added a sort_order line to the products_options Table, a slightly tedious procedure since I wasn't using phpMyAdmin and had to do it through the command line.  Then I made the changes to  products_attributes.php  to add a sort order field to the Product Options section, and altered the case/switches to reflect, and update the new field.  No problems in testing.  If you are interested I'll send the changes to you, so you could add them to your next update. 

 

Have a good one!

 

-exzero

Link to comment
Share on other sites

Does option_id=6 match the option you expect?  Or do you expect Option_id 16, or 61, 62, 63, 6x,.... 

 

You see, even though you get a single digit, it may still be the wrong one!  Please verify that it is the correct one by looking at the products_options table.

 

Joey

 

Joey:

 

option_id is correct. In fact, everything is correct about the attribute set I am editing and updating. The problem is other attribute sets assigned to this product will be lost.

 

Thanks

 

Michael

Link to comment
Share on other sites

I see the disconnect. The store I'm working is going to have a lot of options, and I needed to apply my own sort order to the options themselves, as well as their values. For example, if I want the "Sizes" drop down to be before the "Color" drop down. I tried sorting them by ID, which worked, but this store is going to have 30 or so options and I wanted more control. With your new Attribute Sets page I can change the sort order of the values of the options, and with my changes I can change sort order of the options themselves.

 

Here's a screenshot:

 

Product Attributes Page

 

-exzero

 

 

 

I don't follow.  The product_options table doesn't affect the order of the drop-down list option values.  The product_options table, in my case, has values like "sizes" or "colors" ( I actually only have 1 option for my whole eStore, "sizes") so sorting doesn't help in this table, at least for me.  Sorting the products_attributes table orders the values in the drop down list on the products_info page.  Maybe a screenshot will help.

 

I hope everything, other than the sort, is working.

 

Joey

Link to comment
Share on other sites

I think I may have found a minor little bug. If you have the Attribute Set Contribution installed, and you try to add a product attribute the old way you may get this message:

 

1136 - Column count doesn't match value count at row 1

insert into products_attributes values ('', '53', '1', '1', '', '+')

[TEP STOP]

 

The add_product_attributes switch/case in the products_attributes.php file tries to enter 6 values into the products_attributes table which, with the addition of the new sort_order value, now has seven values.

 

I added a sort_order variable to the query, and set it staticly at 0; It seems to work Okay for now, but it needs a little more testing. I'll post more if problems crop up.

 

It's not a huge problem, I wouldn't have noticed it if I didn't go to add a couple attributes to a product, without using the attribute sets page.

Link to comment
Share on other sites

I think you are referring to the instructions to add the field to the products_info.php page, not the products_attributes.php page. I don't think the instuctions touch the products_attributes.php page. It's a little thing, but it returns an error.

 

 

 

it is the sort order which was added to the new version, i believe there are instructions on adding this field . ..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...