LogoLogo
  • Welcome to Akinon Documentation
  • Products
    • ACC
    • Omnitron
    • Commerce
    • Order Management System (OMS)
    • Instore
    • Integrator
    • Marketplace Dashboard (MPD)
    • Project Zero (PZ)
    • Seller Center
    • Akifast
    • App Maker
  • API Reference
    • Welcome to Akinon API Reference
  • Omnitron
    • Getting Started
    • Integration
      • Product
        • Product
        • Pre-Product
        • Attribute
        • Attribute Value
        • Attribute Set
        • Product Image
      • Price
        • Price List
        • Product Price
        • Currency Unit Table
      • Stock
        • Stock List
        • Product Stock
      • Order
        • Get Orders
        • Search Order
        • Get Order Detail by Order Number
        • Get Order Item Detail
        • Orders ID Detail Integration
        • Orders Waiting to Send to ERP
        • Update Order and Order Item
        • Stock Reservation Release
        • Order Cancellation
        • Cancellation & Refund Pending Orders
        • Order Discount Items
        • Order Status Codes & Cancellation Statuses
      • Migration
        • Getting Started
        • User Migration
        • Address Migration
        • Old Order Migration
        • Old Order Item Migration
        • View Migration Progress
        • Currency Options
    • PIM
      • Attributes & Sets
      • Mapping
      • Localization
      • Media
    • Catalogue
      • Introduction
      • Price List
      • Stock List
      • Catalogue Item
      • Category Trees
      • Product Collection
      • Product Sorting
    • Channels
      • Introduction
      • Payments
      • Customers
    • Order
      • Getting Started
      • Fulfillment
      • Cancellations & Refunds
    • Retail Stores
      • Retail Stores
    • User Management
      • Roles & Permissions
      • Add & Remove
    • Whippy Ware
      • Introduction
      • Stock
      • Stock Lists
      • Stock List Rules
      • Stock Providers
      • Stock Locations
  • Omnitron OpenAPIs
    • Without Server
      • Customers
      • Reporting
      • Deleted Items
      • Pos
      • AttributeValues
      • Attribute Values
      • Providers
      • LDAPProviders
      • Healthcheck
      • LoyaltyTransactions
      • Policies
      • Exports
      • Dashboard
      • AuthTOTP
      • Price Lists
      • ProductPrices
      • Districts
      • Cities
      • Countries
      • Townships
      • PrometheusMetrics
      • Language
      • Content Types
      • Mappings
      • Applications
      • ApplicationPermissions
      • Error Reports
      • MailTemplates
      • UploadLogo
      • SalesChannelMarketPlaceAttributeSetConfig
      • SalesChannelCancellationRequestImage
      • SalesChannelCities
      • SalesChannelCancellationReasons
      • SalesChannelCargoCompany
      • SalesChannelProductImage
      • SalesChannelAttributeConfig
      • SalesChannelAttributeValueConfig
      • SalesChannelTownships
      • SalesChannelCustomers
      • SalesChannelFailedIntegrations
      • SalesChannelGetStockList
      • SalesChannelRetailStore
      • IntegrationActions
      • SalesChannelOrderShippingInfo
      • SalesChannelBatchRequests
      • SalesChannelAddresses
      • SalesChannelMarketPlaceAttributeSet
      • SalesChannelErrorReports
      • SalesChannelCategoryNodes
      • SalesChannelDistricts
      • SalesChannelProductStock
      • SalesChannelExtraProductStock
      • SalesChannelOrders
      • SalesChannelCancellationPlans
      • SalesChannelExtraProductPrices
      • SalesChannelProduct
      • SalesChannelAttributeSchemas
      • SalesChannelProductCategories
      • SalesChannelCancellationRequests
      • SalesChannelMarketPlaceAttributeValue
      • SalesChannelMappedProduct
      • SalesChannelMarketPlaceAttribute
      • SalesChannelOrderItem
      • SalesChannelProductPrice
      • SalesChannelCreateOrder
      • GetPriceList
      • SalesChannelCountries
      • SalesChannelGetPriceList
      • SalesChannelCategoryTree
    • With Server
      • Customers
      • Reporting
      • Deleted Items
      • Pos
      • AttributeValues
      • Attribute Values
      • Providers
      • LDAPProviders
      • Healthcheck
      • LoyaltyTransactions
      • Policies
      • Exports
      • Dashboard
      • AuthTOTP
      • Price Lists
      • ProductPrices
      • Districts
      • Cities
      • Countries
      • Townships
      • PrometheusMetrics
      • Language
      • Mappings
      • Content Types
      • Applications
      • ApplicationPermissions
      • Error Reports
      • MailTemplates
      • UploadLogo
      • SalesChannelMarketPlaceAttributeSetConfig
      • SalesChannelCancellationRequestImage
      • SalesChannelCities
      • SalesChannelCancellationReasons
      • SalesChannelCargoCompany
      • SalesChannelProductImage
      • SalesChannelAttributeConfig
      • SalesChannelAttributeValueConfig
      • SalesChannelTownships
      • SalesChannelCustomers
      • SalesChannelFailedIntegrations
      • SalesChannelGetStockList
      • IntegrationActions
      • SalesChannelRetailStore
      • SalesChannelOrderShippingInfo
      • SalesChannelBatchRequests
      • SalesChannelAddresses
      • SalesChannelMarketPlaceAttributeSet
      • SalesChannelErrorReports
      • SalesChannelDistricts
      • SalesChannelCategoryNodes
      • SalesChannelProductStock
      • SalesChannelExtraProductStock
      • SalesChannelCountries
      • SalesChannelOrders
      • SalesChannelProduct
      • SalesChannelCancellationPlans
      • SalesChannelExtraProductPrices
      • SalesChannelProductCategories
      • SalesChannelAttributeSchemas
      • SalesChannelCancellationRequests
      • SalesChannelMarketPlaceAttributeValue
      • SalesChannelMappedProduct
      • SalesChannelMarketPlaceAttribute
      • SalesChannelOrderItem
      • SalesChannelProductPrice
      • SalesChannelCreateOrder
      • GetPriceList
      • SalesChannelGetPriceList
      • SalesChannelCategoryTree
  • Commerce
    • Users
      • Getting Started
      • User Management & Authentication
      • Password & OTP Operations
      • User Profile & Segment Management
      • User Payment & Card Management
      • User Orders & Cancellations
      • Anonymous User Orders & Cancellations
      • User Support & Conversation
      • Captcha Validation
      • Currency & Akifast Operations
    • Checkout
      • Payment Related
      • Payment Strategy Related
      • Shipping Related
      • Independent Pages
    • Product
    • User Collections
    • Basket
    • Discount
    • Autocomplete
    • Breadcrumb
    • Pretty URLs
    • Menu
    • Widgets
    • Loyalty Accounts
    • Address Migration
    • Index Configuration
    • Favourite Products
    • User Address
    • Data Warehouse
    • Introduction
      • Filtering Parameters
    • Data Warehouse
    • Default
  • OMS
    • Package Services
    • Package Item Services
    • Package Denial Reason Services
    • Order Services
    • Order Item Services
    • Transfer Order Services
    • Transfer Item Services
    • Channel Services
    • Cancellation Plan Services
    • Cancellation Reason Services
    • Address Setup Services
    • City Services
    • District Services
    • Township Services
    • Stock Location Address Services
    • Webhook Setup Services
    • Webhook Event Services
    • Omnitron Order Webhooks
    • Undelivered Webhook Event Services
    • Inventory Discrepancy Services
    • OMS Setup Services
    • UI Settings Services
    • OMS Audit Events Service
    • Customer Address Services
    • Application Settings Services
    • Content Type Services
    • Customer Services
    • Channel Setup Services
    • Demo Data Service
    • Order Execution Plan Services
    • Invoice Services
    • Localization Services
    • Action Log Services
    • Order Log Services
    • Celery Metrics Service
    • Stock Location Services
    • Stock Location Address Services
    • Stock Location Sender Address Services
    • Stock Location Sender Address Setup Services
    • Cargo Company Condition Services
    • Permission Group Services
  • OMS OpenAPIs
    • Package Services
      • Default
    • Transfer Order Services
      • Default
  • Instore
    • Password Reset Services
  • Integrator
    • Projects
    • Flows
    • Logs
  • Seller Center
    • Languages
    • Categories
    • Introduction
    • Products
    • Packages
    • Orders
    • Claims
    • Shipping Methods
  • Akifast
    • Authentication
  • B2B
    • Quotation
    • Basket
    • Division
    • User
    • Staff User
    • Groups
    • Notification
    • Notification Template
  • Flows
    • Shipment Flows
    • Payment Flows
    • SMS Flows
    • Basket Offer Flows
