Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 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 [...
user avatar
0 votes
0 answers
11 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=&...
user avatar
0 votes
0 answers
18 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. ...
user avatar
0 votes
0 answers
28 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
user avatar
  • 3,446
0 votes
0 answers
18 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','...
user avatar
0 votes
1 answer
63 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.
user avatar
  • 3,187
0 votes
2 answers
34 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 ...
user avatar
  • 526
0 votes
1 answer
152 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&...
user avatar
  • 526
0 votes
0 answers
64 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: $...
user avatar
0 votes
0 answers
17 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 ...
user avatar
  • 526
0 votes
0 answers
21 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....
user avatar
  • 121
0 votes
1 answer
50 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 ...
user avatar
0 votes
1 answer
16 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 ...
user avatar
  • 1
0 votes
2 answers
87 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()...
user avatar
0 votes
0 answers
9 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 ...
user avatar
  • 526
0 votes
1 answer
103 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 ...
user avatar
  • 526
0 votes
3 answers
72 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 [ '...
user avatar
  • 1,279
0 votes
0 answers
17 views

Magento 2.4 sorting issue due to pricing by some additional attributes

We have a site where we have to sort products by price to display in collection. But there are few attributes that too are considered while calculation final price and even on listing we want to show ...
user avatar
0 votes
0 answers
56 views

Magento 2 sort by price ASC not working

Magento 2 sort by price not working. DESC order working fine but ASC order, not getting the order for configurable products. One more is like catalog_product_index_price in this table showing zero for ...
user avatar
0 votes
1 answer
201 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
user avatar
  • 297
0 votes
0 answers
171 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 ...
user avatar
  • 5,856
0 votes
0 answers
10 views

How to show Shipping & Handeling after tax in order totals section admin order view?

I want to show Shipping & Handeling after Tax and just before Grand Total in order view page in admin. I have tried to change sort order from backend but this is not working for me.
user avatar
  • 1,967
0 votes
0 answers
142 views

Magento 2.3 product listing page sorting not working - using varnish and elasticsearch

I was trying to show the products listing order by product id descending in any condition except price. So, I override the \Magento\Catalog\Block\Product\ProductList\Toolbar class with plugin and did ...
user avatar
0 votes
1 answer
39 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
user avatar
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 ...
user avatar
  • 109
2 votes
1 answer
189 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\...
user avatar
  • 1,474
2 votes
0 answers
122 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 ...
user avatar
0 votes
1 answer
108 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?
user avatar
0 votes
2 answers
553 views

Sort products by In stock in magento 2.4

Can we sort products In stock only. see the below screenshot.
user avatar
  • 409
0 votes
1 answer
303 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 ...
user avatar
1 vote
1 answer
341 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 ...
user avatar
3 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 ...
user avatar
  • 771
0 votes
1 answer
156 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 ...
user avatar
0 votes
1 answer
30 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`, `...
user avatar
  • 3,446
0 votes
1 answer
111 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 ...
user avatar
0 votes
0 answers
95 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 ...
user avatar
  • 3,446
-1 votes
3 answers
375 views

Magento 2 - Sort by Brand and Position?

Is it possible to sort by A the Brand alphabetically and then B by Position Programmatically.
user avatar
1 vote
0 answers
42 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
user avatar
2 votes
1 answer
1k 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}) { ...
user avatar
  • 1,946
1 vote
1 answer
587 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 ...
user avatar
0 votes
1 answer
60 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 (...
user avatar
0 votes
1 answer
235 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 ...
user avatar
1 vote
2 answers
446 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 ...
user avatar
1 vote
0 answers
330 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 ...
user avatar
1 vote
0 answers
72 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 ...
user avatar
1 vote
0 answers
106 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 ...
user avatar
0 votes
1 answer
619 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/...
user avatar
3 votes
8 answers
1k 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 ...
user avatar
0 votes
1 answer
746 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 /...
user avatar
2 votes
3 answers
1k views

Magento 2.3 Natural Sort Order for Numeric Attributes / Sort Order Wrong

I have a custom attribute (text field) - let's call it "size". It contains numeric values like 1,2,3,10,20,30. Products are sorted by this attribute on the category page. Expected sort order: 1,2,...
user avatar
  • 33

1
2 3 4 5
8