Questions tagged [sorting]
Denotes questions related to sorting collections in Magento.
356
questions
0
votes
0answers
14 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
8 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
77 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 ...
0
votes
1answer
60 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
15 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
27 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
31 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
45 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
39 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
18 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
8 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
2answers
50 views
Magento 2 - Sort by Brand and Position?
Is it possible to sort by A the Brand alphabetically and then B by Position Programmatically.
1
vote
0answers
17 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
189 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}) {
...
0
votes
0answers
37 views
Magento 2 how to sort categories based on a custom attribute in rest API
I am using V1/categories and V1/categories/list API calls for retrieving categories. I have created a custom attribute "featured_sort_order". Now I want to sort the categories based on the ...
1
vote
1answer
113 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
1answer
52 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
0answers
16 views
How to make sorting panel with links in a row instead of a drop-down list?
Does anybody know how to replace the drop-down list with links or buttons? Example:
I tried to do it via CSS but didn't get the result. Seems it has to be done via Html / PHP.
This is a pice of ...
0
votes
1answer
36 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
0answers
45 views
Magento 2: Sort Product collection by updated Special Price
I want to sort product collection by updated Special Price.
When I update the special price of any product, that product should come first in my collection.
How to sort this collection:-
$count ...
1
vote
2answers
171 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 ...
0
votes
0answers
13 views
Magento 2 | Adminhtml | How to change sort order in customer edit
when you edit a customer in adminhtml how could I, for example, change the sort order of first name and last name.
Do you have any idea?
Thanks in advance!
0
votes
0answers
18 views
Cannot Sort Products by Price when using static block on category page
When defining category the user can display static block, product only or both. I am using a particular template to display the products, I am directing it by using a static block with the following ...
0
votes
0answers
127 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
45 views
Magento 2.3 sortOrders not working in search rest API
I tried to pass sort order in V1/search API as below but the sorting is not working in the result.
searchCriteria[sortOrders][0][field]=price
searchCriteria[sortOrders][0][direction]=DESC
Anyone has ...
1
vote
0answers
31 views
How to sort product by position, if every product has same position?
I read somewhere that if all product has same position it will sort by product id, but I don't think its sorting by Id.
Here are a few screenshots I am sharing which I am sorting by position problem ...
0
votes
0answers
48 views
Sorting is not working in magento 2
I modified 2columns-left layout in magento 2 design.After that sorting is not working
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
0
votes
0answers
25 views
How to sort products in block template by create date
In am using a block template to display products from a specific category. How can I sort the products in this block by create date (newest first)? Is there an attribute I should add?
{{block class="...
0
votes
1answer
226 views
Sort product collection by date in standart category view
I'm running Magento CE 2.3.3 with Porto theme.
I want to sort the products in the category overview by the date they were added without using an extra extension.
By default products in category view/...
3
votes
8answers
517 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 ...
0
votes
1answer
156 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
2answers
488 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,...
1
vote
1answer
207 views
Magento 2: Multiple Product Type Not Sorting Due To Amasty Extension
I'm facing a problem due to Amasty Extension. I have a category which has 1 simple product and some configurable products, but when I try to sort them, simple product always comes first although ...
0
votes
0answers
87 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
1answer
329 views
Sort the product collection before load by attribute option in Magento2
I am trying to sort the Product collection based on the attribute option value,
I used below plugin
Vendor/Module/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/...
2
votes
2answers
84 views
Sorting on a date's component
For Magento 1.x
How do I sort product based on a date attribute by a month and year only, rather than on the whole date? The code looks a bit like this:
Mage::getSingleton('...')->...
0
votes
0answers
89 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':
...
1
vote
1answer
528 views
How to change products sort order in magento 2?
In product list page I need to change the sorting order. I have a current order like:
Description A-Z
Price High To Low
Price Low to High
Description Z-A
I need to change it to.
Description A-Z
...
0
votes
1answer
63 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
36 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
600 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" ...
1
vote
1answer
248 views
Magento 2 How to sort admin column in desc order?
I have a custom grid, I am trying to sort it in desc order
What I did
Try 1:- In my Grid Collection:
protected function _renderFiltersBefore()
{
$orderUpdate = $this->getTable('xyztable');...
1
vote
0answers
42 views
Sorting is not working on category page
We have dropdown, which have an option to sort the products by position, name, etc., but its not working.
Could anyone please help me?
0
votes
1answer
554 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
455 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 ...
1
vote
0answers
24 views
How to remove default options from sort order list?
How can I remove default options from de sort by list? For example, see the image? Is it possible to remove Best Sellers from the list?
0
votes
0answers
632 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 ...
1
vote
0answers
42 views
The image is not assigning to the correct attribute option after sorting when use visual swatch- Magento 2.3.1
Summary of Issue:
I am looking to sort the color attribute options programmatically with input type 'Visual Swatch'.
I have made customization in below files to sort the attribute options:
File 1:...
0
votes
0answers
154 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
331 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 ...