Powered by GitBook

© 2025 Akinon. All rights reserved.

On this page
  • Product Sorting API Methods
  • GET Sorting Algorithms
  • POST Create Sorting Algorithm
  • PATCH Update Sorting Algorithm
  • GET List All Addable Products for the Algorithm
  • GET List All Products in an Algorithm
  • Sort Option API Methods
  • GET Sort Options
  • POST Create Sort Option
  • POST Add Sorting Algorithms to Sort Option
  • Product Sorting Item API Methods
  • GET Product Sorting Items
  • POST Create Product Sorting Items
  • DELETE Product Sorting Items

Was this helpful?

  1. Omnitron
  2. Catalogue

Product Sorting

Product Sorting API Methods

The SortingAlgorithm model ensures that the products in the categories and collections are sorted according to a certain algorithm. Sorting types can be static, dynamic or external. When the static sorting algorithms are used for the catalog or collection, the products are sorted statically without depending on other conditions. In dynamic sorting algorithms, a sorting rule set is created by using certain filters so that the products in the catalog or collection are renewed and sorted according to the determined rule set. External sorting algorithms sort by the saved rules with a file.

GET Sorting Algorithms

Sample HTTP request to retrieve all sorting algorithm lists from the system with their details.

‘content_type’ header represents the response type.

