Forums / Addon Templates / Flexible Attributes addon support

Flexible Attributes addon support

Views: 76,882

Results 141 to 160 of 274
17 Nov 2011, 3:48 PM
#141
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Flexible Attributes addon support

gjh42:

Correct.

I haven't had much need to change attribute sort orders, but you may want to check out the Option Value Sorter (Update All Products' Attribute Sort Orders to match Option Value Default Sort Orders:) as well as the Option Name Sorter.

This is so strange... the Option Name Sorter shows them in the exact order I want them. It's almost like ZC is ignoring the order I am setting. This is maddening!!!

17 Nov 2011, 3:52 PM
#142
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

Have you tried Option Value Sorter > Update All Products' Attribute Sort Orders to match Option Value Default Sort Orders: ?
It may not help, but can't hurt.

17 Nov 2011, 3:54 PM
#143
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

Have you tried Option Value Sorter > Update All Products' Attribute Sort Orders to match Option Value Default Sort Orders: ?
It may not help, but can't hurt.

Yep, unfortunately it didn't make any noticeable change. :(

17 Nov 2011, 4:20 PM
#144
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

I can't think of any other factors for this. There are settings for category/product default sort orders, but I don't know of any for attributes outside of the Option Name Manager and Option Name Sorter. The Attributes Controller has an "update sort to default order" button, though I believe that only applies to values.

17 Nov 2011, 4:23 PM
#145
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

I can't think of any other factors for this. There are settings for category/product default sort orders, but I don't know of any for attributes outside of the Option Name Manager and Option Name Sorter. The Attributes Controller has an "update sort to default order" button.

Just tried the Attribute Update Sort button... no luck. I suppose I will need to just delete the option names and values I have created and recreate them in the order I want them to show up...

17 Nov 2011, 4:41 PM
#146
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

The odd thing is, I have attributes displaying according to sort order, not id, and the display order changes when I change the sort order.

17 Nov 2011, 4:42 PM
#147
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

The odd thing is, I have attributes displaying according to sort order, not id, and the display order changes when I change the sort order.

Yep, that's how it works on my localhost version... it is so strange, like it is ignoring the sort order on the live site.

17 Nov 2011, 5:11 PM
#148
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

OK, I MUST be losing my mind or missing something really obvious, because it still isn't working.

example1.gif shows my table of Option Name values and sort orders.

example2.gif shows a visual explanation of where each of those options will be placed on those four product pages.

Here is my CSS code:

.wrapperAttribsOptions label {font-size: 1.0em;}/*make "label" elements match other text*/
h3#attribsOptionsText {display: none;}/*hide the "Please Choose:" heading*/
h4.optionName {font-size: 1.0em;}
.wrapperAttribsOptions+br.clearBoth {display: none;}/*allow floated attributes to sit side by side if desired*/

/*Titles*/
#wAttrib-9, #wAttrib-10, #wAttrib-11, #wAttrib-12 {
    background-color: #E8E2EE;
    color: #4C1E73;
    float: left;
    font-size: 12px;
    margin: 0 10px 0 0;
	}

/*Juices*/
#wAttrib-13, #wAttrib-17, #wAttrib-22 {
	float: left; 
	clear: left;
	background-color: #e8e2ee;
	margin:0 10px 0 0;
	padding: 5px 20px 5px 5px;
	}

/*Meals and spacer 3*/
#wAttrib-14, #wAttrib-18, #wAttrib-24 {
	float: left; 
	background-color: #e8e2ee;
	margin:0 10px 0 0;
	padding: 5px 5px 5px 5px;
	}
	
/*Meal Bars, spacer 1, spacer 4*/
#wAttrib-15, #wAttrib-19, #wAttrib-23, #wAttrib-20, #wAttrib-25 {
	float: left; 
	background-color: #e8e2ee;
	margin:0 10px 0 0;
	padding: 5px 20px 5px 5px;
	}

/*Smoothies and spacer 2*/
#wAttrib-16, #wAttrib-21 {
	float: left; 
	background-color: #e8e2ee;
	margin:0 10px 0 0;
	padding: 5px 20px 5px 5px;
	}
	

