Applying Sort Order to Categories and Manufacturers
Applying Sort Order to Categories and Manufacturers
Hi,
What code would i need to amend in order to apply a simple A-Z sort for the Categories and Manufacterers listed in the Product Search Page?
The categories have an up/down arrow method, but this only seems to sort it within admin, however i cannot see any option at all with the Manufacturers section to apply any sorting, either admin or front-end.
How would I achieve this?
Thanks
Andrew
What code would i need to amend in order to apply a simple A-Z sort for the Categories and Manufacterers listed in the Product Search Page?
The categories have an up/down arrow method, but this only seems to sort it within admin, however i cannot see any option at all with the Manufacturers section to apply any sorting, either admin or front-end.
How would I achieve this?
Thanks
Andrew
Re: Applying Sort Order to Categories and Manufacturers
Data source classes for every objects support an overload function with that takes sort expression. You can try passing sort expression when try to load the data. For example CategoryDataSource.LoadForStore(" Name ASC "). Similarly you can load manufacturers as well.
Re: Applying Sort Order to Categories and Manufacturers
Thanks Mazhar,
Where would i update this code? Would this be in the conlib file(s) that are loaded with the specific page, or the product search aspx page itself?
Thanks
Andrew
Where would i update this code? Would this be in the conlib file(s) that are loaded with the specific page, or the product search aspx page itself?
Thanks
Andrew
Re: Applying Sort Order to Categories and Manufacturers
Perhaps you need to do it in ConLib control. Edit the respective conlib and look for loading code over there.
Re: Applying Sort Order to Categories and Manufacturers
Hi,
Well I have found some references in the ascx.cs file of the CategorySearchSidebar conlib, but they do not seem consistent, so i am confused as to whether Ihave found the right code. One is within a region and the other is just within a Void, and seem to refer to NarrowBy, which to me suggests that this is something loaded when you try to narrow the search. I don't have a clue with all this code, but obviously I don't want to amend the wrong code
I cannot find anything that says LoadforStore but the following are similar...
and there is the following code for Categories...
Now possibly I am looking in the wrong conlib file, but this seems to be the most obvious to me and it is the conlib file that is referred to in the CategorySearch Scriptlet.
I would really appreciate any help with this. If anyone has done this before and knows exactly what i need to change, that would be fantastic!
Thanks
Andrew
Well I have found some references in the ascx.cs file of the CategorySearchSidebar conlib, but they do not seem consistent, so i am confused as to whether Ihave found the right code. One is within a region and the other is just within a Void, and seem to refer to NarrowBy, which to me suggests that this is something loaded when you try to narrow the search. I don't have a clue with all this code, but obviously I don't want to amend the wrong code
I cannot find anything that says LoadforStore but the following are similar...
Code: Select all
//BIND THE EXPAND MANUFACTURER LINK
Manufacturer m = ManufacturerDataSource.Load(this.ManufacturerId);
if (m != null)
{
ExpandManufacturerLink.Text = string.Format("{0} (X)", m.Name);
ExpandManufacturerLink.Visible = true;
}
else
{
ExpandManufacturerLink.Visible = false;
}
Code: Select all
#region NarrowByCategoryPanel
protected void BindNarrowByCategoryPanel()
{
Trace.Write(this.GetType().ToString(), "Begin BindNarrowByCategoryPanel");
Trace.Write(this.GetType().ToString(), "Load All Child Categories");
CategoryCollection allCategories = CategoryDataSource.LoadForParent(this.CategoryId, true);
List<NarrowByCategoryData> populatedCategories = new List<NarrowByCategoryData>();
foreach (Category category in allCategories)
{
Trace.Write(this.GetType().ToString(), "Count Items in " + category.Name);
int totalProducts = ProductDataSource.NarrowSearchCount(this.Keyword, category.CategoryId, this.ManufacturerId, 0, 0);
if (totalProducts > 0)
{
populatedCategories.Add(new NarrowByCategoryData(category.CategoryId, category.Name, totalProducts));
}
}
I would really appreciate any help with this. If anyone has done this before and knows exactly what i need to change, that would be fantastic!
Thanks
Andrew
Re: Applying Sort Order to Categories and Manufacturers
I think i may have found another post on this, but i just want to make sure that this is still relevant, and matches what I am after with the manufacturers?
I am not "that" fussed about the Categories, as that is a nice to have, but the Manufacturers is the important one, as that is effectively my Brand.
The link is: viewtopic.php?f=44&t=10102&p=43856&hili ... rch#p43856
Is this the same thing?
Thanks
Andrew
I am not "that" fussed about the Categories, as that is a nice to have, but the Manufacturers is the important one, as that is effectively my Brand.
The link is: viewtopic.php?f=44&t=10102&p=43856&hili ... rch#p43856
Is this the same thing?
Thanks
Andrew
Re: Applying Sort Order to Categories and Manufacturers
ok, just to update:
I have made the changes in accordance with that post, and it has worked. The manufacturers are now sorted in alphabetical order, so that is good
I still cannot get the categories to work though. I tried your suggestion but as there was no LoadforStore, i used the one that said LoadforParent, adding an additional parameter at the end of " Name ASC ". This thre an error about only being able to pass 3 parameters. I tired various changes, replacing parameters, but couldn't get it to work so it is back as it was now
I guess the LoadforParent is just not the correct place for that, the problem is, i have not a clue what is going on with this code, and there is nothing consistent in it, for example, there is not a _Catergories ...... similar to in the above post link that follows the same procedure, so this is very confusing
Like I say, the Manufacturers was the crucial one and this is now working, but i would also like to have the Categories sorted in order too, as to me it makes sense to sort things in Name order, rather than by the id. It makes it so much easier to find things when you have many Categories.
If anyone can help me with this, that would be great, and also any other search pages that i would also need to amend to achieve the same thing
Thanks
Andrew
I have made the changes in accordance with that post, and it has worked. The manufacturers are now sorted in alphabetical order, so that is good
I still cannot get the categories to work though. I tried your suggestion but as there was no LoadforStore, i used the one that said LoadforParent, adding an additional parameter at the end of " Name ASC ". This thre an error about only being able to pass 3 parameters. I tired various changes, replacing parameters, but couldn't get it to work so it is back as it was now
I guess the LoadforParent is just not the correct place for that, the problem is, i have not a clue what is going on with this code, and there is nothing consistent in it, for example, there is not a _Catergories ...... similar to in the above post link that follows the same procedure, so this is very confusing
Like I say, the Manufacturers was the crucial one and this is now working, but i would also like to have the Categories sorted in order too, as to me it makes sense to sort things in Name order, rather than by the id. It makes it so much easier to find things when you have many Categories.
If anyone can help me with this, that would be great, and also any other search pages that i would also need to amend to achieve the same thing
Thanks
Andrew
Re: Applying Sort Order to Categories and Manufacturers
Ignore me!
I feel a complete numpty!!
I have just realised that this can be sorted from the Admin. I thought at first that that just controlled the Admin side sort order, but after re-sorting the categories, this is also reflected in the front-end.
Yes, it will be a manual process each time a new category is added to move it in to the right order, and i suppose there is still a way in the code to sort it on load, but i can live with this approach, at least to allow us to go live until i can work out the code needed to sort when the page loads
Thanks Mazhar
Andrew
I feel a complete numpty!!
I have just realised that this can be sorted from the Admin. I thought at first that that just controlled the Admin side sort order, but after re-sorting the categories, this is also reflected in the front-end.
Yes, it will be a manual process each time a new category is added to move it in to the right order, and i suppose there is still a way in the code to sort it on load, but i can live with this approach, at least to allow us to go live until i can work out the code needed to sort when the page loads
Thanks Mazhar
Andrew
- crockettdunn
- Lieutenant Commander (LCDR)
- Posts: 105
- Joined: Sun Oct 26, 2008 6:32 pm
- Contact:
Re: Applying Sort Order to Categories and Manufacturers
Thanks mazhar!
.LoadForStore(" Name ASC ") was the syntax I was looking for.
Crockett
.LoadForStore(" Name ASC ") was the syntax I was looking for.
Crockett