The "Authorization" header is required for authentication. You can retrieve api_token by logging in.

Path: /api/v1/sorting_algorithms/

Request

import requests

url = "https://{customer_api_url}/api/v1/sorting_algorithms/"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

response = requests.get(url, headers=headers)
print(response.text)

Response

In response, it returns the sorting algorithm details. The rule set that comes in the response also contains the rules of the relevant dynamic sorting.


{
    "count": n,
    "next": "/api/v1/sorting_algorithms/?limit=1&page=2",
    "previous": null,
    "results": [
        {
            "pk": 1,
            "code": "a0001",
            "name": "Default",
            "sorting_type": "dynamic",
            "ruleset": [
                {
                    "rule_type": "sorter",
                    "exp": [
                        {
                            "field": "priority"
                        }
                    ],
                    "order": "desc",
                    "mode": "max",
                    "path": "r0001"
                },
                {
                    "rule_type": "sorter",
                    "exp": [
                        {
                            "field": "listed_id"
                        }
                    ],
                    "order": "desc",
                    "mode": "max",
                    "path": "r0002"
                }
            ],
            "config": {},
            "is_visible": true,
            "catalog": 1
        }
    ]
}

POST Create Sorting Algorithm

Records new objects in the SortingAlgorithm table. The SortingAlgorithmSerializer class defined at omnitron.search.resources.serializers is used to validate the data.

Request

Path: /api/v1/sorting_algorithms/

import requests

url = "https://{customer_api_url}/api/v1/sorting_algorithms/"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

data = {
    "sorting_type":"dynamic",
    "is_visible":False,
    "name":"test algorithm",
    "catalog":{catalog-id},
    "ruleset":[
        {
            "rule_type":"sorter",
            "exp":[{"field":"attributes__max_installment"}],
            "order":"desc"
        },
        {
            "rule_type":"sorter",
            "exp":[{"field":"stock"}],
            "order":"desc"
        }]
}

response = requests.post(url, headers=headers, data=data)
print(response.text)

Response

Returns the created sorting algorithm items properties. Response Status Code: 201

{
    "pk": 41,
    "code": "a0009",
    "name": "test algorithm",
    "sorting_type": "dynamic",
    "ruleset": [
        {
            "rule_type": "sorter",
            "exp": [
                {
                    "field": "attributes__max_installment"
                }
            ],
            "order": "desc",
            "mode": "max",
            "path": "r0001"
        },
        {
            "rule_type": "sorter",
            "exp": [
                {
                    "field": "stock"
                }
            ],
            "order": "desc",
            "mode": "sum",
            "path": "r0002"
        }
    ],
    "config": {},
    "is_visible": false,
    "catalog": {catalog-id},
    "modified_date": "2022-12-22T09:54:31.076718Z",
    "created_date": "2022-12-22T09:54:31.076685Z"
}