#wAttrib-9  h4.optionName, #wAttrib-10  h4.optionName, #wAttrib-11  h4.optionName, #wAttrib-12  h4.optionName, #wAttrib-13  h4.optionName, #wAttrib-14  h4.optionName, #wAttrib-15  h4.optionName, #wAttrib-16  h4.optionName, #wAttrib-17  h4.optionName, #wAttrib-18  h4.optionName, #wAttrib-19  h4.optionName, #wAttrib-20  h4.optionName, #wAttrib-21  h4.optionName, #wAttrib-22  h4.optionName, #wAttrib-23  h4.optionName, #wAttrib-24  h4.optionName, #wAttrib-25  h4.optionName {
	color:#4C1E73;
	display: none;
}

.wrapperAttribsOptions {
    margin: 0;
}

The example at http://tinyurl.com/87bxoxe is for KS 3 Day and KS 5 Day.

As you can see, both the ID and the Sort Order are in the order I want them... but they are not displaying in that order. Additionally, when I change the "Juice" header text attribute (sort order 1) to sort order 21, it does not change at all on the product page.

I am on ZC 1.3.9d if that helps at all...

Any ideas?

P.S., the attributes in the 100's can be ignored, as they are for other products.

18 Nov 2011, 2:50 PM
#149
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

Hey gjh42, would you be willing to take a look in my admin if I PM'ed you some login credentials?

18 Nov 2011, 4:27 PM
#150
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

I can take a quick look now.

By the way, the "updates for v1.3.9h" that delia posted about are simply a change from the ereg_replace() to the preg_replace() function in one active line (and one commented-out line). It might make a difference for servers running PHP5.3, so changing this in two places in your current copy of attributes.phpphp ereg_replace('txt_', '', $key) to this```php
preg_replace('/txt_/', '', $key)

I had the change in my development copy, so it will be included in the "wrapper improvements" version... yet another mod I just need to test before releasing the new version:)
18 Nov 2011, 4:31 PM
#151
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

I can take a quick look now.

By the way, the "updates for v1.3.9h" that delia posted about are simply a change from the ereg_replace() to the preg_replace() function in one active line (and one commented-out line). It might make a difference for servers running PHP5.3, so changing this in two places in your current copy of attributes.phpphp ereg_replace('txt_', '', $key) to this```php
preg_replace('/txt_/', '', $key)

> I had the change in my development copy, so it will be included in the "wrapper improvements" version... yet another mod I just need to test before releasing the new version:)


Just sent you some login info. :)
18 Nov 2011, 4:54 PM
#152
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

I'm not seeing anything wrong with your attributes settings or admin displays, but the storefront just ignores that sort order. Very weird.

I do note that there are missing defines in your admin homepage Customers box (BOX_TITLE_CUSTOMERS) (caused by COWOA implementation?), which is probably not related, but who knows?

Have you done the code update? Again, that is unlikely to affect the display in the way you are seeing, but it can't hurt to fix it.

18 Nov 2011, 4:58 PM
#153
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

The odd thing is, I have attributes displaying according to sort order, not id, and the display order changes when I change the sort order.
Yep, that's how it works on my localhost version... it is so strange, like it is ignoring the sort order on the live site.What is different about the environment in your localhost and live server? It pretty much has to be something there...

18 Nov 2011, 5:03 PM
#154
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

I'm not seeing anything wrong with your attributes settings or admin displays, but the storefront just ignores that sort order. Very weird.

I do note that there are missing defines in your admin homepage Customers box (BOX_TITLE_CUSTOMERS) (caused by COWOA implementation?), which is probably not related, but who knows?

Have you done the code update? Again, that is unlikely to affect the display in the way you are seeing, but it can't hurt to fix it.

Yep, I did do the code update a day or two ago.

gjh42:

What is different about the environment in your localhost and live server? It pretty much has to be something there...

The live site has had a fair number of customizations done to it over the course of the last year or so... the localhost version was a fresh install. Unfortunately, there may be a number of different things on the live site.

Do you know of a way to track down where in the code it tells the system how to sort the attributes? Maybe there is something that was changed that causes the code to no longer pay attention to the sort order applied in the back-end?

