Magento 2
  • Personalization for Magento 2
  • Installing
  • Disconnecting
  • Uninstalling
  • Getting Started
  • Configuring
  • Hyvä Theme
  • Guides
    • Migrating to Magento2
    • Upgrading to >= 4.0.0
    • Varnish & Full-Page Caches
    • Advanced User Guide
    • Managing Blocks
    • Overriding or Extending Functionalities
      • Overriding Product Data
        • Excluding Products
        • Customising Pricing
        • Customising Categories
        • Resizing Images
      • Overriding Customer Data
    • Console Commands
    • Tagging Providers
  • Features
    • Product data caching
      • Built-in caching
      • Database caching
    • Variations (Configurable Products)
    • Add to Cart
    • Indexer
      • On 7.x
      • On 5.x and 6.x
      • On 4.x
      • On 3.x
    • Customer Group Pricing
    • Supplier Cost & Inventory Level
    • Restore Cart Link
    • Ratings & Reviews
    • Multi Currency (Exchange Rates)
    • Marketing permission and GDPR compatibility
    • Content Staging & Special Prices
  • Integrations
    • Using Yotpo
  • FAQ
  • Developing & Contributing
  • Visit Nosto
  • Issues
  • Releases
  • Addons
    • Multi Source Inventory (MSI)
      • Installing
      • Uninstalling
      • Configuring
    • Category Merchandising (CM 1.0)
      • Installing
      • Uninstalling
      • Configuring
      • Guides
        • Translating Frontend Strings
        • PWA Implementation
        • Using Elasticsearch
        • Segmentation
        • Overriding or Extending Functionalities
          • Customize Query Parameters
          • Customize Page Size Limit
          • Customize Exclude Filters
        • Debugging
Powered by GitBook
On this page
  • Create a CustomParameterResolver class
  • Inject the CustomParameterResolver
  • Compiling your changes

Was this helpful?

  1. Addons
  2. Category Merchandising (CM 1.0)
  3. Guides
  4. Overriding or Extending Functionalities

Customize Query Parameters

PreviousOverriding or Extending FunctionalitiesNextCustomize Page Size Limit

Last updated 3 years ago

Was this helpful?

This module relies on Http parameters for handling pagination and sorting. In case your Magento installation has a customised catalog page or customised query parameter (we rely on p for page and product_list_order for sorting order), it is necessary to create a class which will be responsible for handling two parameters: page number and sorting order. Read up on prior to proceeding with this.

Create a CustomParameterResolver class

This class will implement ParameterResolverInterface and it's methods.

<?php

namespace My\Nosto\Plugin;

use Nosto\Cmp\Plugin\Catalog\Block\ParameterResolverInterface;

class CustomParameterResolver implements ParameterResolverInterface
{
    /**
     * @inheritdoc
     */
    public function getSortingOrder()
    {
        //ToDo return current sorting order
    }

    /**
     * @inheritdoc
     */
    public function getCurrentPage()
    {
        //ToDo return current page number
    }
}

Inject the CustomParameterResolver

  1. Open the file app/code/My/Nosto/etc/di.xml

  2. Inject the class

   <type name="Nosto\Cmp\Plugin\Catalog\Block\Pager">
        <arguments>
            <argument name="parameterResolver" xsi:type="object">
                My\Nosto\Plugin\CustomParameterResolver
            </argument>
        </arguments>
    </type>
    <type name="Nosto\Cmp\Plugin\Catalog\Block\Toolbar">
        <arguments>
            <argument name="parameterResolver" xsi:type="object">
                My\Nosto\Plugin\CustomParameterResolver
            </argument>
        </arguments>
    </type>

Compiling your changes

In order to compile your changes you'll need to run the di:compile command

bin/magento setup:di:compile
Overriding or Extending Functionalities