Jump to content

Custom Sorting within a Category


strandoo
 Share

Recommended Posts

I've got an existing site where the client wants to add a custom sort order to his products when viewed on the Categories page. Categories are a Page field type and the products are already manually sorted by Product Type. And a product can appear in more than one category. If it were a 1-to-1 relationship, I'd just add an integer field to the product for a custom sort order field. But some products have 1 category, some have 4. Some categories apply to only a dozen or so product; some apply to 300 or 400. (He's supplied a spreadsheet to import). 

Even if I figure out how to sort these, will the client be able to add new products and alter/insert a sort order? 

Here's an illustration:

Products (Actual page hierarchy in the Admin. These are sorted manually and appear in this order on the front end when viewing a 'Product Type' page)
- Bracelets
-- Product 1
-- Product 2
-- Product 3
- Earrings
-- Product 4
-- Product 5
...

In the front end, when viewing by Category, we'd like to display the products in a custom order per category:
- Amber - $pages->find("template=product,  category=$page->title, sort ???")
-- Product 1 
-- Product 4
-- Product 3

- Silver
-- Product 2
-- Product 5
-- Product 3
...

When I thought he was only going to sort the first page of results (18 or so), I was going to add a new page field type for each category so the client could select a limited amount of products to display first (I do this for the 'related products' section of the product page). Then I would select these first, then select the unsorted products (minus the first batch) and append them. But since the client wants to sort hundreds of products this way, I don't think this method would be practical.

I've seen a similar post where Teppo uses a single field as an array, but I'm not sure if this would work or if I could populate the field from my spreadsheet.

I welcome any ideas! Thanks.

 

Link to comment
Share on other sites

Hi @Zeka Thanks, but I probably haven't explained it correctly. The Category pages are not actual page trees (the products are already organised under as pages under the product type pages; I use sort=sort on those). The Category pages  have no children and fetch their related content not as children but with a 'find' selector. The client wishes to reorder pages differently under Categories than their 'natural' order under Product Type.

Link to comment
Share on other sites

Ohh, sorry, my bad. I don't think that there is something built-in that will fully accomplish your request. You can try to adapt fieldtype from this post

or develope custom module based on ProcessPageList module to control additional sorting of your product pages per category.

Maybe someone else can provide better advice. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...