18 Nov 2011, 5:25 PM
#155
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

attributes.php sets the query sort order with this:```php
if ($pr_attr->fields['total'] > 0) {
if (PRODUCTS_OPTIONS_SORT_ORDER=='0') {
$options_order_by= ' order by LPAD(popt.products_options_sort_order,11,"0")';
} else {
$options_order_by= ' order by popt.products_options_name';
}

18 Nov 2011, 5:40 PM
#156
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

Oops, didn't see that the previous try at this post actually posted:)

The corresponding database field stores the products_options_sort_order value, but I'm not sure where the PRODUCTS_OPTIONS_SORT_ORDER constant's value is set. It is not defined in a PHP file, so it must be set in admin and stored in the db, then retrieved at runtime. I've never been able to find out how/where stored settings are turned into constants for use.

18 Nov 2011, 6:56 PM
#157
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

Oops, didn't see that the previous try at this post actually posted:)

The corresponding database field stores the products_options_sort_order value, but I'm not sure where the PRODUCTS_OPTIONS_SORT_ORDER constant's value is set. It is not defined in a PHP file, so it must be set in admin and stored in the db, then retrieved at runtime. I've never been able to find out how/where stored settings are turned into constants for use.

I did a comparison of all files that contain "PRODUCTS_OPTIONS_SORT_ORDER" via Dev Toolkit in the localhost files and the live site files. the only difference I found was in admin/option_name.php:

Localhost:
Line #37 : $db->Execute("UPDATE " . TABLE_PRODUCTS_OPTIONS . " set products_options_sort_order= " . (int)$_POST['products_options_sort_order'][$id] . " where products_options_id=" . (int)$id . " and language_id=" . (int)$_GET['lng_id']);

Live Site:
Line #37 : $db->Execute("UPDATE " . TABLE_PRODUCTS_OPTIONS . " set products_options_sort_order= " . $_POST['products_options_sort_order'][$id] . " where products_options_id= $id and language_id=" . $_GET['lng_id']);

I modified the live site's file to match the code in the localhost file, but it did not make any difference. Still stumped...

18 Nov 2011, 6:59 PM
#158
hockey2112 avatar

hockey2112

Zen Follower

Join Date:
Jun 2010
Posts:
204
Plugin Contributions:
0

Re: Flexible Attributes addon support

gjh42:

attributes.php sets the query sort order with this:```php
if ($pr_attr->fields['total'] > 0) {
if (PRODUCTS_OPTIONS_SORT_ORDER=='0') {
$options_order_by= ' order by LPAD(popt.products_options_sort_order,11,"0")';
} else {
$options_order_by= ' order by popt.products_options_name';
}


Hmmm... so the code says to order it by the sort order, and if that doesn't work then order them by option name in alphabetical order, right? It does indeed seem to be ordering it by name right now (Juice 1, Juice 2, Juice 3, Juice Choice, etc...). I wonder if that code could be tweaked to tell it to sort by ID instead, since I added the options in the order I want them to show up...


I changed order by popt.products_options_name to order by popt.products_options_id and it looks like it's gonna work!!!! I need to add a few CSS modifications, but I think I'm on to something here. I'll post back here with my final results.
18 Nov 2011, 8:00 PM
#159
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

Somehow there is a PRODUCTS_OPTIONS_SORT_ORDER constant that should be generated (or should be empty or '0' or null); if that is 0 then the correct sort order is used. If it has a nonzero value, then the name sort is used.

So the real question is how to control that constant. If that can be done, the stock code will work correctly. Until then, a tweak may be what you need to get on with the rest of your work.

18 Nov 2011, 8:03 PM
#160
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Flexible Attributes addon support

I would copy the desired statement to replace the name statement for now:```php
if (PRODUCTS_OPTIONS_SORT_ORDER=='0') {
$options_order_by= ' order by LPAD(popt.products_options_sort_order,11,"0")';
} else {
//$options_order_by= ' order by popt.products_options_name';
$options_order_by= ' order by LPAD(popt.products_options_sort_order,11,"0")';
}