Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Attribute Sets Contribution


Recommended Posts

  • Replies 659
  • Created
  • Last Reply

Top Posters In This Topic

Why do you say this?

 

Have you tried to reassigning an Attribute Set by editing a product and setting the attribute set to the one you want to use for that product. I will delete any attribtues for that product and then re-add them for that product.

 

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

Good catch!!! This the kind of stuff I like tohear about!

 

I get the same error when I try what you tried.

 

I must say, I didn't plan on have to use to old way but in all reality even I have had to use once in a while. I thought I accounted for this when I set the sort_order field to allow nulls and the default value to 0. I'll work on this and see if there is a clean fix then hacking the insert statement. Thanks!.

 

Joey

 

 

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.

Edited by joeyjgarcia
Link to comment
Share on other sites

wow. i love it. i had a hell of a freaking tim egetting previous installs to work properly and i tried this on a whim and it was beautiful. the ONLY problem i have so far is when i have more than one set IE size and color. I add color first with 72 options and then size with 7 options, after adding size, the order of the color set is backwards. any quick fix to this?

 

other than that its working wonderfully and saving me shitloads of time. thanks joey.

 

EDIT: i also tried deleting the test product and starting with a fresh product incase it had something to do with the product already having a set. still the same thing. if i have a new product and only want to add COLOR it is still backwards.

Edited by psychostickers
Link to comment
Share on other sites

so heres the quck fix for problems w/ sort order in multiple drop down attribute products:

 

MAKE YOUR LIST BACKWARDS.

 

delete the sets you have (sizes, colors) and re enter them completley backwards in order, not chaning the # but the actual order you enter them in. Then add a new product and it will come up in the "correct" order. kinda ghetto, but you should only have to do this once since you reuse sets.

 

Thanks

Nicole

Link to comment
Share on other sites

Why do you say this?

 

Have you tried to reassigning an Attribute Set by editing a product and setting the attribute set to the one you want to use for that product.  I will delete any attribtues for that product and then re-add them for that product. 

 

Joey

 

Joey:

 

Let me explain my situation again. Say if I have already assigned three sets to product A, color, size, and text(I have installed the contribution to allow text field as attribute.). At first, it works well. I can see three sets in product A's product_info page.

 

Now, I go to edit set color(for example, I change the sort order of red, green, and yellow.). The result is (1)OK, the sort order of colors are updated correctly, and I can see set color in product A's product_info page. (2)However, set size and set text are no longer assigned to product A, and can't see them in product A's product_info page.

 

I think my problem is set size and set text are deleted when updating the edit of set color but never been added back.

 

Michael Lee

Link to comment
Share on other sites

Why do you say this?

 

Have you tried to reassigning an Attribute Set by editing a product and setting the attribute set to the one you want to use for that product.  I will delete any attribtues for that product and then re-add them for that product. 

 

Joey

 

I have the same prob. - editing a set deleted all my site attrabutes - days of work down the drain :angry:

Link to comment
Share on other sites

hey i just had a thought, maybe its not practical but it seems needed almost.

 

maybe there should be a site with faq about this contribution. i personally LOVE it think its wonderful but sifting through 15+ pages of forum posts to find an answer isnt a way id like to spend my time.

 

seems like it would be simple enough and obviously very easy to host. so i thought id throw the idea out there.

Link to comment
Share on other sites

perhaps reading the forum rules might help you understand why this is not done. 15 pages is not much. and the thing about the 15 pages, you can pretty much find the different answers which may arise.

Link to comment
Share on other sites

perhaps reading the forum rules might help you understand why this is not done.  15 pages is not much.  and the thing about the 15 pages, you can pretty much find the different answers which may arise.

 

 

forum rules eh? didnt know such a thing existed. :) besides it was merely an idea.

Link to comment
Share on other sites

This is not acceptable to me.

 

I emptied my products_attributes, products_attributes_sets, and products_attributes_sets_to_products tables.

 

Then I created a 2 Colors sets and 1 Sizes set.

 

