Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

Filter by
Sorted by
Tagged with
26 votes
7 answers
63k 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/...
24 votes
3 answers
22k views

Magento 1.9.1 configurable product attribute sorting

As i already mentioned, there seems to be a problem with magento 1.9.1 and the sorting of attributes of configurable products. The options of a configurable product now ALWAYS depend on the product ID ...
  • 482
18 votes
5 answers
38k views

How to list products in descending order?

This seemed simple but is proving otherwise -- I just want to list all products in my store from high -> low To do so, I went to: Configuration -> Catalog -> Product Listing Sort by -> (I ...
16 votes
2 answers
2k views

What factors are used to determine display order when the "Sort By Relevance" option is used while searching in Magento Connect?

I want to understand the logic or algorithm behind the search functionality in Magento Connect when the Sort by option in Refine search is set to sort by Relavence
  • 1,489
15 votes
2 answers
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','...
  • 1,267
13 votes
5 answers
64k views

Magento - Unable to set order of collection

This doesn't seem to be ordered correctly, anything I'm doing wrong? Suggestions? $componentQuantityCollection = Mage::getModel('catalog/product')->getCollection(); $componentQuantityCollection-&...
  • 1,267
13 votes
1 answer
19k views

How to specify custom sort order for product collection?

I am trying to create a product collection based on array of products ids, and also sort the collection based on the ids array. $productIds = array(318,310,311); $collection = Mage::getModel('catalog/...
13 votes
2 answers
2k views

Magento 2 product list sorting [closed]

I see that in Magento 2 something changed in the way the page behaves when sorting a product list page or when the number of products visible per page is changed. In Magento 1 there were parameters ...
  • 196k
11 votes
1 answer
7k views

Magento 2 - Product sorting issue on category page using product attribute

I made product attribute and assign it on of attribute set so that it will show in the admin product detail page. Based on this product attribute I sort the product collection on category page. The ...
10 votes
1 answer
11k views

sort products by newest, discount, most sold, reviews" in products list page

On the products list page, we can see sort by "Position, name, price" as in default Magento. How to sort by newest products (uploaded recently) Discount (highest discount products first) Best ...
10 votes
5 answers
4k views

Pagination and Sorting not working

For my custom module I have get product by manufacturer. For template I have copied list.phtml. On the template file pagination appears but it shows all product instead of selected limit per page. ...
  • 5,843
7 votes
1 answer
45k views

Custom Sort Order For Collection

I need to sort a collection based on "sort_order" field instead of "id" as shown in the image. $collection=Mage::getResourceModel('banners/manage_collection'); $collection->getSelect()->order('...
  • 1,965
7 votes
1 answer
363 views

Shopping cart sorting

In the shopping cart we need to sort products in the order they are added and the grouped products need to be ordered alphabetically.
  • 71
7 votes
1 answer
1k views

Sort By Products By Creation Date in EE with SOLR

I need to sort product collection by creation date. It's static attribute in the product entity table. SOLR can index and sort by eav attributes. One option is to create a new attribute and copy date ...
  • 6,500
7 votes
0 answers
1k views

Magento 2 - sorting order of products in a widget block

I created a block and a widget in the 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 ...
  • 2,154
6 votes
2 answers
10k views

Magento2 : How to change sort by option position in sorting options

Native Magento give 3 options position, name, price for sort by option. I added one custom product attribute for sorting option. I want to display it on first position but it is displaying on last ...
6 votes
2 answers
14k views

How to make category 'Default Product Listing Sort By' default option as 'Position'

There is 'Default Product Listing Sort By' on every category I setup ' Use Config Settings' for all categories and the config settings 'Product Listing Sort by' is 'Best Value' I want to always ...
  • 1,576
6 votes
1 answer
230 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 ...
  • 571
5 votes
2 answers
18k views

How to Add additional Sort by?

How can I add additional sort by: price, newest and most popular? Thanks.
  • 123
5 votes
2 answers
2k views

In magento2,Category Sorting Product list: How to remove position from attributes?

I have sorted products in categories by: price (default) name position I need to remove the position from the menu leaving only price and name I don't want to edit every single category view from ...
  • 1,366
5 votes
1 answer
3k views

Sorting of Categories based on a attribute of product item

In my project, by default, I have some categories which are visible in frontend as shown below: category-1 sub-category-1 sub-category-2 category-2 sub-category-1 category-3 ...
  • 1,585
5 votes
1 answer
2k views

Change default sort order in Manage Products admin

In the admin Manage Products area, I want to set the default sort to newest first (via created_at) so the latest products added to my site are displayed first. Everything I have tried to fix this ...
  • 241
5 votes
3 answers
5k views

Product List Page Sort by Most View in magento 2.1

We need to bring most viewed, most subscribed and latest options in the sort menu in product listing page of our magento 2.1 application (magento 2.1.7). I already refered the this link Product List ...
  • 77
5 votes
1 answer
1k views

How to display search results sorted by categories

I need to sort my search results by product categories. If I have Product A and Product B in Category A And I have Product C and Product D in Category B If all products are available in search ...
  • 863
5 votes
1 answer
608 views

How to control search result ordering

Lets say someone searches for "item a" , and 20 items show up, is there a way to control which item shows up first and which item shows up second and so on?
5 votes
1 answer
292 views

How is Varien_Db_Adapter_Pdo_Mysql::orderRand() optimized?

Magento comes with a method to randomly "order" collections: $collection->getSelect()->orderRand(); It takes an optional parameter $field, that is eventually used in ...
5 votes
1 answer
715 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 ...
  • 792
4 votes
1 answer
4k views

How can I add a sort by rating?

I want to add a sort by rating on product list view. Product rating is not an attribute, so I can't edit it in the magento backend. So I think the best way is to create a module for this problem, ...
  • 437
4 votes
3 answers
10k views

How to add custom sort by option filter in tool bar in magento2

I want to custom sort by option filter attribute add in tool bar section. Currently Magento 2 provide Position , Product Name , Price And Sorting option to low to high. But i need to change all ...
4 votes
1 answer
3k views

Custom sorting for product collection

I have to implement the following scenario. The default sort order in category (by position) should ignore the position set for the products in the category. Instead when sorting by position it should ...
  • 196k
4 votes
1 answer
423 views

Exclude custom options price from sorting

I'm working on a Magento store where there are lots of products with custom options. I noticed that when I sort category products by price, the displayed value (e.g. 300,00 EUR) is different from the ...
4 votes
3 answers
2k views

How to convert Magento 2 Sort By Dropdown to Horizontal List

I was trying to Convert Magento 2 Drop down to Horizontal list. Code Path: /app/design/frontend/Vendor/Theme/Magento_Catalog/templates/product/list/toolbar/sorter.phtml Actual Code: <div ...
  • 204
4 votes
3 answers
3k views

Magento sort by price: sort by final price instead of price

Magento sort by price: sort by final price instead of price: I want to sort by price filter to sort by final price of product instead of just price. For product I have price 10 but special price is ...
  • 53
4 votes
3 answers
2k views

"random" order clause added to my collection

For a module I load a custom product collection where I select products based on IDs in an array, I also try and sort the collection by the same order as the IDs have in the array(). To achieve the ...
4 votes
1 answer
715 views

How to load my javascript file before other javascript file from addJs

I am facing some javascript issues by loading order of custom module Javascript files, so i want to change the loading order of my Javascript files located at magento root root/js/. But the ...
4 votes
1 answer
1k views

Widgets sort order in different design packages

I'm wondering if I'm doing something wrong, or there's a 'bug' in Magento. When I add a couple of widgets in the same package/theme, say 'base/default', the sort order works just fine. But, when I ...
  • 1,036
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 ...
  • 821
4 votes
0 answers
621 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, ...
4 votes
3 answers
5k views

Category Sorting Product list: How to take off position from attributes?

Magento 1.9.0.1 In the admin panel, you have the ability to sort categories by attributes as seen here: http://inchoo.net/magento/changing-default-category-sort-order-in-magento/ Now I have sorted ...
  • 109
3 votes
1 answer
8k views

How to reset a specific order by column?

I have a product collection that use a addAttributeToSort. Now there exists a sort filter in the frontend to sort products e.g. for price or date. When I click that filter in the frontend I have to ...
3 votes
3 answers
3k views

Sorting and sort direction applied together

Is it possible to apply sorting option and direction at the same time, using sorting select box? The sorting select box could have options like: Price Asc Price Desc Position Asc Position Desc .....
  • 611
3 votes
2 answers
1k views

How do I list all products in ascending order in Magento?

I try to list all product names in a store, so I try the following code. $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setPageSize(5000)->...
  • 41
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 ...
3 votes
5 answers
8k views

product collection sorting by price is not working

I want to sort the product collection by price. For this i am using ->setOrder('price', 'DESC') or ->addAttributeToSort('price', 'DESC') is not working but it is working with ->...
  • 441
3 votes
2 answers
2k views

Sorting by product ID

I'd like to add product id as a new sorting option in frontend catalog pages. How can I do that? This attribute is not listed in product attributes configuration in magento backend. I guess that it ...
  • 611
3 votes
1 answer
1k views

How to edit the sorting order of New Products displayed on Magento homepage

I am showing new products on homepage with the code {{block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage" template="catalog/product/new.phtml"}} Now the results ...
  • 35
3 votes
1 answer
2k views

Cannot sorting joined column in Magento Grid

I have joined 2 columns to customer grid, I can make them filterable but I don't know how to make them sortable. Here is my _prepareCollection function: protected function _prepareCollection() { ...
  • 792
3 votes
2 answers
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\...
3 votes
1 answer
4k views

Custom Sort order for magento product collection (Sort collection by an array values)

I have product collection as below, Array ( [0] => Array ( [entity_id] => 1995 [type_id] => configurable [sku] => WSH06 [has_options] => 1 ...
  • 594
3 votes
1 answer
1k views

Sort products by color in the cart in Magento2

I have configurable products with virtual variations by color and size. In the cart, I am trying to arrange them in the order of priority, by configurable parent, then by color, then by size. In my ...

1
2 3 4 5
8