PATCH Update Sorting Algorithm

Update the object specified with the primary key in the SortingAlgorithm table.

‘content_type’ header represents the response type.

The ‘Authorization’ header is required for authentication. You can retrieve api_token by logging in.

Path: /api/v1/sorting_algorithms/{sorting-algorithm-pk}


import requests

url = "https://{customer_api_url}/api/v1/sorting_algorithms/{PK}/"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

data = {
    "sorting_type":"static",
    "is_visible":True,
    "name": "Test Updated"
}

response = requests.patch(url, headers=headers, data=data)
print(response.text)

Response

{
    "pk": 41,
    "code": "a0009",
    "name": "Test Updated",
    "sorting_type": "static",
    "ruleset": [
        {
            "rule_type": "sorter",
            "exp": [
                {
                    "field": "attributes__max_installment"
                }
            ],
            "order": "desc",
            "mode": "max",
            "path": "r0001"
        },
        {
            "rule_type": "sorter",
            "exp": [
                {
                    "field": "stock"
                }
            ],
            "order": "desc",
            "mode": "sum",
            "path": "r0002"
        }
    ],
    "config": {},
    "is_visible": true,
    "catalog": 1,
    "modified_date": "2022-12-22T10:14:56.911146Z",
    "created_date": "2022-12-22T09:54:31.076685Z"
}

GET List All Addable Products for the Algorithm

Path: /api/v1/sorting_algorithms/{sorting-algorithm-pk}/product_list/

The endpoint where the products that can be added to the algorithm are listed. Essentially, it returns products added for static sorting.

Response


{
    "count": n,
    "next": "/api/v1/sorting_algorithms/{sorting-algorithm-pk}/product_list/?limit=1&page=2",
    "previous": null,
    "results": [
        {
            "pk": 468,
            "name": "VEST / SWEATER",
            "base_code": "1182701",
            "sku": "1182701040",
            "product_type": "0",
            "is_active": true,
            "parent": 210347,
            "attributes": {
                "erp_ProductDetailName": "NYLON",
                "integration_MainColour": "EVERGREEN"
            },
            "attributes_kwargs": {},
            "extra_attributes": {},
            "group_products": [],
            "productimage_set": []
            ...
        }
    ]
}

GET List All Products in an Algorithm

Sample HTTP request to return the entire list of items linked to sorting algorithms.

‘content_type’ header represents the response type.

The ‘Authorization’ header is required for authentication. You can retrieve api_token by logging in.

Request

Path: /api/v1/sorting_algorithms/{sorting-algorithm-pk}/item_list/

The endpoint where the products in the algorithm are listed.


import requests

url = "https://{customer_api_url}/api/v1/sorting_algorithms/{PK}/item_list/"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

response = requests.get(url, headers=headers)
print(response.text)

Response

{
    "count": n,
    "next": "/api/v1/sorting_algorithms/{sorting-algorithm-pk}/item_list/?limit=1&page=2",
    "previous": null,
    "results": [
        {
            "pk": 468,
            "name": "VEST / SWEATER",
            "base_code": "1182701",
            "sku": "1182701040",
            "product_type": "0",
            "is_active": true,
            "parent": 210347,
            "attributes": {
                "erp_ProductDetailName": "NYLON",
                "integration_MainColour": "EVERGREEN"
            },
            "attributes_kwargs": {},
            "extra_attributes": {},
            "group_products": [],
            "productimage_set": []
            ...
        }
    ]
}

Sort Option API Methods

By saving the sorting score produced by the Sorting Algorithm, it allows Elasticsearch to sort according to this value for the shop.

GET Sort Options

Sample HTTP request to get all sort options lists with its details from the system.

‘content_type’ header represents the response type.

The ‘Authorization’ header is required for authentication. You can retrieve api_token by logging in.

Path: /api/v1/sort_options/

Request

import requests

url = "https://{customer_api_url}/api/v1/sort_options"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

response = requests.patch(url, headers=headers)
print(response.text)

Response

Returns the sort options details. Sorting algorithm ID values are kept in the responses, and optional channel information can be added.

