Sorting products by price

avdistribution's picture

I'd like to see a way to sort products by price or other ways in the product list. I've tried to make it work with advanced search features and using a java script table sorter. The java script sorts one page fine but doesn't sort across multiple pages.


Tricky, but Possible

thelimit's picture

It is possible to arrange the search results by price. The related documentation resides at
http://workspace.smilehouse.com/manual/Manual?id=visual.xmlhid_advanceds...

Just to be clear, I say that one just has to add the 2 lines to the code of the Advanced Search form.

The 2 lines that trigger the sorting:


<input name="advancedsearch.orderby" value="price" type="hidden">
<input name="advancedsearch.orderby.direction" value="desc" type="hidden">

Form code of an Advanced Search field that searches the products by the first product option and arranges the search results in a price descending order:


<form accept-charset="UTF-8" method="POST" name="AdvancedSearch" action="PublishedService" encoding="UTF-8" enctype="application/x-www-form-urlencoded">
<input name="file" value="page" type="hidden">
<input name="pageID" value="20" type="hidden">
<input name="action" value="advancedsearch" type="hidden">
<input name="advancedsearch.attributes" value="variable1" type="hidden">

<input name="advancedsearch.variable1" type="text" value="M" >
<input name="advancedsearch.variable1.type" value="option" type="hidden">

<input name="advancedsearch.orderby" value="price" type="hidden">
<input name="advancedsearch.orderby.direction" value="desc" type="hidden">

<input type="submit" value="Search by size">
</form>

Regards,
Martin Vahi (from Smilehouse)

The problem with that code

avdistribution's picture

The problem with that code is that it pulls in all products on the site instead of just the selected product group: Test page can be seen here: http://avdistributionllc.shop.wosbee.com/PublishedService?file=&pageID=3...

What I'm trying to do is have a sort by price option that returns a results page with ONLY the products from the selected product group in it so a customer can shop by price within a catgeory. It would have one selectable input field with "asc/desc" option and then a "sort by price" submit button right next to the "number of products in this category" text. I could probably figure it out with the information you've given me, but I'm not very good with code!

http://a-vdistribution.com

To add search by groups you

ignition's picture

To add search by groups you will need to use 1 of 3 variables that will allow you to do that

advancedsearch.groupcode - Search from productgroup with groupcode

advancedsearch.gid - Search from productgroup with group's database id

advancedsearch.path - Search from product group with group path

you can find more about them here
http://workspace.smilehouse.com/manual/Manual?id=visual.xmlhid_advanceds...

Personally I would recommend groupcode since its the easiest
You will need to insert in your code something like that

<select name="advancedsearch.groupcode">
<option>All</option>
<option value="01">Clubs</option>
<option value="02">Bags</option>
<option value="03">Special Offers</option>
</select>

Of course you can modify it as much as you want.
PS. You can enter group code value in Products module by selecting some product group and clicking modify in product group manager.

Did this answer helped you?

I saw that on the advanced

avdistribution's picture

I saw that on the advanced search page and it's great, but I'm trying to avoid making the customer select the product group to search from again. In other words, the customer has selected a group and landed on the product list page. I'd like them to be able to sort the products in that group by price, without having to choose the group again. So Wosbee would have to know somehow to limit the search by price option to the products within the already selected group.Here's an example of what I mean:
http://www.walmart.com/search/browse-ng.do?ic=48_0&ref=125875.183815&cat...
Note the "Sort by" box at the top.

http://a-vdistribution.com

I hope this will help

ignition's picture

Ah I think I understood what you mean.
You will need to go to Visual->Page construction->"Product information" slot
And select there "Product list" to modify. When the window opens go there go to second element (Product list) and select it.

There in Start HTML insert something like

<form accept-charset="UTF-8" method="POST" name="AdvancedSearch" action="PublishedService" encoding="UTF-8" enctype="application/x-www-form-urlencoded">
<input name="pageID" value="20" type="hidden">
<input name="action" value="advancedsearch" type="hidden">
<input name="advancedsearch.attributes" value="price" type="hidden">
<input name="advancedsearch.variable1.type" value="option" type="hidden">
<input name="advancedsearch.orderby" value="price" type="hidden">
<select value="" name="advancedsearch.orderby.direction" class="advanced_dropdown">
<option selected="selected">No direction</option>
<option value="desc">Descending</option>
<option value="asc">Ascending</option>
</select>
<input name="advancedsearch.gid" value="$group_id$" type="hidden">
<input type="submit" value="Sort by Price">
</form>