I editted a product and added 1 color set, then I re-editted that product and added the size set and everything is displaying fine in my product_info.php page. I'm puzzled!?!? Did I do it exactly the same way you did?

 

I'm wondering if you installed the "order by" clause correctly in the product_info.php page? Make sure it is sorting my sort_order and not by products_attributes_id!

 

Also, does it display with the right sort_order numbers when you edit the Attribute Set?

Or are they in a decending order (e.g., 3,2,1 vs 1,2,3).

 

Answering this will tell me if it is in the products_info.php page or not.

 

Joey

 

 

 

the sizes are also backwards now for new products. i can live with this as it still saves me so much time but thought youd like to know.

Link to comment
Share on other sites

Yes, this can fix this but there is a much easier way, at least I fix the problem correctly.

 

Going back to the product_info.php page, find the "order by" clause and add a DESC at the end of the clause. This will order the results in a decending order, then once I fix the problem you can just out the DESC and have it work as it should.

 

I may have left a DESC attribute to that clause by accident.

 

Joey

 

 

 

so heres the quck fix for problems w/ sort order in multiple drop down attribute products:

 

MAKE YOUR LIST BACKWARDS.

 

delete the sets you have (sizes, colors) and re enter them completley backwards in order, not chaning the # but the actual order you enter them in. Then add a new product and it will come up in the "correct" order. kinda ghetto, but you should only have to do this once since you reuse sets.

 

Thanks

Nicole

Link to comment
Share on other sites

I THINK YOU GOT IT NOW!!!!!!!!!!!!!

 

(Everyone, please listen!)

 

Yes, if you edit a product with multiple Attribute Sets assigned to it you have to make sure have the Attribute Sets to the Sets you want to show for that product when you click the preview & update button (after editting the product). If you have a product with 3 sets assigned to it, then, pretend you want to modifiy one of the sets assigned to that product so you edit that product and re-assign the changed set for that product but forget to make sure the other 2 sets are still assigned. If you click Preview and Update then that product will only have 1 Attribute Set assigned to it, thus show only 1 drop-down list on the product_info.php page instead of 3. Like always, it is doing exactly what you told it to do - show 1 set.

 

When you edit a product, my code sees which Attribtue Set(s) are assigned to the product and 1st removes all previous sets assigned to this product, then re-adds them to the product. So you may start with 3 sets and end up with 1 set.

 

 

I hope this it all that is required to solve your problem.

 

Joey

 

 

 

 

Joey:

 

Let me explain my situation again. Say if I have already assigned three sets to product A, color, size, and text(I have installed the contribution to allow text field as attribute.). At first, it works well. I can see three sets in product A's product_info page.

 

Now, I go to edit set color(for example, I change the sort order of red, green, and yellow.). The result is (1)OK, the sort order of colors are updated correctly, and I can see set color in product A's product_info page. (2)However, set size and set text are no longer assigned to product A, and can't see them in product A's product_info page.

 

I think my problem is set size and set text are deleted when updating the edit of set color but never been added back.

 

Michael Lee

Edited by joeyjgarcia
Link to comment
Share on other sites

I hear what you are saying. Thank you for the kind words, it really keeps me going when I continue to work with people as they fight through these issues.

 

 

Here are my idea for version 5.0 (after I release version 4.0), having an Attribute Set of Sets.

 

For example, You create a set for "Sizes", then another for "Colors" then you create a set of sets called "Colors and Sizes", this will eliminate the need for re-editting a product to add new Attribute Sets to a product.

 

 

If anyone is wondering where the heck is version coming from, it is in beta testing from my site until I get a fuzzy that it is working fine, this is why I need feedback that it WORKS rather just feedback that it doesn't work (please post back if it works perfectly). You can download it from http://www.goodnewsclothing.com/AttributeSets_v4_0.zip (this was originally post a few pages back).

 

Please post back if it works so I can make it a formal contribution.

 

Thanks,

 