{
    "count": n,
    "next": "/api/v1/sort_options/?limit=1&page=2",
    "previous": null,
    "results": [
        {
            "pk": 12,
            "channel": null,
            "sorting_algorithms": [
                25,
                703,
                40
            ],
            "label": "Demo Sub Category",
            "value": "6d9fe140-a02f-4470-9989-f8e4303c9751",
            "order": null,
            "is_default": false,
            "is_visible": false,
            "translations": null,
            "catalog": {catalog-id},
            "disable_score": false
        }
    ]
}

POST Create Sort Option

Records new objects in the SortOption table. The SortOptionSerializer class defined at omnitron.search.resources.serializers is used to validate the data.

Request

Path: /api/v1/sort_options/

{
    "channel": null,
    "sorting_algorithms": [
        {sorting-algorithm-pk},
        ...
    ],
    "label": "label",
    "order": null,
    "is_default": false,
    "is_visible": false,
    "catalog": {catalog-pk},
    "disable_score": false
}

Response

{
    "pk": 12,
    "channel": null,
    "sorting_algorithms": [
        {sorting-algorithm-pk},
        ...
    ],
    "label": "label",
    "order": null,
    "is_default": false,
    "is_visible": false,
    "catalog": {catalog-pk},
    "disable_score": false
}

POST Add Sorting Algorithms to Sort Option

To add an extra sorting algorithm to the sorting options, the relevant endpoint is used and the sorting_algorithm and options IDs to be added must be entered. The sent data information list should be sent. In addition, a sort option can only have one static algorithm.

Request

Path: /api/v1/sort_options/{sort-option-pk}/add_sorting_algorithms/

Data

[
    {
        "algorithm": {sorting-algorithm-pk},
        "option": {sort-option-pk}
    }
]

Response

{
    "pk": 12,
    "channel": null,
    "sorting_algorithms": [
        {sorting-algorithm-pk},
        ...
    ],
    "label": "label",
    "order": null,
    "is_default": false,
    "is_visible": false,
    "catalog": {catalog-pk},
    "disable_score": false
}

Bad Response

If a static algorithm is not entered, it will throw an error as follows:

Static code is 400 (Bad Response)

[
    {
        "non_field_errors": [
            "A sort option can only have one static algorithm!"
        ]
    }
]

Product Sorting Item API Methods

It is the model with the score calculated by the sorting algorithm of the product. The sorting score is calculated by the linked algorithm.

GET Product Sorting Items

Sample HTTP request to get all product sorting items lists from the system.

‘content_type’ header represents the response type.

The ‘Authorization’ header is required for authentication. You can retrieve api_token by logging in.

Request

Path: /api/v1/product_sorting_items/


import requests

url = "https://{customer_api_url}/api/v1/product_sorting_items"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

response = requests.get(url, headers=headers)
print(response.text)

Response


{
    "count": n,
    "next": "/api/v1/product_sorting_items/"
    "previous": null,
    "results": [
        {
            "pk": 8769,
            "catalog_item": {catalog-item-pk},
            "sorting_algorithm": {sorting-algorithm-pk},
            "modified_date": "2021-10-15T07:21:14.937432Z",
            "created_date": "2021-10-15T07:21:14.937362Z"
        },
        ...
    ]
}

POST Create Product Sorting Items

Records new objects in the ProductSortingItem table. The ProductSortingItemSerializer class defined at omnitron.resources.serializers is used to validate the data.

‘content_type’ header represents the response type.

The ‘Authorization’ header is required for authentication. You can retrieve api_token by logging in.

Request

Path: /api/v1/product_sorting_items/


import requests

url = "https://{customer_api_url}/api/v1/product_sorting_items"
api_token = "API TOKEN"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

data = {
    "catalog_item": {catalog-item-pk},
    "sorting_algorithm": {sorting-algorithm-pk}
}


response = requests.post(url, headers=headers, data=data)
print(response.text)

Response


{
    "pk":12,
    "catalog_item":{catalog-item-pk},
    "sorting_algorithm":{sorting-algorithm-pk}
}

DELETE Product Sorting Items

Allows users to completely remove certain product sorting items. Returns "204 No Content"

Path: /api/v1/product_sorting_items/{product-sorting-item-pk}/

Response Status Code: 204

PreviousProduct CollectionNextChannels

Last updated 27 days ago

Was this helpful?