Hello
1.1.0.2
I know there is a sort order in the attributes, but that does not really help me with our layout, I want to know how to list in value order on the page, so lowest first and pre selected, used to able to do it with the SQL query - order by, but to be honest, not even sure where the query is now.
Could anyone point me in the right direction?
Thank you
David
Attributes order
-
BatteryTrader
- Contributor
- Posts: 153
- Joined: Thu Apr 11, 2024 7:18 am
- Phoenix Version: 1.1.0.3
- Has thanked: 3 times
- Been thanked: 17 times
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Attributes order
Admin > Modules > Layout > {Options & Attributes} > Edit
Change "Enforce Selection" to False.
Change "Enforce Selection" to False.
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
BatteryTrader
- Contributor
- Posts: 153
- Joined: Thu Apr 11, 2024 7:18 am
- Phoenix Version: 1.1.0.3
- Has thanked: 3 times
- Been thanked: 17 times
Re: Attributes order
Thanks for the reply
Sorry, no, perhaps I have not explained myself properly.
On the Products Info page, there might be a few Attributes; they appear to be currently listed in alphabetical order, if the client does not look, then the very first one will be added to the cart with the product.
I require the order to be by price, descending, the first will probably be zero, so, no change.
While I could have it as Please select, that would be a pain to the customer.
I have thousands set up like this currently on my old site that I will be moving over in time, If I remember, I just needed to edit the SQL query sort order, but that was a long time ago, and right now, I can't actually find the query.
I think that having the ability to do this in core makes a lot of sense. Perhaps I am wrong, but I am a shopowner and can say from my experience that anything that makes the customer have to think and read, costs sales or best create a silly phone call.
Kindest regards
David
Sorry, no, perhaps I have not explained myself properly.
On the Products Info page, there might be a few Attributes; they appear to be currently listed in alphabetical order, if the client does not look, then the very first one will be added to the cart with the product.
I require the order to be by price, descending, the first will probably be zero, so, no change.
While I could have it as Please select, that would be a pain to the customer.
I have thousands set up like this currently on my old site that I will be moving over in time, If I remember, I just needed to edit the SQL query sort order, but that was a long time ago, and right now, I can't actually find the query.
I think that having the ability to do this in core makes a lot of sense. Perhaps I am wrong, but I am a shopowner and can say from my experience that anything that makes the customer have to think and read, costs sales or best create a silly phone call.
Kindest regards
David
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Attributes order
They are sorted by the Sort Order set in Admin > Catalog > Products Attributes > Values section.BatteryTrader wrote: ↑Thu May 08, 2025 5:42 pmthere might be a few Attributes; they appear to be currently listed in alphabetical order
For example, in the default installation: https://phoenixcart.org/demo_admin/admi ... ibutes.php
Options > Option Name=Box Size (a Sort Order for this can also be set).
Values > 2 Values for Box Size are set:
Option Value=12, Sort Order=10
Option Value=24, Sort Order=20
Attributes > those Options and Values are set to a Product (Red Tomatoes) with a Value Price.
Going to Admin > Modules > Layout > Options & Attributes (Group: product_info) > Edit
Setting Add Helper Text and Enforce Selection to False then gives this on the product page:
See also on this demo: https://psiwebsites.com/1100/product_in ... ducts_id=5
If understood correctly, that is precisely the desired behaviour you describe.
You do not have the required permissions to view the files attached to this post.
-
BatteryTrader
- Contributor
- Posts: 153
- Joined: Thu Apr 11, 2024 7:18 am
- Phoenix Version: 1.1.0.3
- Has thanked: 3 times
- Been thanked: 17 times
Re: Attributes order
Hi
Thanks for the reply
The Options values can be sorted, but when in some instances, the same value is used on different pages to mean different things then it would make more sense for the order to be dictated by price, else many more options would need to be created (worded slightly differently) to fit the purpose.
Kindest regards
Thanks for the reply
The Options values can be sorted, but when in some instances, the same value is used on different pages to mean different things then it would make more sense for the order to be dictated by price, else many more options would need to be created (worded slightly differently) to fit the purpose.
Kindest regards
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Attributes order
https://github.com/CE-PhoenixCart/Phoen ... er.php#L43 is the line that sets the default sort order.
In any hook that runs after the product is loaded, e.g. in sitewideStart,
If you need something more complicated than that, I'm sure that any of the certified developers could help you work it out.
In any hook that runs after the product is loaded, e.g. in sitewideStart,
Code: Select all
class hook_shop_product_info_sort_by_price {
public function listen_sitewideStart() {
$attributes = $GLOBALS['product']->get('attributes');
uasort($attributes, function($a, $b) {
return $a['price'] <=> $b['price'];
});
$GLOBALS['product']->set('attributes', $attributes);
}
}