Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

0
votes
1answer
18 views

Sort product collection on stock status in magento2.3

I want to sort my list.phtml and catalogsearch by availability. Mean that when category page or search result page loads, first show "in stock" product and at the end show out of stock items. Don't ...
2
votes
0answers
16 views

Magento2.2.7 PLP sorting breaks after we place orders

Whenever we place an order on store front and come back to any category page, the sorting is not working(sorting breaks) . To fix this we needed to run a reindex on the below indexers and clear the ...
0
votes
0answers
14 views

Sorting on parent categories

Let's say that we have the following categories: Category A (60 products) Subcategory A1 (20 products) Subcategroy A2 (40 products) Products are assigned only to Subcategories A1 and A2, but they ...
3
votes
2answers
93 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 ...
0
votes
0answers
16 views

magento2 Sort is not working on PLP due to entity_id

We are working on Magento 2.2.7. On PLP, sort by price is not working. This is because in the query it first sorts the items by entity_id then only using the price field. Example query is given below ...
1
vote
1answer
26 views

How to sort by position field

This is my collection function: public function getCollection() { $searchCriteria = $this->searchCriteriaBuilder->addFilter('status', '1')->create(); $someCollection = $this->...
0
votes
0answers
13 views

Incorrect product sorting for numerical attributes (Magento 2.2.8)

I've got a shop with an attribute "capacity" created via Magento Backend: Shops -> Attribute -> Product It has "Text Field" as input type and "Decimal" as validation. So for new products therefore ...
0
votes
0answers
15 views

Magento 2 sorting duplicates

i have a problem with sorting products on magento2. When i sort by price or position some of the products gets duplicated. And it shows less products. For example if i have 20 products(10 per page) it ...
1
vote
1answer
38 views

Need help with ui component and change sorting order of columns in magento 2

Have listing but need to change view of one column: <column name="status"> <settings> <filter>text</filter> <label translate="true">...
1
vote
0answers
19 views

M2 - Previous & Next product from category

I have this code below to show the Previous & Next buttons on the product detail page, but the next en previous product are based on the position in the category. How can this be modified so the ...
1
vote
1answer
43 views

Magento 2 - Category page `addAttributeToSort` not working on custom product attribute

I used the following code for sorting on category page. if($this->getCurrentOrder() =="latest_products") { $collection->addAttributeToSort('significance', 'DESC')->getSelect()->...
9
votes
1answer
5k 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 ...
1
vote
1answer
30 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 ...
1
vote
1answer
82 views

Magento 2 - Category page sorting does not work on grouped products

I added the new product sorting attribute related to price in category page like price low to high and price high to low. It showed on Sort By drop down. It is working fine for configurable product ...
1
vote
5answers
40 views

Categories are not in order same as in Admin panel Magento 2

I am listing children categories of specific category using below code: $categoryFactory = $this->_categoryFactory->create(); $category = $categoryFactory->loadByAttribute('url_key', 'shop');...
0
votes
0answers
41 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 ...
0
votes
1answer
45 views

Grouped product (simple product sorting on price) Magento 2

In Magento 2.2 on the product view page is it possible to sort the simple products of a grouped product based on price (or any other attribute)? At the moment they seem to be sorting randomly. I ...
0
votes
0answers
11 views

Checked “Use Config Settings” for “Default Product Listing Sort By” for all categories

How to checked the checkbox "Use Config Settings" for "Default Product Listing Sort By" using script or sql ?
1
vote
0answers
21 views

Sort by Each Price Magento 2 via \Zend_DB_expr

I've had this working previously however seems to be causing me some difficulty now, basically i have a unit of sale attribute that I am using to get an each price from the sale price: if ($...
2
votes
0answers
21 views

Position not showing in category sorting dropdown

I have a problem with the sort order of products in the categories: The Position option is not showing in the dropdown as you can see in the screenshot. In the Magento backend the position is ...
3
votes
1answer
78 views

Product collection sorting broken in Magento 2.3?

I am trying to sort by price on a product collection query, however, it seems sorting by price is reducing the result set to 0... Here is a working query which returns expected number of products (...
1
vote
0answers
21 views

Magento 1.9.2. - (Configurable) Sort collection of associated products by attribute value position

I tried with multiple codes to try and sort the collection of associated products based on the position of the attribute value but without success. With my foreach in the product page I have pulled ...
3
votes
3answers
338 views

Sort by price is not working as expected in magento 2.2.7 product listing page

when I sort by price product order in Asc or dec. In product listing shows like, First product price is 40, second product price is 50 and the third product price is 40. If I opened and save those 50 ...
2
votes
1answer
58 views

Sort collection by discount

I want to sort my collection by discount percentage for my sale category, I don't know if it is possible in Magento
0
votes
1answer
35 views

Magento 1.9 sort collection by one of the fields value

Whetever I do it still gives me the same results. Querying cms_block ids: $collection = Mage::getModel( 'cms/block' ) ->getCollection() // can't add addAttributeToSelect(whatever ...
0
votes
0answers
43 views

how to sort products on custom attribute and then on sku in magento 2 category page

how to sort products on custom attribute (i.e. brands) first and then on sku in magento 2 category page For example if 10 products have same brand then it should sort that 10 products on SKU
0
votes
2answers
49 views

How can I remove %26 and %3D from url?

When I want to sort products by price (low to high and high to low), my link is not working. Option value is "price&product_list_dir=asc", which encode in "price%26product_list_dir%3Dasc". How ...
0
votes
0answers
43 views

Magento 1.9.2. - Set Order by position attribute value of associated products

I'm trying to order my foreach for the products associated with the configurable product. I would like the values ​​to be printed in ascending order by position relative to the size attribute. At the ...
0
votes
1answer
44 views

Magento 2 Product Form Categories Sort Alphabetically From the Backend

I want to sort Categories alphabetically of the product form, how can I? For more clarification please look onto the below picture. As I checked, by default Magento 2 sort according to the category ...
1
vote
0answers
15 views

Sort products with custom options, based on minimum/initial price

In my website there are products with the following type: Price : 100$ Custom Option 1 price = 0 Custom Option 2 price = 50$ These products are sorted and filtered based on the max price (which is ...
0
votes
1answer
22 views

Not able to sort the column items in grid

I have created a custom grid I am not able to sort the items of a column.(ascending and descending).If i click first time it will sort in ascending order.Second time it will descend the contents.But ...
0
votes
1answer
78 views

Magento2 : How to override any product custom option price sorting in list page

I have one simple product it's price zero(0). it has a custom option with name and price like: ------------------------- Name Price ------------------------- product A 10 ...
3
votes
3answers
301 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 .....
1
vote
0answers
51 views

How can I sort a category product loop by position with elastic search outside of category page?

I am creating a product loop on the homepage of our site. The site has smile elastic search running. I have set up the manual sort for products in the category admin and can loop thru the products, ...
0
votes
0answers
15 views

Custom sort by functionality in custom module

I need custom "sort by functionality" for customer. I have a list of customer showing in forntend account dashboard , in that i need to implement "sort by functionality" (like sort by or sort by email ...
1
vote
0answers
399 views

magento 2 : Product listing default sorting order based on attributes

i have add sort by attributes to products say like below one. "Publish date" "Product Name" "Price" Now i want to change sort order based on default attributes. For eg 1: Publish date -> Descending ...
0
votes
1answer
141 views

Sort product collection by Latitude and Longitude

I need to sort product collection by latitude and longitude in product listing and search page. Explanation: I have two product attributes Latitude and Longitude. All product has single Latitude and ...
0
votes
1answer
506 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.
0
votes
0answers
83 views

Default sort order for default sort attributes

So it is already possible to select custom attributes for the default sort order in categories. But this sorts by default ascending. If we have - like in our case - a popularity rating which is a ...
3
votes
2answers
145 views

Magento2 change sort order of block using plugin

I have used a plugin to add new template at end of the page in Order view page in admin but the issue is I cannot see it at end of the page, instead, it is showing inside Address Information, Please ...
0
votes
1answer
36 views

Product List Issue

I'm having a problem with the product list in Magento 2. For the most part everything is working properly, but occasionally when I change the sort order to 'desc' or change the sort criteria to 'name' ...
5
votes
2answers
815 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 ...
0
votes
1answer
25 views

Sort Order Issue Payflow Pro Checkout Magento ver. 1.9.3.9

in [Configuration > Payment Methods > PayPal Payment Gateways > Payflow Pro > Basic Settings - PayPal Payflow Pro] there is a "Sort Order" option but it does not work. I am setting this to 0 but the "...
0
votes
1answer
352 views

Magento product collection override sort order with own order

I'm using Magento 1 and inside catalog/product/list.phtml I use the following code to add a custom sort order product_on_top: <?php $_productCollection=$this->getLoadedProductCollection(); $...
0
votes
1answer
164 views

Custom sort order for loaded collection?

I have a product collection created by Magento for the category product list. I then pass some information about this collection to an external method that returns the entity IDs in a specific sort ...
0
votes
0answers
20 views

How can I apply natural sorting to a collection in Magento 2?

I want to sort a collection in Magento 2 using natural sort. I know a can do a simple $collection->getSelect()->order(...) to do the sorting directly in MySQL, and I know that would be the ...
1
vote
0answers
109 views

sort options Url parameters '?' change to '&' so 404 error

in my category page, sort options url (Position, Name or Price) are https://www.mywebsite.com/category/subcategory?dir=asc&is_ajax=1&order=position&type=195 https://www.mywebsite.com/...
0
votes
0answers
49 views

Random order with orderRand() but maintain pagination

I have successfully implemented a random sort on a product collection using suggestions provided here magento get products from category, order by rand() and here How is Varien_Db_Adapter_Pdo_Mysql::...
1
vote
0answers
63 views

I want custom sorting order for attribute for each category magento 2

I want custom sorting order for attributes for each category. Please see attached image. If in the category 1, the colour option displaying at the top, then for a category two size options would be ...
0
votes
1answer
188 views

Product List Toolbar for Wishlist

I want to add the toolbar from the product list to my wishlist to have the pagination and the sorter element. So in my wishlist_index_index.xml I added the block Magento\Catalog\Block\Product\...