Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

Filter by
Sorted by
Tagged with
1 vote
0 answers
10 views

Sorting images issue ( Magento 2.4.3

I face an issue when upload images bulky that i don`t have the way to sort it as i want , it is sorted random , even if i one of it as base,small,thumbnail Need the way to know how to sort it for ...
  • 11
1 vote
0 answers
28 views

Magento 2.4.4 upgrade after custom sorting filter Ascending/Discending order not working with porto theme?

I have upgrade Magento version 2.3.7 to Magento 2.4.4, before upgrade custom sorting option is working fine.after upgrade popularity asc/desc sorting is not working. we are currently using smartwave ...
0 votes
0 answers
65 views

Magento2.4.4 Sort by Created at date not working with elastic search

Magento2.4.4 Sort by Created at date not working with elastic search $this->_collection->getSelect()->order('e.created_at DESC'); Please advice. Mysql working fine.
  • 3,466
1 vote
1 answer
15 views

How to change (text) after sorting option on category page

I need help changing the text in () when selecting the sort option. With translation I change to Low to high and High to low but I have to change Product name to (A-Z). I don't know how to change only ...
0 votes
2 answers
121 views

How to sort menu items in the top menu in alphabetical order in magento2 frontend

Is there any way to sort menu items(Categories) showing in Magento in alphabetical order?
  • 23
0 votes
0 answers
30 views

Magento2 : Save Product Quantity To Custom Attribute

I Want To save Product Quantity Value In Custom Attribute. For That, I Have Created Patch With backend_model :-Magento\Catalog\Model\Product\Attribute\Backend\Stock. Whenever I save Value It Renders [...
0 votes
0 answers
30 views

Magento2 : Category Page (Product Listing Page) Custom Sorting Option Not Working

I Want TO Display Product Based On Product Stock On Category Page. I Have Used Code As Below. I Have Used the Around Plugin To Set Collection. File:- di.xml Vendor\Module\etc\di.xml <type name=&...
0 votes
0 answers
62 views

How can I modify logic for Sort by Lowest Price?

In my Magento store in the category page I display a grid of products each product contains used and new products. All configurable products are considered new, all used simples are considered used. ...
  • 31
0 votes
0 answers
34 views

Magento2 on listing page after ASC sorting move attribute with values null or 0 at last

Magento2 How to move null & 0 value custom attribute values at last after ASC sorting on list page
  • 3,466
0 votes
0 answers
70 views

Magento 2 : Render Product Using Custom Sorting Option

I want to display product on Qty Desc order but shows no product to display. I run sql query used in sorting and it working in as per qty. I have tried below code. $collection->setOrder('price','...
0 votes
1 answer
205 views

Magento 2 PWA store add new sorting in product listing page

How to add new sorting in product listing page. I have frontend is PWA. So can you explain me how do that. THANKS.
  • 3,297
0 votes
2 answers
364 views

Some Filters not showing on some Categories in Magento 2.4

Some Filters not showing on some Categories in Magento 2.4 As you can see in two images both are diffrent categories but Newest filter not showing in second image. In some categories it just show ...
  • 586
0 votes
1 answer
701 views

Custom Sorting option not working in Magetno 2.4 search

Custom Sorting option not working in Magetno 2.4 search app/code/Arun/NewSorting/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&...
  • 586
0 votes
0 answers
99 views

How to sort by name all categories in my layered navigation?

I need to have all categories and subcategories ordered by name. How can I do it? Do I have to modify this file? app/design/VENDOR/THEME/Magento_Catalog/templates/navigation/left.phtml I've tried: $...
0 votes
0 answers
36 views

How to add Custom Sorting option with created date on category page in Magento 2

I want to add Custom Sorting option with created date on category page in Magento 2. Like its label would be Newest Product and the product sort is based on product crated date. SS attached for more ...
  • 586
0 votes
0 answers
25 views

Product sort in catalog page not correct

I'm using Magento 2.3.4. On my product list page, when I sort price ASC or DESC, the price is not correct. Here is a picture of the result: In the URL, I can see param in URL https://example.com/wine....
  • 121
0 votes
1 answer
192 views

How to add sort by filters to the custom collections magento2

I would like to display Sort By filter options to the order collection Magento2 at the front-end and display the results. Sort by options are 'processing','cancelled', 'hold' etc. Can anyone advise ...
0 votes
1 answer
163 views

Sorting custom column in ui component

I've created a custom column in the report using UI components that use DataProvider in report_listing.xml Unfortunately, this new custom column is not able to sort. I made also a class for this ...
  • 1
0 votes
2 answers
391 views

Sort order products in categories by custom value attribute first in Magento 2

I want to sort products with custom value (1) numeric attribute. In toolbar.php: if ($this->getCurrentOrder()) { $this->_collection->addAttributeToSort( $this->getCurrentOrder()...
0 votes
0 answers
20 views

How to write custom query for sorting for a new column added in sales order grid in Magento 2?

How to write custom query for sorting data for a new column added in sales order grid in Magento 2 ? It shows Printed when invoice is created and it is blank if invoice is not created. I have ...
  • 586
0 votes
1 answer
346 views

How to create custom sorting in sales grid custom column in Magento 2?

I have created a custom column named printed which shows the invoice is printed or not and works well. But how to apply sorting in in it like when i click on printed firstly it shows all data with ...
  • 586
0 votes
3 answers
133 views

How to sort modules in config.php alphabetically?

Is it possible to sort the output of the modules node in config.php alphabetically? This way git versioning won't get messed up since Magento sometimes changes the sorting. <?php return [ '...
  • 1,384
0 votes
1 answer
596 views

Magento 2 | Change sort order for search results

I would like to set as the default order in the search results page "relevance" in descending order. How can i do? Thanks
  • 347
0 votes
0 answers
315 views

Magento 2.3.2 sort the product collection by attributes

I want to sort the product collection by attributes. I want to apply multiple sorting to the product collection need to sort by NEW, ONSALE, and POSITION For example when going to any listing page ...
  • 5,946
0 votes
1 answer
89 views

Can we update Product Position in Category with CSV in M2?

Can we update products position with csv in Category ? If yes than please share share any sample or example. Thanks
0 votes
0 answers
28 views

Best way to do this?

I've been racking my brains for a long time trying to think of the best most efficient way to solve the following problem. Basically I have a set of questions which I'm looping through in the ...
  • 156
2 votes
1 answer
236 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\...
  • 1,484
2 votes
0 answers
149 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 ...
0 votes
1 answer
182 views

Paginate order list by 15 items and sort by price ASC

I need to do sort by price and paginate by 15 items for order list history page, can anyone help?
0 votes
2 answers
680 views

Sort products by In stock in magento 2.4

Can we sort products In stock only. see the below screenshot.
  • 465
0 votes
1 answer
385 views

Magento 2.4 : Sort Product by attribute value

i have configurable and simple product in my website with Attribute color: (Values - Red, Green, Blue) I want to sort product on the listing page with specific attribute value, for example, all ...
1 vote
1 answer
408 views

How can you map a virtual column in magento 2.4.1?

I have just upgraded to Magento 2.4.1 that REQUIRES you to use Elasticsearch as the search engine instead of MySql. In the previous setup (Magento 2.3.2) I had a custom sort by a discount in the ...
4 votes
2 answers
2k 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 ...
  • 811
0 votes
1 answer
195 views

Column 'created_at' not imported

My goal is to sort products on the frontend from newest to oldest. The products CSV file contains the created_at column (e.g. 2020-10-31 14:05:44). Format seems to be correct. After the standard ...
0 votes
1 answer
42 views

Magento2 query displaying perfect result in database but wrong in collection while sorting by created_at

Magento2 query displaying perfect result in database but wrong in collection while sorting by created_at Query SELECT `e`.*, `cat_index`.`position` AS `cat_index_position`, `price_index`.`price`, `...
  • 3,466
0 votes
1 answer
153 views

Category Products - Sort By Newest

Since upgrading to Magento 2.4x and having to use ElasticSearch as default, I am unable to find a way to sort category products by newest (created_at). I have tried enabling used_in_sort_by for ...
0 votes
0 answers
107 views

Magento2.4 sort by created date not working

Magento2.4 Sort by created date not working on list page case 'new_arrivals': $this->_collection->getSelect()->order('e.created_at '. $this->getCurrentDirection()); break; It just ...
  • 3,466
-1 votes
3 answers
568 views

Magento 2 - Sort by Brand and Position?

Is it possible to sort by A the Brand alphabetically and then B by Position Programmatically.
1 vote
0 answers
43 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
2 votes
1 answer
2k 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,946
1 vote
1 answer
734 views

Custom column sorting(DESC and ASC) not working in custom grid Magento 2.3.5

Actually in below listing.xml file i am trying to sort customer_id column DESC/ASC but not working fine. After using below code it's loading the data in ASC order only if sort customer_id column one ...
0 votes
1 answer
69 views

Show products with zero quantity last in Magento 1.9

I want to show products with zero quantity last in all site categories, search results, etc. But the sort order should be as follows: the products with a non-zero quantity (not in decreasing, default (...
0 votes
1 answer
396 views

Change order of widget catalog products list

I have a product in my product list, which must be at the top. After I have extended the product list, the product is unfortunately no longer at the top. I add the product list via the widget catalog ...
1 vote
2 answers
468 views

Magento 1.9 How to sort product in category page by stocks product

I want the products to be displayed on the category page, if available That is, first those that are stocks , then those that are not stocks I didn't find anything with the title in the attribute Is ...
1 vote
0 answers
363 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
0 answers
84 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
0 answers
212 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
1 answer
700 views

Sort product collection by date in standart category view

I'm running Magento CE 2.3.3 with Porto theme. I want to sort the products in the category overview by the date they were added without using an extra extension. By default products in category view/...
3 votes
8 answers
2k views

Magento2: I want to show featured product on top of the category and search result

I have yes/no type product attribute. If this featured attribute is yes for any products, those product will show top(first featured product showing in category page then rest of the products are ...
0 votes
1 answer
841 views

Products in Category Default Sort and Direction on Position Column

In catalog Category's assigned product grid, sort order is applied on entity_id as DESC by default like this: But I want to apply sort order by default on position as ASC like this: I found a file /...

1
2 3 4 5
8