Sort by Position in Magento 2: Working and Customization

Sort by Position in Magento 2: Working and Customization

Looking to enhance your store’s navigation and product visibility? Sort by position in Magento 2 gives you full control over how customers interact with your catalog.

In this article, we will explore the working and customization of sort by position functionality.

Best Magento Hosting now

Key Takeaways

  • Sort by position helps control product display in Magento 2.

  • Follow the steps to customise the sort by position feature.

  • Explore the difference between Sort by Position and other sorting methods.

  • Understand the pros and cons of using this feature for your store.

  • The functionality supports marketing strategies like promotions.

What is Sort by Position Functionality in Magento 2?

The sort by position functionality in Magento 2 allows store admins to control the display order of products within a category.

Each product is assigned a position value, where lower numbers appear first. Admins can manually adjust these values in the category products section of the admin panel. It provides flexibility to highlight specific products.

When customers sort by position on the storefront, the products display in the predefined order. The feature improves user experience, enables better product visibility, and supports marketing strategies. It is by showcasing featured or high-priority items at the top of category listings.

How Sort by Position Functionality in Magento 2 Work?

1. Position Field in Categories

  • Every product added to a category in Magento 2 has a position field. The field determines the order in which the product appears when the sort by position option is used.

  • Products are assigned a position value of 0 by default. It means all products with the default value will appear in an arbitrary order unless explicitly adjusted.

  • Admins can manually assign a value to prioritize the display order. Lower numbers have higher priority.

2. Assigning Position Values

Assigning Position Values

  • The position values are assigned in the category configuration in the Magento Admin panel.

  • Merchants can define the values for each product in the Products in Category grid.

  • The grid lists all products associated with a category and includes a column for the Position value.

3. Frontend Sorting

  • When customers browse the store and select "Sort by Position" from the sorting options. Then, products are displayed in the exact sequence defined by their position values.

  • If no position values are explicitly set, products may be displayed in a default order.

4. Customer Interaction

  • Customers can use the sort by position option on the storefront. It helps customers to view products in the predefined order.

  • On a category page, a sorting dropdown menu is usually available at the top of the product grid.

  • If sort by position is enabled, customers can select it from the dropdown. Products will then be displayed based on their assigned position values.

  • The sorting option is helpful for customers looking for curated selections. These include highlighted products or featured deals.

5. Default Sorting

  • Magento allows store owners to set sort by position as the default sorting method for specific categories.

  • It ensures customers see products in the custom order. It eliminates the need to interact with the sorting menu.

  • When sort by position is the default, customers visiting the category page will see products in the order defined. It is by their position values automatically.

How to Customize Default Position Sorting Behavior in Magento 2?

1. Understand the Default Behavior

  • By default, Magento 2 uses the Position field in the category’s product configuration to sort products.

  • Products with lower position values appear first. If multiple products share the same position value, Magento may fall back to secondary sorting criteria. These include product name or ID.

2. Identify Your Customization Needs

Identify Your Customization Needs

You might want to:

  • Sort by a custom product attribute instead of position.

  • Apply additional conditions for sorting.

  • Combine position values with other attributes, first sort by position, then price.

3. Override the Default Sorting Logic

  • Magento 2 uses Magento\Catalog\Model\ResourceModel\Product\Collection to handle product collection and sorting.

  • To customise the sorting behavior, you will need a custom module. It helps ensure the changes are non-destructive and maintainable. If you don’t already have one, create a module.

  • Create the required files for the module. Create a plugin or preference for the Magento\Catalog\Model\ResourceModel\Product\Collection. It modifies the sorting logic.

  • Create a plugin to modify the default sorting.

4. Test Your Customization

  • Clear the Magento cache using php bin/magento cache:clean.

  • Reindex the data by php bin/magento indexer:reindex.

  • Navigate to a category page and set sorting to Position. Verify that the products are displayed according to your customized logic.

5. Optional Enhancements

  • If you would like to keep the default position sorting but introduce a custom option. You can define a new sorting method in the category display settings.

  • Modify the plugin logic to apply changes only for certain categories using their IDs.

Difference Between Sort by Position and Other Sorting Methods in Magento 2

Feature Sort by Position Other Sorting Methods
1. Definition It displays products based on an admin-defined position field in the category. It arranges products using a specific attribute as the sorting criterion. These include price, name and newness.
2. Primary Sorting Criterion The custom position values is set by the admin in the backend. It is sorted by attribute values like price, product name, or custom attributes like date added.
3. Control It is fully controlled by the admin. Merchants manually assign numeric values to define the order. It is determined automatically based on the selected attribute value. These include lowest price first.
4. Customizability It is highly customizable. It allows merchants to reorder products manually for each category. Customization is limited unless custom sorting logic is implemented. These options include custom attributes or modules.
5. Configuration Process It is configured in the Products in Category section of the category settings in the admin panel. It is automatically applied using product attributes. No manual setup is required.
6. Dynamic Updates It does not update automatically when product data changes. It requires admin adjustment. It updates dynamically as attribute values like price or name change.
7. Fallback Behavior If two products have the same position, secondary sorting is applied. Sorting continues solely based on the selected attribute or its default behavior.
8. Default Sorting Option It can be set as the default sorting option for specific categories. Any sorting method like price and name can also be set as the default.
9. Customer Interaction Customers must select Sort by Position in the sorting dropdown unless it is set as the default. Customers can select options like Sort by Price or Sort by Name from the dropdown.
10. Use Case It is ideal for highlighting featured, seasonal, or priority products. It is best for scenarios like showing the lowest-priced items, alphabetical navigation, or new arrivals.