Joey

 

 

 

 

 

forum rules eh? didnt know such a thing existed. :) besides it was merely an idea.

Link to comment
Share on other sites

I looked at my code, and it verified that it is correctly sorting by the sort_order field rather than the products_attribtues_id field.

 

You can search your product_info.php page for this crucial pattern: "order by pa.sort_order" without the quotes.

 

To fix your problem and sort it backwards you can change it to this "order by pa.sort_order DESC"

 

 

If you missed this change from versions 1.0 - 2.1, then you missed the "upgrade_from_2.1_to_4.0.txt" file.

 

Joey

 

 

 

Yes, this can fix this but there is a much easier way, at least I fix the problem correctly. 

 

Going back to the product_info.php page, find the "order by" clause and add a DESC at the end of the clause.  This will order the results in a decending order, then once I fix the problem you can just out the DESC and have it work as it should. 

 

I may have left a DESC attribute to that clause by accident.

 

Joey

Link to comment
Share on other sites

in product_info.php the only "order by" i could find is the following:

 

?php

$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");

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

 

 

not sure if thats where youre talking about since it didnt match your post to a T but i thought id bring it up before i screw something up :)

Link to comment
Share on other sites

I THINK YOU GOT IT NOW!!!!!!!!!!!!! 

 

(Everyone, please listen!)

 

Yes, if you edit a product with multiple Attribute Sets assigned to it you have to make sure have the Attribute Sets to the Sets you want to show for that product when you click the preview & update button (after editting the product).  If you have a product with 3 sets assigned to it, then, pretend you want to modifiy one of the sets assigned to that product so you edit that product and re-assign the changed set for that product but forget to make sure the other 2 sets are still assigned.  If you click Preview and Update then that product will only have 1 Attribute Set assigned to it, thus show only 1 drop-down list on the product_info.php page instead of 3.  Like always, it is doing exactly what you told it to do - show 1 set.

 

When you edit a product, my code sees which Attribtue Set(s) are assigned to the product and 1st removes all previous sets assigned to this product, then re-adds them to the product.  So you may start with 3 sets and end up with 1 set.

 

 

I hope this it all that is required to solve your problem.

 

Joey

 

Joey:

 

Thanks, so let me rephrase your point again for confirmation.

 

For example, set 1, set 2 and set 3 are assigned to product A. Set 1, set 4, and set 5 are assigned to product B. If I edit and update attribute set 1, then set 2 and set 3 will no longer be assigned to product A and set 4 and set 5 will no longer be assigned to product B. Am I right?

 

So, if I edit and update attribute set 1, I have to re-edit product A and B to re-add again set2, 3, 4, 5 to product A, B respectively. Am I right?

 

Sorry for keep bothering you...

 

BTW, besides this issue, Version 4 works well in my site.

 

Michael

Link to comment
Share on other sites

I think you got it.

 

Keep in mind that my contribution only helps to add product attributes to the products_attribtues table. This table is used by the product_info.php page. This page doesn't have any knowledge or relationship to the Attribute Sets, so if you change an Attribute Set and you want a product to reflect this change, then you have to edit a product and if the Attribute Set drop down list on the Edit Product page is showing the changed Attribute Set then you don't even have to change a thing, you just have to click Preview and then Update.

 

For example, lets say you create a set called "Sizes: S-L" with a sort_order or 1,2,3 which will show sizes S, M, L in a drop down list on the product_info.php page.

 

Then you edit the "Sizes: S-L" set and now you changed the sort order to be 3,2,1 which will show sizes L, M, S in a drop down list on the product_info.php page.

 

Just because you editted the "Sizes: S-L" set, doesn't mean that it will be reflected on the product_info.php page, so to make the sizes show in the opposite order (based on you editting the set) all you have to do is edit this product and you DON'T have to change a thing. When you edit the product is will already be showing that this product is using the "Sizes: S-L" set so you don't have to change it, so you just need to click Preview and then Update.

 

This is how you reapply the changes to the modified Attribute Set.

 

