Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

Filter by
Sorted by
Tagged with
0
votes
0answers
25 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 ...
2
votes
1answer
28 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
vote
0answers
33 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
3answers
920 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,...
0
votes
1answer
29 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?
1
vote
2answers
948 views

Sort products in wishlist by price

How can I sort products in the wishlist page by price asc and desc. I have found a piece of code but it is not working any help please. public function getWishlistCollection(...
0
votes
2answers
1k views

Magento 2.2 listing page products sort by price is incorrect

I'm using Magento CE 2.2.6 In front-end when we sort the category pages by price, the sorting happens wrongly. Any suggestions are appreciated.
2
votes
2answers
630 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 ...
1
vote
1answer
1k views

Magento sort attribute - get url

For filtering attributes, I use the method geturl() in order to get the required url a client side input type component should use in order to call the server and activate the required filtering via ...
0
votes
0answers
16 views

Magento 2 - Cannot configure sort options in the backend

im trying to configure the sort options available in the category page. but it doesnt seem to work. i only need 'position' and 'price' as options but its displaying other attribute than the one i ...
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 ...
1
vote
1answer
966 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 ...
0
votes
2answers
84 views

Sort products by In stock in magento 2.4

Can we sort products In stock only. see the below screenshot.
-1
votes
3answers
134 views

Magento 2 - Sort by Brand and Position?

Is it possible to sort by A the Brand alphabetically and then B by Position Programmatically.
3
votes
3answers
3k views

“Joined field with this alias is already declared” sort by custom attribute shows error

I already had one custom sort by attribute which is agency_id but when i try to add new sort by attribute Location it shows me this error. a:5:{i:0;s:48:"Joined field with this alias is already ...
0
votes
0answers
16 views

Custom module sort and search filter not working

I've created a custom module. The sorting and search filter not working on the grid page. <arguments> <argument name="id" xsi:type="string">testGrid</argument> &...
0
votes
0answers
28 views

Sorting by position not working with Elastic Search 6+ on magento 2.3.3

When I use mysql as a default search engine in magento 2.3.3 everything works fine as it should but as I change the default search engine to Elastic Search 6+ the sort by position attribute does not ...
0
votes
0answers
18 views

Sort product list widget by position?

I added a prodct list widget that should show products from one category, sort by position. Sort products in widgets seems not to work, so I tried a suggested module from this question. It adds a ...
0
votes
1answer
79 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 ...
0
votes
0answers
17 views

In Navigation top menu sort default and custom added links

Kindly read it out carefully because for me it is somehow confusing. 1- I have default links in navigation like (What's New, Women, Collection). I have sorted them by adding category attributes (sort ...
0
votes
0answers
20 views

Magento 2 : When I special price bulk update price sorting is not working

My site has just configurable products only. I want to sort by price. For products so when users sort products by price, sorting looks wrong. So I have checked so Price(Low to High) Sorting not ...
24
votes
7answers
49k views

Magento 2 How to add custom sort by option

I need to add an additional filter based on created_at attribute for sorting product list by latest product. I tried to figure it using below file app/design/frontend/Vendor/ThemeName/Magento_Catalog/...
1
vote
1answer
141 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 ...
0
votes
0answers
19 views

jQuery (server side) search and sort using Ajax

I tried to create search and sort from live URL using Ajax , i used do search function and i managed to retrieve the data from the URL . I am showing Ajax response in select options as below code. I ...
0
votes
1answer
85 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
0answers
14 views

How to get the best selling products in a category and sort them from best selling to least selling?

How to get the best selling products in a category and sort them from best selling to least selling? I try get best selling collection like: use Magento\Store\Model\StoreManagerInterface; use Magento\...
1
vote
1answer
824 views

Sort quote items in Magento2

In Magento2, how to sort Quote Items? The code I have is her: <?php require __DIR__ . '/app/bootstrap.php'; use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Api\SortOrder; ...
15
votes
2answers
2k views

Magento 1 - sorting cart items by 'updated_at'

This is how i'm getting the cart items: $quote = Mage::getModel('checkout/cart')->getQuote(); $items=$quote->getAllitems(); I'd like to do something like this: $items->sortBy('updated_at','...
0
votes
1answer
21 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`, `...
0
votes
1answer
40 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
0answers
43 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 ...
0
votes
0answers
56 views

Magento 2.2.9. Sales Order Grid. Order & Filter by column not in database

I´m trying to create a new calculated colunm on sales order grid. This column must indicate if all the products in the order are in stock at the moment the grid is displayed. I managed to create the ...
0
votes
0answers
41 views

Using foreach change the position of my product collection

The best way to explain this issue is showing an example: In the product list.phtml I had the following <?php $logger->info($_productCollection->getData()); foreach ($...
0
votes
0answers
21 views

How can I create a module or plugin that will sort attribute color properties alphabetically?

How to sort attribute options color properties in Magento 2.3.5 alphabetically with code? How can I create a module or plugin that will sort attribute color properties alphabetically? Image below. ...
0
votes
0answers
10 views

Magento2 Price sorting not working with special price

Price(Low to High) Sorting not working correctly with the special price. Any one have idea?
0
votes
3answers
5k views

Programmatically assign a product's categories _AND_ sort order/position

How can I programatically set the categories AND the sort order/position of products? I already have an exisiting script that iterates through my products and assigns the categories $product = Mage::...
0
votes
1answer
325 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
vote
0answers
210 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
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
562 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
1answer
270 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
2answers
830 views

Magento2 Catalog search result and product listing grid only sort by product name set

I need below condition to my website. Magento2 Catalog search result and product listing grid only sort by product name to be set. I have also back-end configuration done but issue is like product ...
2
votes
2answers
3k views

Magento 2.2.2 - Rename Sort By Options Label

On product listing page, I need to rename the label of Sort by Option Position to Most Popular. Below are the two files responsible for sorting \vendor\magento\module-catalog\Block\Product\...
0
votes
1answer
54 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
1answer
80 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 ...
2
votes
2answers
3k views

Cannot sort by position in Magento 1.9.2.4

I am trying to force a category of products to sort by position in Magento 1.9.2.4. I have assigned the position to each product in the category but I notice there is no position option - only by Best ...
0
votes
0answers
132 views

Magento 2 : on page load product sorting not working

When I go on the category page, sorting does not work unless I select any value from dropdowns like position or price then it sorts the product. http://prntscr.com/q97trw Can anyone help me how can ...
1
vote
2answers
285 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
3answers
3k views

Magento2 sort products and search result by stock availability

I need to add an option in the Sort By dropdown which sorts the products with based on stock availability of the products. So far i have created a plugin for setCollection methodMagento\Catalog\Block\...
0
votes
2answers
3k views

Why sort by price order not working?

I am using below script to desc order price collection but it's not working. This collection is working for a simple product but configurable products not working: $productsCollection->...

1
2 3 4 5
8