Pros of Sort by Position

1. Enhanced Control Over Display Order

  • Sort by position gives full control to administrators to arrange products manually.

  • If you want to highlight bestsellers or high-margin products, you can set their position at the top of the category listing.

  • It is especially useful for campaigns like holiday sales or new product launches where specific items need priority.

2. Customizable for Specific Categories

  • Each category in Magento can have its own unique product positioning. It allows store owners to tailor the display for different audiences or purposes.

  • You can display high-value products at the top in luxury categories and sale items at the top in a clearance category.

3. Improved User Experience

  • Customers can quickly find relevant products if they’re strategically placed at the top of a list.

  • Displaying popular or frequently purchased items first can improve conversion rates.

4. Easy Setup

  • Adjusting product positions is done directly from the Magento Admin Panel under category settings.

  • No coding or additional tools are required. It is accessible even for non-technical users.

5. Supports Marketing Campaigns

Supports Marketing Campaigns

  • Sort by position is ideal for short-term promotions.

  • A store can temporarily position limited-time offers or holiday collections higher. It doesn’t disrupt the overall sorting rules.

Cons of Sort by Position

1. Manual Effort Required

  • Sorting by position requires assigning numbers to products in the catalog manually.

  • The process is time-intensive. It is particularly for categories with hundreds or thousands of items.

2. Static Sorting

  • Once products are arranged, they remain in the same order unless manually updated.

  • The approach lacks automation. Frequent updates are needed to keep the display fresh and relevant.

3. Does Not Reflect Customer Preferences

  • Unlike dynamic sorting options sort by position doesn’t adapt to customer behavior.

  • If preferences shift, such as a sudden rise in demand for a product. You will need to intervene manually to update the order.

4. Limited Personalization

  • Modern e-commerce platforms thrive on personalization. It shows customers products tailored to their interests.

  • Sort by position is static and doesn’t account for personalized recommendations. It might limit engagement and conversions.

5. Challenging for Large Stores

  • Managing product positions for thousands of items across multiple categories can become overwhelming. It is especially true for large e-commerce businesses with extensive catalogs.

  • The limitation often leads large stores to adopt automated sorting options. It rely on algorithms or AI to determine product order.

Common Issues and Solutions of Sort by Position in Magento 2

Common Issues Explanation Causes Solution
1. Products Not Sorting Correctly The "Sort by Position" option doesn't reorder products as expected. It leads to a random display. Incorrect category product position values. Cached category products. Conflicts with third-party extensions or customizations. Verify position values and adjust product positions. Clear cache. Check for module conflicts.
2. Sort by Position Missing from Dropdown The "Sort by Position" option doesn't appear in the sorting dropdown on category pages. Misconfigured attributes or theme settings. Disabled default sorting configuration in Magento. Enable sort by position. Verify attribute settings. Check your theme's list.phtml or toolbar.phtml and ensure the position sort order is included.
3. Position Sorting Not Applied on Frontend Changes to the product position in the admin panel are not reflected on the storefront. Incomplete reindexing. JavaScript or CSS caching issues. Reindex the category. Flush the browser and Magento caches. Deploy static content.
4. Sorting Works in Default View but Breaks in Layered Navigation Sorting by position works in the default category view but doesn't work when filters are applied. Issues with layered navigation logic. Conflicts with third-party filtering modules. Check layered navigation configuration. Temporarily disable any layered navigation extensions and retest. If needed, modify the category collection logic in your custom module.
5. "Sort by Position" Is Slow or Causes Performance Issues Sorting by position takes a long time to load or impacts page performance. Large number of products in categories. Inefficient SQL queries or missing indexes. Optimize SQL queries. Ensure pagination is implemented correctly to limit the number of products displayed per page. Enable flat catalog If compatible with your setup.

FAQs

1. How do third-party extensions enhance product sorting in Magento 2?

Third-party extensions provide advanced options like automatic sorting by rules. These include sort by price, newest items, or product name. These tools optimize product collection and product sorting in Magento 2. It allows your e-commerce store to improve the user experience.

2. How can I enable "Sort by Position" in Magento 2?

To enable Magento 2 sort by position, go to the admin panel. Then, navigate to Catalog > Categories, and expand the Display Settings tab. Select the Sort by Position option from the dropdown under Default Product Listing Sort. Then assign a position number for each product in the category.

3. Can I manually customise product sorting in Magento 2?

You can manually customise product sorting by assigning position values for each product in a category product. Go to Manage Categories in the admin panel and use the position column. Arrange the products in Magento 2 using the drag-and-drop tool for better sorting in Magento 2.

4. What are the benefits of "Sort by Position" for an e-commerce store?

Using "Sort by Position" in Magento 2 category pages improves the user experience. It is by ensuring relevant products are displayed first. It also helps boost sales by allowing you to prioritize newest items or high-performing products. It is in the default product listing sort.

CTA

Summary

The Sort by position in Magento 2 gives store admins control over product display order in categories. The article explores the features of the functionality, including:

  • Admins assign numeric position values to prioritize product order in categories.

  • Customers can choose "Sort by Position" to view products in a predefined order.

  • Merchants can set it as the default sorting method for specific categories.

  • Sorting behavior can be customized using modules for advanced requirements.

Take full control of your product display with Magento’s Sort by Position feature. Upgrade to managed Magento hosting for enhanced store management.

Ruby Agarwal
Ruby Agarwal
Technical Writer

Ruby is an experienced technical writer sharing well-researched Magento hosting insights. She likes to combine unique technical and marketing knowledge in her content.


Get the fastest Magento Hosting! Get Started