Does this make sense?

 

Joey

 

 

Joey:

 

Thanks, so let me rephrase your point again for confirmation.

 

For example, set 1, set 2 and set 3 are assigned to product A. Set 1, set 4, and set 5 are assigned to product B. If I edit and update attribute set 1, then set 2 and set 3 will no longer be assigned to product A and set 4 and set 5 will no longer be assigned to product B. Am I right?

 

So, if I edit and update attribute set 1, I have to re-edit product A and B to re-add again set2, 3, 4, 5 to product A, B respectively. Am I right?

 

Sorry for keep bothering you...

 

BTW, besides this issue, Version 4 works well in my site.

 

Michael

Link to comment
Share on other sites

If this is the case then you are definitely missing the cricial code that sorts this correctly.

 

1st) make sure the sort_order field is in the products_attributes table.

 

2nd) Search product_info.php page for sort_order. In my case it is on line 181, it should be withing 10 lines of this number since I have modified my page from the original code.

 

 

Here is some code that surrounds the correct area:

 

<?php
     $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");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $products_options_query = tep_db_query("select pov.products_options_values_id,
pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, "
. TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and
pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id =
pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'   order by pa.sort_order");
       while ($products_options = tep_db_fetch_array($products_options_query)) {
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }

 

The order by clause is just above the while loop, so this is something you can search on.

 

Hope this helps.

 

Joey

 

 

 

 

 

in product_info.php the only "order by" i could find is the following:

 

?php

      $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");

      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

not sure if thats where youre talking about since it didnt match your post to a T but i thought id bring it up before i screw something up :)

Edited by joeyjgarcia
Link to comment
Share on other sites

Joey:

 

Thanks, so let me rephrase your point again for confirmation.

 

For example, set 1, set 2 and set 3 are assigned to product A. Set 1, set 4, and set 5 are assigned to product B. If I edit and update attribute set 1, then set 2 and set 3 will no longer be assigned to product A and set 4 and set 5 will no longer be assigned to product B. Am I right?

 

So, if I edit and update attribute set 1, I have to re-edit product A and B to re-add again set2, 3, 4, 5 to product A, B respectively. Am I right?

 

Sorry for keep bothering you...

 

BTW, besides this issue, Version 4 works well in my site.

 

Michael

 

 

Joey:

Thank you for great contribution and I can't complain...^^|||

 

 

But the best case to me (though I am not sure if it can be done or not) seems to be when editing and updating set 1, why can't just leave the assignment of set 2,3,4,5 to product A,B as they are....why must delete the assignment of set 2,3,4,5 to product A,B when you are just editing set 1 only...

 

Otherwise, when I edit and update one set, I must manually check all products which this set has been assigned to and re-add other sets been assigned to these products....it's almost an impossible mission to me.

 

As a result, I will not try to edit and upadte a set if it has already been assigned to products.

 

How do you think?

 

Michael

Link to comment
Share on other sites

In reply to "why can't just leave the assignment of set 2,3,4,5 to product A,B as they are"

 

Typically, the end results is the same.

 

I would recommend modifying an Attribute Set only if it is wrong or needs to be re-sorted. Otherwise, I would just create a new set for new attributes, this way you can re-edit the products without recourse.

 

No matter what I do, there is always someone that is not happy. I would encourage you to hack it to meet your needs.

 

Joey

 

 

 

Joey:

Thank you for great contribution and I can't complain...^^|||

But the best case to me (though I am not sure if it can be done or not) seems to be when editing and updating set 1, why can't just leave the assignment of set 2,3,4,5 to product A,B as they are....why must delete the assignment of set 2,3,4,5 to product A,B when you are just editing set 1 only...

 

Otherwise, when I edit and update one set, I must manually check all products which this set has been assigned to and re-add other sets been assigned to these products....it's almost an impossible mission to me.

 

As a result, I will not try to edit and upadte a set if it has already been assigned to products.

 

How do you think?

 

Michael

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...