last day (15 days later) » 

7:51 AM
0
A: How to convert Magento 2 Sort By Dropdown to Horizontal List

NaveedOpen your theme /Magento_Catalog/templates/product/list/toolbar/sorder.phtml file and replace your select block with this code below : <?php foreach ($block->getAvailableOrders() as $_key => $_order): ?> <a href="<?php echo $block->getPagerUrl("product_list_order=".$_key) ?>"

 
Hi, Thanks for the reply. But I was getting empty query string parameter but on hover on the link it was showing with parameter. Please look at the below URL. http:www.example.com/categoryname?product_list_order=
 
which version of magento are you using ? i have tested this in 2.2.0 and it is working fine for me. $_key should be printing attribute name/code, try to echo $_key and check if you get any value
 
I was using Magento 2.2.1. When I look in Console for I was getting this XHR finished loading: POST "http://localhost:8888/mage2/fashion/women/tops-blouses.html‌​?product_list_orde‌​r=‌​".
 
cod you share your complete code block / file
 
Updated the Question Please check it.
 
7:51 AM
try to remove (value) / change data-role, id="sorter" data-role="sorter" class="sorter-options"
Hello Raghav
 
8:42 AM
Hello Naveed
I didn't understand what this is "try to remove (value)"
What should I need to do ?
 
9:22 AM
hello
sorry i was away after waiting a while
 
Its Okay Naveed
Its my I've to wait :)
work*
 
what issue are you facing ?
this code should be working fine
 
I can able to print the dropdown list to normal list items
I've replaced my code with your code but now what happening is when I hover on the link it was showing me the sortable URL
But when I click on it. Query string parameter was missin
missing*
 
9:59 AM
what if you just debug by <?= $_key; ?> does it show any value
 
10:22 AM
H
Hi Naveed
Found Issue
 
what is the issue ?
 
With the Code you sent to me was generating url and redirecting to the particular sorted page
Getting Conflict in this <div id="sorter" data-role="sorter" class="sorter-options">
 
are you implementing code in custom theme ?
 
Yes
 
yes it could also be the reason, didn't you change the ids and role in div ?
 
10:29 AM
But here when I use that div
I was not seeing any results
 
so did you fix the issue ?
or found the issue for now
 
Only Found the Issue
 
okay do you have any other extension setup ?
 
No I was using Porto Magento 2 Theme
 
for listing page, like infinite scroll etc
 
10:32 AM
Yes
Infinite scroll
But I came with the Theme itself
Infinite scroll and Ajax page load
 
you have to make changes in infinite scroll module template then, because it is overriding functionality of toolbar
i tried with 2.2.1 also it code working fine
earlier i had tried with 2.2.0
 
If I Change IDs in this toolbar
it won't work ?
 
i am doubtful on that, because ajax always work with ids, give it a try and see if it works
getPageUrl is method of toolbar.php block
check if your ajax extension have any method for page url, if it does then use that method for urls
 

last day (15 days later) »