Now every time user chooses some group he will be able to sort it by Price.
Mind you that most important here is

<input name="advancedsearch.gid" value="$group_id$" type="hidden">

the rest you can modify as much as you want.

Hope it will help you :)

I tried it exactly as you

avdistribution's picture

I tried it exactly as you suggested and the search STILL returns every product in the database instead of just the products in the selected group. The group has 21 products-but 55 get returned in the search. Is the $group_id$ the group code? Is there some way to limit the search results to only the group that has been selected?

http://a-vdistribution.com

Very strange. I double

ignition's picture

Very strange. I double checked the code - everything is working fine here. It returned only products from certain group.

Can I please see the code that you use?
And the URL of the place where you use it.

PS. I'm going on small vacation, so the reply may come only next week. Or someone else may answer :)

I used the exact code you

avdistribution's picture

I used the exact code you provided on a test site - here's the product group page url:
http://avdistributionllc.shop.wosbee.com/PublishedService?file=&pageID=3...
I should add I tried both group code as it appears in the url (301) and the text name of the group from the products module (Two Way Radios).

http://a-vdistribution.com

Hmm compared the code

ignition's picture

Hmm compared the code between yours and my version
the only difference is here

this is from your form
< form accept-charset="UTF-8" target="" method="post" action="http://avdistributionllc.shop.wosbee.com/PublishedService?" name="productList" enctype="application/x-www-form-urlencoded">

and thats from mine

< form accept-charset="UTF-8" method="post" name="AdvancedSearch" action="PublishedService" encoding="UTF-8" enctype="application/x-www-form-urlencoded">

you can see my test page here

http://ignition.shop.wosbee.com/PublishedService?file=page&pageID=3&acti...

PS you don't have to put group code or name in the code
all you have to do is to put there this $group_id$ and the Wosbee will replace it later automatically when you choose some group. :)

I copy/pasted the code from

avdistribution's picture

I copy/pasted the code from above-I don't know why it changes when it gets saved in Workspace. When I switched to the same b to c theme you're using it works fine. If you try it in the b2b theme I'm using, you'll see it doesn't work right. I wonder why that is? Thanks for persevering!
http://a-vdistribution.com

Finally............

avdistribution's picture

Ok, I think it figured it out. I had set up my product groups as root groups instead of under one of the existing root groups (b to c etc) and then used "display all groups" in the visual/settings module. When I move my group to the b to c root group and change the setting to "display b to c", it works fine.
http://a-vdistribution.com

The sort works, but the $add$ button doesn't..............

avdistribution's picture

When I add the sort function to the product list and search results pages, the $add$ variable stops working. Bizarre! Anyone have any idea how to fix?

http://a-vdistribution.com

The sort works, but the $add$ button doesn't..............

roman's picture

Hello!
I have looked in manual the list of all variables and I have not found a variable $add$. You mean what variable?
Here is the list of all variables
http://workspace.smilehouse.com/manual/Manual?id=all-contexts-alphabetic...
Best regards,
Roman

In the b2b restricted theme,

avdistribution's picture

In the b2b restricted theme, $add$ is the default variable in the product list/card/spot for the add to cart function. It may not be in the list but it works the same as $product_add_action$.
When I put the sorting code you guys provided on the product list page, it sorted fine but as I said, when I clicked on the add button. nothing happened either on the product list page or the search results page. I left it that way on my test site so you can see what I mean and look at the underlying code.:
http://avdistributionllc.shop.wosbee.com/PublishedService?file=&pageID=3...

The only way I could get it to work was to use 2 product list wae's with the sorting code in the start html section of the first and the rest of the product list code in the second. I have no idea why I thought this would work, but it does. Here's a working page:
http://avdistribution.shop.wosbee.com/PublishedService?file=&pageID=3&ac...

I also tried to add the sort function to the search results page, so a customer could resort after landing on that page, but that returned all products on the site again so I'm guessing that can't be done, unless you can suggest a way. .

http://a-vdistribution.com

In the b2b restricted theme

roman's picture

Hello!
I have checked up two your references in a browser Mozilla, sorting, addition of the goods and the order work. In the first reference the Shipping Calculator works only after sorting, in the second reference the Shipping Calculator does not work.
Best regards,
Roman