Page 1 of 1
Adding new Sort Option
Posted: Tue Sep 02, 2025 6:58 pm
by levelup
Hi! I'm looking for a way to add another sort option for the dropdown for the product listing pages. I've added an image here for further context, but for the life of me, I cannot find a way to make any changes within the admin folders/files.
Is this possible? If so, do you have any recommendations on files/folders I could review?
Thanks in advance here for any details sent my way.
Re: Adding new Sort Option
Posted: Tue Sep 02, 2025 7:20 pm
by burt
What is the `Sort Option` you want to add ?
I *think* it's possible with a Hook, but getting some more details from you, might help to illuminate a way forward.
--
Side Note; always state Phoenix Version when asking for help.
Re: Adding new Sort Option
Posted: Tue Sep 02, 2025 9:34 pm
by levelup
burt wrote: ↑Tue Sep 02, 2025 7:20 pm
What is the `Sort Option` you want to add ?
I *think* it's possible with a Hook, but getting some more details from you, might help to illuminate a way forward.
--
Side Note; always state Phoenix Version when asking for help.
I figured it out, sorta, I just added what I'm looking to do (add a product list column to sort by) in the configuration database table, and it showed up as an option under Product Listing.
Ultimately, what I'm trying to do is add a 'PRODUCT_LIST_MSRP' option to sort by and include in the sortable_product_columns. This was part of a rabbit hole I went down to see how I could override sortable_product_columns, but I couldn't figure out a way to create a hook...it was a whole thing.
Sidenote, Burt, thank you for your help here and there over the years. You've been so insightful, even in the old osCommerce days. You,
@ecartz and
@raiwa have definitely inspired me to become a better developer, even with my inadequate hook creation capabilities.
Re: Adding new Sort Option
Posted: Wed Sep 03, 2025 1:50 pm
by burt
TY for the kind words @levelup - appreciated.
Back to this;
I am not sure that just adding to the DB would make anything work in the Shop Side.
If you set your new option to show, does it actually show in the Shop Side on the dropdown menu in the listings?
If it does show, does it do what you want (ie order by MSRP asc/desc).
Re: Adding new Sort Option
Posted: Wed Sep 03, 2025 2:39 pm
by levelup
burt wrote: ↑Wed Sep 03, 2025 1:50 pm
TY for the kind words @levelup - appreciated.
Back to this;
I am not sure that just adding to the DB would make anything work in the Shop Side.
If you set your new option to show, does it actually show in the Shop Side on the dropdown menu in the listings?
If it does show, does it do what you want (ie order by MSRP asc/desc).
Of course! And, sure, so I've included a couple of more screenshots. The screenshots show segments of the Product Listing configuration page with details I added to the database. After that, I edited the sortalbe_product_columns.php page and added the new column specification details I wanted to include for the MSRP.
Re: Adding new Sort Option
Posted: Wed Sep 03, 2025 3:45 pm
by burt
levelup wrote: ↑Wed Sep 03, 2025 2:39 pm
I edited the sortalbe_product_columns.php page and added the new column specification details I wanted to include for the MSRP.
Depending on Phoenix Version, I think this is a template component - so you could override it in your template.
And, again depending on Phoenix Version, I think this has a hook listener so you could add your new column_specification with a Hook.
You would probably not do both of those things, but certainly one or the other.
Either way, it leaves the Core File untouched, good for the future.