Questions tagged [sorting]

Denotes questions related to sorting collections in Magento.

124 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
206 views

Magento 2: How to sort products by price then by name?

The reason I'm asking this is that all my products have configuration and I have to display only simple products (configurable products not visible). However when I sort by price, the products belongs ...
1
vote
1answer
660 views

How to add product updated date as sort order using custom extension

I want to add product updated date as sort order but I don't want to add Updated date field in product setting page which means if admin updates a product, it's edited date should be detected ...
1
vote
0answers
294 views

Proper way to implement grid filtering and sorting on a custom column

I have a custom grid with products. It shows price and special_pirce. Now I want to add another colum which is discount percentage. I have added the column discount with a custom render. The ...
1
vote
0answers
45 views

Attributes assigned globally to advanced search/page sorting/layered navigation on two of my websites. How do I assign them manually?

I've created two websites, but they will be using two different attribute sets. The products are working fine, as they're only using the attribute set assigned to them. The major issue I'm facing is ...
1
vote
0answers
33 views

Disable Category Page Description Content from showing on Sorted Results

Our category pages the description attribute shows at the top of the page. This section is really helpful for the initial category experience. Problem: When the user sorting in the category, the ...
1
vote
1answer
620 views

Sort products in category by stock quatity or stock availabilty

I show out of stock items on my website and they are all over the place but I dont want to get rid of them. I want to sort the category so that products that are out of stock appear last, is this ...
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 ...
1
vote
0answers
38 views

how do return myBlock?

I have Block extend controller Product_view. this block show <ul> <li>Name</li> <li>Age</li> <li>Sex</li> </ul> I have selected option Sort ...
1
vote
0answers
907 views

Sorting product collection on category view

I'm trying to set custom sort for product collection on category view and I'm hitting wall. I tried simple observer for event: catalog_block_product_list_collection with $collection = $observer-&...
1
vote
0answers
735 views

Magento 1.9.1 Configurable Swatches not sorting Size Field Correctly

I have enabled configurable swatches for my store, and it looks great. We are displaying shirts, and sizes as our configurable attributes. I would like to sort the size attribute by position, and have ...
1
vote
1answer
215 views

How to call the "Sort By" feature in Left Column in Category page

I have to show the "Sort By" feature in Left Column along with the other Attributes. How to call the Sort by in the left section specifically in layered navigation section. I want something like this ...
1
vote
0answers
936 views

Product Collection sort by price dividing product types

I am working on a custom extension in which we augment the default Magento Search. Works great with one issue I’ve encountered and identified while attempting to add a sortOrder option to the ...
1
vote
2answers
963 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(...
1
vote
1answer
82 views

Where/How to re-order collection before pagination but after f.x Price

I'm trying to achieve so that products with specific Manufacturer should be the first in the collection (for example, user wants to sort by price, so it should show all the products by Manufacturer X ...
1
vote
0answers
103 views

Magento Product Sorting for Ink Cartridges

Hopefully somebody may be able to help me with this? I am trying to change the sort order of products on Magento, it is a website that sells ink cartridges. The order I want to always displays ...
0
votes
0answers
5 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.
0
votes
0answers
19 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 ...
0
votes
1answer
19 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
0
votes
0answers
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 ...
0
votes
0answers
22 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 ...
0
votes
2answers
180 views

Sort products by In stock in magento 2.4

Can we sort products In stock only. see the below screenshot.
0
votes
0answers
17 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
36 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
21 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
122 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
23 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
22 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 ...
0
votes
0answers
21 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
0answers
15 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\...
0
votes
1answer
96 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
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
51 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
46 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
57 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
42 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
1answer
55 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
93 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 ...
0
votes
1answer
410 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 /...
0
votes
0answers
143 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 ...
0
votes
0answers
118 views

Sorting products based on a custom attribute Magento2

I have a plugin that adds some custom product sorting, based on a customer attribute, in a way similar to below. # Vendor\ModuleName\Plugin\Product\ProductList\Toolbar; case 'capacity_low_to_high': ...
0
votes
1answer
67 views

Magento 2: sort values in collection with unique flag

I have an array as collection and ordered it in ascending order with respect to expiry date as below: $creditDetails = $this->_creditFactory->create()->addFieldToFilter('customer_id', 1)->...
0
votes
1answer
52 views

Magento 2: Display out of stock items in the end in API

I am using a headless magento 2 approach for my store. I have made an API which accepts parameters like: category_slug, sort_by, sort_order, page_size, current_page and returns the products ...
0
votes
0answers
872 views

Magento 2 Sort product in cms page widget block

I want to insert multiple products in a cms page using SKU . So i did using blocks . So please see my code {{widget type="Magento\CatalogWidget\Block\Product\ProductsList" show_pager="0" ...
0
votes
1answer
807 views

Magento 2 - Custom sort order not working properly

I have created a custom plugin for sorting options for high to low & low to high price. High to low sort works fine but "low to high" sort order not showing correct results. app/code/Digital/...
0
votes
1answer
550 views

Use join table to display data in admin grid column

How can I use join table to display second table data in admin grid? Admin grid is created using layout & block in proper manner. I used this link (how to create a grid without using ui component ...
0
votes
0answers
722 views

magento 2.3.1 - How to sort product name, price in ascending order in search result page?

Below is my search result page sort by product name in result page. Products are sorting by name by Z to A. I want to show the products in A-Z order when user click Product Name sort By option.How ...
0
votes
0answers
187 views

Magento2.3.0 How to brand filter sorting left side layer navigation

I am using Magento2.3.0 i need to brand filter sorting for left side layer navigation. I attached image for layered navigation to clearly understand, where am i need.
0
votes
1answer
574 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 ...