in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Catalog Default Sort Order?

Last post 07-22-2008 3:17 PM by MrBruce. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 07-14-2008 9:31 AM

    • MrBruce
    • Top 10 Contributor
    • Joined on 02-11-2008
    • Juno Beach, FL
    • Posts 120

    Catalog Default Sort Order?

    My client would like to see the products on a Catalog page sorted alphabetically when the page initially loads. (He understands that the customer can filter the results based on price, manufacturer, or alpha/reverse alpha, but would prefer, if the customer does nothing, for the results to be presented in alpha order.)

    I've looked at catalog.aspx and controls/catalogList.ascx, and haven't been able to figure out how to accomplish this. Any ideas or suggestions???

    Can anybody point me in the right direction?????

    --
    Bruce
    Filed under:
  • 07-22-2008 9:34 AM In reply to

    • MrBruce
    • Top 10 Contributor
    • Joined on 02-11-2008
    • Juno Beach, FL
    • Posts 120

    Re: Catalog Default Sort Order?

    My client would REALLY like for me to make this happen.... does anybody have any ideas on where I can look to find and adjust the appropriate query???

    --
    Bruce
  • 07-22-2008 9:57 AM In reply to

    Re: Catalog Default Sort Order?

    Hi Bruce,

    In catalog.aspx.cs in the LoadProducts method, you can try adding .Sort(Product.Columns.Name, true) to the queries. So, the default query (the last one in the if . . . else construct) would look like:

    pagedDataSource.DataSource = Store.Caching.ProductCache.GetProductsByCategoryId(categoryId).Sort(Product.Columns.Name, true);

    That should do it. Hope this helps.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-22-2008 10:25 AM In reply to

    • MrBruce
    • Top 10 Contributor
    • Joined on 02-11-2008
    • Juno Beach, FL
    • Posts 120

    Re: Catalog Default Sort Order?

    Thanks, Chris!

    I tried adding the SORT to the default query, and had no luck, so I added it to the other two queries as well. Still no joy! Take a look at the stopre at:

    http://www.AquaticsToGo.com/default.aspx - and select Crabs as an example... it's readily apparent that no alpha order sorting has happened! Here's the modified LoadProducts method:

    /// <summary>
    /// Loads the products.
    /// </summary>
    private void LoadProducts()
    {
    pagedDataSource.AllowPaging =
    true;
    pagedDataSource.PageSize = Master.SiteSettings.CatalogItems;
    int currentPageIndex = 0;
    int.TryParse(Utility.GetParameter("p"), out currentPageIndex);
    pagedDataSource.CurrentPageIndex = currentPageIndex;

    if (manufacturerId > 0)
    {
    pagedDataSource.DataSource = Store.Caching.
    ProductCache.GetProductsByCategoryIdManufacture(categoryId, manufacturerId).Sort(Product.Columns.Name, true);
    }
    else if (priceStart >= 0 && priceEnd > 0)
    {
    pagedDataSource.DataSource = Store.Caching.
    ProductCache.GetProductsByCategoryIdPriceRange(categoryId, priceStart, priceEnd).Sort(Product.Columns.Name, true);
    }
    else
    {
    pagedDataSource.DataSource = Store.Caching.
    ProductCache.GetProductsByCategoryId(categoryId).Sort(Product.Columns.Name, true);
    }

    topPager.PagingTitle = category.Name;
    bottomPager.PagingTitle = category.Name;
    topPager.PagedDataSource = pagedDataSource;
    bottomPager.PagedDataSource = pagedDataSource;
    catalogList.PagedDataSource = pagedDataSource;
    }

    Have I misinterpreted your instructions?

    --
    Bruce
  • 07-22-2008 11:39 AM In reply to

    Re: Catalog Default Sort Order?

    Nope, you've got it spot on. It looks like SubSonic isn't doing the sort. Let me experiment a bit and see if I can come up with something.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-22-2008 11:57 AM In reply to

    • MrBruce
    • Top 10 Contributor
    • Joined on 02-11-2008
    • Juno Beach, FL
    • Posts 120

    Re: Catalog Default Sort Order?

    Thank you, sir... I look forward to your results!

    --
    Bruce
  • 07-22-2008 12:03 PM In reply to

    Re: Catalog Default Sort Order?

    Yeah, some goofiness in SubSonic is keepng it from working as expected.

    So, to get this to work, you have to do a couple of things:

    1.) Add in a ProductCollection

    2.) set the productCollection to the the results of the query

    3.) THEN, use the Sort method

    3.) THEN, bind it to the pagedDataSource

    So, my code looks like this:

          ProductCollection productCollection = null;
    
          if (manufacturerId > 0) {
            productCollection = Store.Caching.ProductCache.GetProductsByCategoryIdManufacture(categoryId, manufacturerId);
          }
          else if (priceStart >= 0 && priceEnd > 0) {
            productCollection = Store.Caching.ProductCache.GetProductsByCategoryIdPriceRange(categoryId, priceStart, priceEnd);
          }
          else {
            productCollection = Store.Caching.ProductCache.GetProductsByCategoryId(categoryId);
          }
          productCollection.Sort(Product.Columns.Name, true);
          pagedDataSource.DataSource = productCollection;
    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-22-2008 12:46 PM In reply to

    • MrBruce
    • Top 10 Contributor
    • Joined on 02-11-2008
    • Juno Beach, FL
    • Posts 120

    Re: Catalog Default Sort Order?

    admin:

    Yeah, some goofiness in SubSonic is keepng it from working as expected.

    I love it when you talk "technical!"  Wink

    Okay... I think I did what you described, and I'm still having no luck. Here's my newly modified method:

    /// <summary>
    /// Loads the products.
    /// </summary>
    private void LoadProducts()
    {
    pagedDataSource.AllowPaging =
    true;
    pagedDataSource.PageSize = Master.SiteSettings.CatalogItems;
    int currentPageIndex = 0;
    int.TryParse(Utility.GetParameter("p"), out currentPageIndex);
    pagedDataSource.CurrentPageIndex = currentPageIndex;

    ProductCollection productCollection = null;

    if (manufacturerId > 0)
    {
    productCollection = Store.Caching.
    ProductCache.GetProductsByCategoryIdManufacture(categoryId, manufacturerId);
    }
    else if (priceStart >= 0 && priceEnd > 0)
    {
    productCollection = Store.Caching.
    ProductCache.GetProductsByCategoryIdPriceRange(categoryId, priceStart, priceEnd);
    }
    else
    {
    productCollection = Store.Caching.
    ProductCache.GetProductsByCategoryId(categoryId);
    }
    productCollection.Sort(
    Product.Columns.Name, true);
    pagedDataSource.DataSource = productCollection;

    topPager.PagingTitle = category.Name;
    bottomPager.PagingTitle = category.Name;
    topPager.PagedDataSource = pagedDataSource;
    bottomPager.PagedDataSource = pagedDataSource;
    catalogList.PagedDataSource = pagedDataSource;
    }

    Where did I mess up???

    --
    Bruce
  • 07-22-2008 3:03 PM In reply to

    Re: Catalog Default Sort Order?

    Answer

    hmm - that should work. It works on my machine. Stick out tongue

    You may want to try rebuilding the solution.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
  • 07-22-2008 3:17 PM In reply to

    • MrBruce
    • Top 10 Contributor
    • Joined on 02-11-2008
    • Juno Beach, FL
    • Posts 120

    Re: Catalog Default Sort Order?

    I rebuilt.

    It works.

    You rock.

    Thank you!

    --
    Bruce
Page 1 of 1 (10 items)