# Price List

The name of product prices is ProductPrice. PriceList is used to create multiple lists to link to channels and similar operations. On the Shop side, when linked to the channel, the price list continues to flow without a PriceList defined in that section.

The description above is valid for the conventional loop. Multiple PriceList & StockList developments allow for the definition of multiple price lists on the basis of RetailStore.

The concept of extra price list is created to add PriceList in multiple ways. Thanks to this structure linked to the catalogs, the linked `extra_price_list` and `ProductPrice` values are sent to the shop that is matched with the relevant catalog.

## `GET` Price List

Sample HTTP request to get all price 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/price_list`

```python
import requests

url = "https://{customer_api_url}/api/v1/price_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**

```json
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
          {
            "pk": 1,
            "name": "default_price_list",
            "code": "default_price_list",
            "is_auto_sync": true,
            "modified_date": "2017-01-22T12:14:44.637000Z",
            "created_date": "2017-01-22T12:14:44.637000Z",
            "currency": "try"          
            }
               ]
}

```

## `POST` Create Price List

Records new objects in the `PriceList` table. The `PriceListSerializer` class defined at `omnitron.catalogs.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/price_list/`

```python
import requests

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

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

data = {
    "name": "Test List",
    "code": "test_list",
    "is_auto_sync": True
}

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

```

**Response**

```json
{
    "pk": 2,
    "name": "Test List",
    "code": "test_list",
    "is_auto_sync": true,
    "modified_date": "2021-02-18T11:55:03.741159Z",
    "created_date": "2021-02-18T11:55:03.741139Z",
    "Currency": "try"

}
```

## `PATCH` Update Price List

Update the object specified with the primary key in the `PriceList` table.

‘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/price_list/{PK}/`

```python
import requests

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

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

data = {
    "name": "Test List Updated"
}

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

**Response**

```json
{
    "pk": 2,
    "name": "Test List Updated",
    "code": "test_list",
    "is_auto_sync": true,
    "currency": "try"
    "modified_date": "2021-02-18T12:02:40.890103Z",
    "created_date": "2021-02-18T11:55:03.741139Z"

}
```

## `POST` Bulk Upsert Price List

Sample HTTP post request to create multiple price lists at once. Make sure you have an acceptable dataset and file.

**Request**

<figure><img src="/files/eKZcUwzVnYMo9NcZ3s7L" alt=""><figcaption></figcaption></figure>

**Path:** `/api/v1/price_list/{PK}/excel_import/`

csv file should contain the following headers and their values:

```
csv[headers]: product__sku,price, retail_price, price_list, tax_rate
csv[values]: 1, 43.2, 86.4, 1, 18.00
```

**Response**

This is an asynchronous operation and the status of the operation can be followed when it sends a `GET` request at the endpoint where it will check the status with `cache_key`. It should be noted that only 1 cache key is returned in the response.

**cache\_key:** Unique cache key to status lookup.

```
{
  "cache_key":"b6b0828c-34ec-445b-9c06-5ae060ad1029"
}
```

## Check Status with Cache Key

Checking the status of the bulk upsert process with the received cache key.

**status:** This is representing the process of excel import status and can be **waiting**, **in\_progress** and **completed**.

**chunk\_size:** In default, it is set to 100, indicating the number of times the entered line count is divided into 100-sized chunks. For example, if 300 data is entered and the chunk size is 3, it would mean that it was divided into 100-sized chunks three times.

**Path:** `/api/v1/price_list/{CACHE_KEY}/excel_import_status/`

**Waiting Status:**

<figure><img src="/files/FhasPgSMdhcJ9KkVnTX8" alt=""><figcaption></figcaption></figure>

**Completed Status:**

<figure><img src="/files/IYwCl4pIWyQPN29txATk" alt=""><figcaption></figcaption></figure>

**Bad Response**

If there is no valid file, this will raise the exception file\_100\_1(FileNotFoundException). Django REST's status codes and exceptions are returned because another REST is used.

```
{
    "non_field_errors": "File not found please provide an appropriate file",
    "error_code": "file_100_1"
}
```

#### Service(omnitron.catalogs.service.PriceListService)

`create_price_list:` Improvements have been made to ensure that `is_auto_sync` is True in code.

`bulk_upsert:` Improvements have been made to add multiple `ProductPrices`.

#### Channel Redirections

As mentioned above, when the relevant PriceList and Channel matching is performed, all ProductPrices linked to the relevant PriceList are sent to the Channels.

For instance;

When inspected, the method at `omnitron.channels.integrations.omniweb.integration. Integration.qs__product_price` will show a filter such as `price_listcatalogchannel=self.channel_id` . All `ProductPrices` in the select query will be sent by accessing the channel through the catalog linked to the `PriceList` and matching it with the relevant channel.

#### Data Source

Just like the principle in Channels, `ProductPrices` can be used for `DataSource`. `DataSource` is the structure that enables selling between Omnitron and creates an environment like a marketplace. It is done by direct match over the `DataSource` model.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.akinon.com/omnitron/catalogue/price-list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
