Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

Filter by
Sorted by
Tagged with
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/...
24
votes
3answers
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 ...
18
votes
5answers
37k 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
2answers
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
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','...
13
votes
5answers
61k 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-&...
13
votes
2answers
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 ...
12
votes
1answer
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/...
11
votes
1answer
6k 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
1answer
10k 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
5answers
3k 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. ...
7
votes
1answer
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('...
7
votes
1answer
299 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.
7
votes
1answer
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 ...
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
2answers
9k 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
2answers
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 ...
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
2answers
18k views

How to Add additional Sort by?

How can I add additional sort by: price, newest and most popular? Thanks.
5
votes
2answers
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 ...
5
votes
1answer
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 ...
5
votes
1answer
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 ...
5
votes
3answers
4k 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 ...
5
votes
1answer
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 ...
5
votes
1answer
519 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
1answer
285 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
1answer
629 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
1answer
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, ...
4
votes
3answers
8k 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
1answer
2k 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 ...
4
votes
1answer
413 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
2answers
1k 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 ...
4
votes
3answers
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 ...
4
votes
3answers
1k 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
1answer
675 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
1answer
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 ...
4
votes
0answers
535 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
3answers
4k 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 ...
3
votes
3answers
2k 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 .....
3
votes
2answers
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)->...
3
votes
8answers
954 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
5answers
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 ->...
3
votes
1answer
7k 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
2answers
1k 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 ...
3
votes
1answer
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 ...
3
votes
1answer
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() { ...
3
votes
1answer
837 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 ...
3
votes
1answer
282 views

Natural sort for sortby Name

I want to sort catalog products by name in natural order. In order to achieve it i created a custom module and overwrote Mage_Catalog_Block_Product_List_Toolbar. public function setCollection($...
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 ...
3
votes
1answer
2k views

Sort Products by Date in Admin

Often we need to sort products in the admin on creation date. I know I can sort on ID, and this way I'll get the products in the this order, and I found some (free) extensions that give me the option ...

1
2 3 4 5
8