Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

120 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
1k views

Magento 2 - sorting order of products in a widget block

I created a block and a widget in admin panel to show products that fit some criteria(in a specified category) on home page. When I finished the setting, I found that the sorting order of the ...
6
votes
1answer
218 views

Add new options into sorter

In magento 2 project, it provides 3 options by default. Position Product Name Price I need to change these options to sort as, Most Popular Price high to low Price low to high I can add from ...
5
votes
1answer
627 views

How do I make this custom expression column I have developed for the customer grid display sortable?

I'm trying to add an expression column to collection in customer grid. But it not sortable. I'm not sure that using addExpressionAttributeToSelect or addExpressionFieldToSelect function can solve this ...
4
votes
0answers
534 views

Multiple Sort order in magento

I currently have a pretty standard magento setup. I have the general sort orders, price, release date, name. What I want to do is add an extra level to each sort order. So they would be release date, ...
3
votes
0answers
41 views

Position not showing in category sorting dropdown

I have a problem with the sort order of products in the categories: The Position option is not showing in the dropdown as you can see in the screenshot. In the Magento backend the position is ...
3
votes
1answer
587 views

Product collection sorting broken in Magento 2.3?

I am trying to sort by price on a product collection query, however, it seems sorting by price is reducing the result set to 0... Here is a working query which returns expected number of products (...
3
votes
0answers
193 views

Bulk change “Available Product Listing Sort By” for all categories?

I have a big Magento Store with about 200 categories. Currently, "Available Product Listing Sort By" for all categories is set to "Use All Available Attributes". For about 10 categories, I would like ...
3
votes
1answer
148 views

Sort categories in layered navigation alphabitically

We are trying to sort the categories in the layered navigation alphabetically but it is not getting sort. Tried the following modifications directly in core file at line number 122 for testing ...
3
votes
1answer
584 views

Sorting Attribute (with custom source model) by dropdown label

I have a custom attribute called collection (in retrospect, a horrible name all things considered,) with a custom attribute source model. The important part is here: public function getAllOptions() { ...
2
votes
1answer
27 views

Custom Sorting on category page not working in Magento 2.4.2

I have Magento 2.4.2. I have written a custom code to add A-Z & Z-A filters on category page. I have added dependency injection using below code <preference for="Magento\Catalog\Block\...
2
votes
2answers
611 views

Elastic Search: Custom sorting options not working after enable elastic search

I'm trying to add custom sorting options like newest products,price high-to-low & price low-to-high in category page using plugin. After creating plugin it's working good in category page and ...
2
votes
2answers
84 views

Sorting on a date's component

For Magento 1.x How do I sort product based on a date attribute by a month and year only, rather than on the whole date? The code looks a bit like this: Mage::getSingleton('...')->...
2
votes
0answers
25 views

Magento2.2.7 PLP sorting breaks after we place orders

Whenever we place an order on store front and come back to any category page, the sorting is not working(sorting breaks) . To fix this we needed to run a reindex on the below indexers and clear the ...
2
votes
0answers
993 views

magento 2 : Product listing default sorting order based on attributes

i have add sort by attributes to products say like below one. "Publish date" "Product Name" "Price" Now i want to change sort order based on default attributes. For eg 1: Publish date -> Descending ...
2
votes
0answers
739 views

Magento 2 sort category programmatically by alphabet ascending order

I want to sort category programmatically by alphabet ascending order. I am able to append category programmatically by below code. But I can not able to sort category by code.
2
votes
0answers
65 views

The magento custom sorting functionality is not working

I am creating a Magento module to add a sorting option of a bestseller on the category page. For doing so I have to override few classes in the core. In the beginning, I have created config.xml file. ...
2
votes
0answers
217 views

Magento 2 How can i Change Sortorder in fornted order_view.xml in order_total

I want to change sorting order in order_total block in frontend order view page. can any one tell me how i can change sorting order.
2
votes
1answer
234 views

Sorting by Custom Attribute value/id

I'd like to add a custom attribute to listing products toolbar. This is a dropdown attribute, that looks like this: Available today Available in 1-5 days Available in 5-10 days I have set "Used for ...
2
votes
0answers
101 views

Magento 2 how to do multi sorting of product on product list page

In magento 2 by default we can sort product by product attribute, but we can do sorting with only one attribute at a time. I need to do sorting on multiple attributes. If anyone know how can i ...
2
votes
0answers
514 views

Magento 2 : How to add sorting option to review?

I need to add sorting option (By New, By Old, By Highest Rating, By Lowest Rating) to review section in Magento 2.1 Product Detail View. So that the customer can sort ratings using the drop down.By ...
2
votes
0answers
322 views

Magento 1.9: How to sort product list by alphabetically A ,B, C,D … to Z

How to sort product by alphabetically in product list page in magento 1.9 I want to display sorting like below image
2
votes
2answers
1k views

Sorting a custom column - Customer Grid

I have added in order count and last order date to the customer grid which is working fine, however it is not sortable or filterable in the grid. I have done some searching but can't seem to find a ...
2
votes
1answer
544 views

Sort Order of Image gallery is not working for Magento 1.9

I'm using Magento 1.9.2.4 and there is feature for product using which one can sort images for gallery, but for me it is not working, actually the changes of sorting order are not saved. Any other ...
2
votes
0answers
683 views

catalog search result default sortBy by multiple attributes at once

I want to sort my catalog search result by multiple attributes. For default sorting by price I have added below code in xml file : ... <catalogsearch_result_index> <reference name="...
2
votes
0answers
3k views

Changing a custom attribute's sort order in Default Product Listing Sort By in Display Settings

I have a custom attribute called Select Photographer which appears in the category display settings area like so: This then allows users to use the Sort By to Group Photographers By Name A-Z or ...
1
vote
0answers
28 views

Magento 2.4.2 and elasticsearch issue (sort by position)

As I have seen, sort by "position" does not work with Elasticsearch (I have no result when I want to see the products in a category). I would like to disable position sorting on ALL ...
1
vote
0answers
26 views

Sorting Products at Category Page

Is there a way to bulk update products position at Category Page importing a CSV file via System -> Data Transfer -> Import ? Cordially, Daniel Mas
1
vote
0answers
548 views

Magento 2 GrahQL Product Sorting does not work for the product query with category Filter

I have this graphQL query { products(filter: {category_id:{eq: "5"}, price: {from: "0", to: "999999"}}, pageSize: 10, currentPage: 1 sort: {position: DESC}) { ...
1
vote
0answers
205 views

Sort Menu items in aphabetical order magento 2 in observer

I am creating menu items in magento 2. I is working fine and generated according to category order in admin dashboard. But I wanted to sort the menu items alphabetically on store front ir-respective ...
1
vote
0answers
60 views

Magento 2.3 sortOrders not working in search rest API

I tried to pass sort order in V1/search API as below but the sorting is not working in the result. searchCriteria[sortOrders][0][field]=price searchCriteria[sortOrders][0][direction]=DESC Anyone has ...
1
vote
0answers
43 views

How to sort product by position, if every product has same position?

I read somewhere that if all product has same position it will sort by product id, but I don't think its sorting by Id. Here are a few screenshots I am sharing which I am sorting by position problem ...
1
vote
0answers
53 views

Sorting is not working on category page

We have dropdown, which have an option to sort the products by position, name, etc., but its not working. Could anyone please help me?
1
vote
0answers
24 views

How to remove default options from sort order list?

How can I remove default options from de sort by list? For example, see the image? Is it possible to remove Best Sellers from the list?
1
vote
0answers
44 views

The image is not assigning to the correct attribute option after sorting when use visual swatch- Magento 2.3.1

Summary of Issue: I am looking to sort the color attribute options programmatically with input type 'Visual Swatch'. I have made customization in below files to sort the attribute options: File 1:...
1
vote
0answers
24 views

M2 - Previous & Next product from category

I have this code below to show the Previous & Next buttons on the product detail page, but the next en previous product are based on the position in the category. How can this be modified so the ...
1
vote
1answer
961 views

Sort products in ascending order by name on specific category page not working

I want to sort product for a specific category by name in ascending order but it is still sorting in descending order in the front-end. For a category under Display Setting, I have set Default ...
1
vote
0answers
316 views

Sort by Each Price Magento 2 via \Zend_DB_expr

I've had this working previously however seems to be causing me some difficulty now, basically i have a unit of sale attribute that I am using to get an each price from the sale price: if ($...
1
vote
0answers
45 views

Magento 1.9.2. - (Configurable) Sort collection of associated products by attribute value position

I tried with multiple codes to try and sort the collection of associated products based on the position of the attribute value but without success. With my foreach in the product page I have pulled ...
1
vote
0answers
112 views

how to sort products on custom attribute and then on sku in magento 2 category page

how to sort products on custom attribute (i.e. brands) first and then on sku in magento 2 category page For example if 10 products have same brand then it should sort that 10 products on SKU
1
vote
0answers
414 views

How can I sort a category product loop by position with elastic search outside of category page?

I am creating a product loop on the homepage of our site. The site has smile elastic search running. I have set up the manual sort for products in the category admin and can loop thru the products, ...
1
vote
0answers
190 views

sort options Url parameters '?' change to '&' so 404 error

in my category page, sort options url (Position, Name or Price) are https://www.mywebsite.com/category/subcategory?dir=asc&is_ajax=1&order=position&type=195 https://www.mywebsite.com/...
1
vote
0answers
79 views

I want custom sorting order for attribute for each category magento 2

I want custom sorting order for attributes for each category. Please see attached image. If in the category 1, the colour option displaying at the top, then for a category two size options would be ...
1
vote
0answers
58 views

Magento get Configurable option sort by min price

I have created on configurable product A with attribute Unit which contains following Value: Option A: 500$ Option B: 300$ Option C: 1500$ On the frontend, it's showing as drop-down line ...
1
vote
0answers
142 views

Magento 2.2.3 - Sort product collection by custom price

I want to sort my product custom price instead of Magento default price. By default product price is '0'. I overwrite /vendor/magento/module-catalog/Block/Product/ProductList/Toolbar.php. I set my ...
1
vote
0answers
796 views

Order category by position

I seem to be having a problem with the sorting position within categories as it is not displaying properly. I have my "Product Listing Sort By" set to 'best value'. Within a single category i have ...
1
vote
1answer
274 views

Sort Magento categories alphabetically using SQL query but for specific root category

I found this SQL query (Magento Sort Categories Alphabetically using SQL Query) and I've been successfully using it to re-sort all of our 30000+ categories but the problem I have is that it re-sorts ...
1
vote
0answers
38 views

how to sort products by colour and then by manufacture on magento 2?

On a magento product page category page, i want to seperate the products by colour, then i want to show a manufacture first, eg, black black cyan cyan magenta magenta etc, the first color in ...
1
vote
1answer
61 views

How to implement this code to sort the grid in admin panel?

I want to "naturally" sort skus in admin panel ("grid"?) and I found this code: https://magento.stackexchange.com/a/124324/51693 which would be exactly what I need, but I don't know where to call this ...
1
vote
0answers
91 views

Product sorting error for arrow(asc & desc)

In Magento, The product sorting by name, price..and by arrow is also not working. I tried many solutions and worked, but the problem is not fixed. Can anyone do this favour to me by helping this ? ...
1
vote
0answers
26 views

Configurable products being sorted after simple products on category pages

Is there any reason why a category page will sort all simple products a-z then start again with configurable?