Product Data

Product Simple Data

{
    "pk": 12227,
    "name": "Kırmızı Tişört",
    "base_code": "1KBATC0231",
    "sku": "1KBATC0231001",
    "product_type": "0",
    "is_active": true,
    "parent": null,
    "attributes": {
        "boyut": "34X34",
        "renk": "001",
        "uretim_yeri": "Türkiye",
        "materyal": "%100 POLYESTER",
    },
    "productimage_set": [
        {
            "pk": 20044,
            "status": "active",
            "image": "http://localhost:8001/media/products/2021/10/17/12227/1bfe74b4-175e-4c1a-80f2-b355feae498c.jpg"
        }
    ],
    "attribute_set": 2,
    "productization_date": "2017-01-23T16:40:58.578504Z"
}

Mapping Data in the Product

This refers to the result of the mapping service applied to the product data, which includes the characteristics of the sales channel on Akinon.

The mapped_attributes property name is included in the product data and contains the mapping results that the company requires.

In the mapped_attribute_values section, you can access the attribute’s Omnitron ID along with the special code in the sales channel (remote_id) and other attribute information. The attribute_set_id and attribute_set_name indicate which attribute set this product corresponds to in Omnitron. The attribute_set_remote_id is the unique code representing the attribute set in the sales channel.

{
    "pk": 12227,
    "name": "Kırmızı Tişört",
    "base_code": "1KBATC0231",
    "sku": "1KBATC0231001",
    "product_type": "0",
    "is_active": true,
    "parent": null,
    "attributes": {
        "boyut": "34X34",
        "renk": "001",
        "uretim_yeri": "Türkiye",
        "materyal": "%100 POLYESTER",
    },
    "productimage_set": [
        {
            "pk": 20044,
            "status": "active",
            "image": "http://localhost:8001/media/products/2021/10/17/12227/1bfe74b4-175e-4c1a-80f2-b355feae498c.jpg"
        }
    ],
    "attribute_set": 2,
    "productization_date": "2017-01-23T16:40:58.578504Z",
    "mapped_attributes": {
        "pk": 370,
        "mapped_attributes": {
            "size": "34 - 34"
            "color": "red",
            "age": "std",
            "desc": "%100 POLYESTER"
        },
        "attribute_set_id": 1,
        "attribute_set_name": "Giyim",
        "attribute_set_remote_id": null,
        "mapped_attribute_values": {
            "123": {
                "attribute_name": "size",
                "label": "34 - 34",
                "value": "34 - 34",
                "attribute_remote_id": 22,
                "is_required": true,
                "is_variant": false,
                "is_custom": false,
                "is_meta": false
            },
            "223": {
                "attribute_name": "color",
                "label": "RED",
                "value": "red",
                "attribute_remote_id": 23,
                "is_required": true,
                "is_variant": false,
                "is_custom": false,
                "is_meta": false
            },
        }
    }
}

Stock Data in the Product

This refers to the inclusion of stock information in the product data.

The data is contained within productstock in the product data, which includes:

  • stock: The quantity of available stock for sale.

  • stock_list: The ID information of the stock list in Akinon.

  • unit_type: The unit of measurement for the quantity.

  • sold_quantity_unreported: The reserved stock quantity in Akinon.

  • modified_date: The date of the last update.

{
    "pk": 12227,
    "name": "Kırmızı Tişört",
    "base_code": "1KBATC0231",
    "sku": "1KBATC0231001",
    "product_type": "0",
    "is_active": true,
    "parent": null,
    "attributes": {
        "boyut": "34X34",
        "renk": "001",
        "uretim_yeri": "Türkiye",
        "materyal": "%100 POLYESTER",
    },
    "productimage_set": [
        {
            "pk": 20044,
            "status": "active",
            "image": "http://localhost:8001/media/products/2021/10/17/12227/1bfe74b4-175e-4c1a-80f2-b355feae498c.jpg"
        }
    ],
    "attribute_set": 2,
    "productization_date": "2017-01-23T16:40:58.578504Z",
    "productstock": {
        {
            "pk": 1,
            "product": 2250,
            "stock": 46,
            "stock_list": 1,
            "unit_type": "qty",
            "extra_field":{},
            "sold_quantity_unreported": 0,
            "modified_date": "2017-01-23T13:37:31.947171Z"
        }
    }
}

Price Data in the Product

This refers to the inclusion of price information in the product data.

The data is contained within productprice in the product data, which includes:

  • price: The sale price of the product.

  • price_list: The ID information of the price list in Akinon.

  • currency_type: The unit of currency for the price information.

  • tax_rate: The tax rate applied to the product.

  • retail_price: The store price of the product.

  • discount_percentage: The discount information applied to the product.

  • modified_date: The date of the last update.

{
    "pk": 12227,
    "name": "Kırmızı Tişört",
    "base_code": "1KBATC0231",
    "sku": "1KBATC0231001",
    "product_type": "0",
    "is_active": true,
    "parent": null,
    "attributes": {
        "boyut": "34X34",
        "renk": "001",
        "uretim_yeri": "Türkiye",
        "materyal": "%100 POLYESTER",
    },
    "productimage_set": [
        {
            "pk": 20044,
            "status": "active",
            "image": "http://localhost:8001/media/products/2021/10/17/12227/1bfe74b4-175e-4c1a-80f2-b355feae498c.jpg"
        }
    ],
    "attribute_set": 2,
    "productization_date": "2017-01-23T16:40:58.578504Z",
    "productprice": {
        "pk": 2,
        "product": 913,
        "price": "62.44",
        "price_list": 1,
        "currency_type": "try",
        "tax_rate": "8.00",
        "retail_price": "249.75",
        "extra_field": {},
        "discount_percentage": "75.00",
        "modified_date": "2017-01-23T18:29:23.716095Z"
    }
}

Category Data in the Product

This refers to the inclusion of category information in the product data.

The category data is contained within category_nodes in the product data, which includes:

  • name: The name of the category.

{
    "pk": 12227,
    "name": "Kırmızı Tişört",
    "base_code": "1KBATC0231",
    "sku": "1KBATC0231001",
    "product_type": "0",
    "is_active": true,
    "parent": null,
    "attributes": {
        "boyut": "34X34",
        "renk": "001",
        "uretim_yeri": "Türkiye",
        "materyal": "%100 POLYESTER",
    },
    "productimage_set": [
        {
            "pk": 20044,
            "status": "active",
            "image": "http://localhost:8001/media/products/2021/10/17/12227/1bfe74b4-175e-4c1a-80f2-b355feae498c.jpg"
        }
    ],
    "attribute_set": 2,
    "productization_date": "2017-01-23T16:40:58.578504Z"
    "category_nodes": [
        {
            "pk": 255,
            "name": "Shop",
            "order": 1,
            "numchild": 4,
            "depth": 1,
            "sort_option": 20,
            "uuid": "cf461e84-1f19-497b-8fb8-555805e58221",
            "path": "0001",
            "created_date": "2021-10-06T13:48:07.643569Z",
            "modified_date": "2021-11-01T13:54:52.526750Z"
        }
    ]
}

Synchronous or Asynchronous Sales Channel Process

The is_sync parameter relates to whether the product process will be synchronous or asynchronous.

If operations such as insert, update, or delete are processed immediately upon being sent to the sales channel, and the result is returned in the response, then this is a synchronous process. In synchronous operations, the commands related to the product must return data in the ProductBatchRequestResponseDto format:

  • classProductBatchRequestResponseDto(status: channel_app.omnitron.constants.ResponseStatus, sku: str, remote_id: Optional[str] = '', message: Optional[str] = '')

data: any
report: List[ErrorReportDto]
response_data: List[ProductBatchRequestResponseDto]
return response_data, report, data

If the processes are handled asynchronously, a code must be returned from the relevant sales channel for later verification (remote_batch_request_id).

remote_batch_id = response.get("remote_batch_request_id")
self.batch_request.remote_batch_id = remote_batch_id
return "", report, data

If a process is asynchronous but has pre-checks in the sales channel, and some records are processed while immediate results are shared for others, the errors for problematic records must still be indicated, even though the process is asynchronous. These issues appear in the error reports.

self.failed_object_list.append(
    (price, ContentType.product_stock.value,
     "Product has not been sent"))

Source code of the channel_app.core.data item:

import datetime
from dataclasses import dataclass
from decimal import Decimal
from typing import List, Optional

from channel_app.omnitron.constants import ResponseStatus, \
    ChannelConfSchemaDataTypes

@dataclass
class CategoryNodeDto:
    name: str
    children: List['CategoryNodeDto']
    remote_id: Optional[str] = ''
    parent: Optional['CategoryNodeDto'] = None

@dataclass
class CategoryTreeDto:
    root: CategoryNodeDto

@dataclass
class CategoryAttributeValueDto:
    remote_id: str
    name: str

@dataclass
class CategoryAttributeDto:
    remote_id: str
    name: str
    required: bool
    variant: bool
    allow_custom_value: bool
    values: List[CategoryAttributeValueDto]

@dataclass
class AttributeValueDto:
    remote_id: str
    name: str

@dataclass
class AttributeDto:
    remote_id: str
    name: str
    values: List[AttributeValueDto]

@dataclass
class CategoryDto:
    remote_id: str
    name: str
    attributes: List[CategoryAttributeDto]

@dataclass
class ChannelConfSchemaField:
    required: bool
    data_type: ChannelConfSchemaDataTypes
    key: str
    label: str
    schema: Optional[dict] = None

@dataclass
class ErrorReportDto:
    action_content_type: str
    action_object_id: int
    modified_date: str
    raw_request: str = ""
    raw_response: str = ""
    error_code: str = "custom"
    error_description: str = "custom"
    is_ok: bool = False
    target_content_type: Optional[str] = ''
    target_object_id: Optional[str] = ''

@dataclass
class BatchRequestObjectsDto:
    pk: int
    version_date: str
    content_type: str
    failed_reason_type: Optional[str] = ''
    remote_id: Optional[int] = 0

class BatchRequestDto:
    channel: int
    local_batch_id: str
    content_type: str
    pk: Optional[int] = 0
    remote_batch_id: Optional[str] = ''
    status: Optional[str] = ''
    objects: Optional[List[BatchRequestObjectsDto]] = []

@dataclass
class ProductBatchRequestResponseDto:
    status: ResponseStatus
    sku: str
    remote_id: Optional[str] = ''
    message: Optional[str] = ''

@dataclass
class BatchRequestResponseDto:
    status: ResponseStatus
    remote_id: Optional[str] = ''
    sku: Optional[str] = ''
    message: Optional[str] = ''

@dataclass
class OrderBatchRequestResponseDto:
    status: ResponseStatus
    remote_id: str
    number: str
    message: Optional[str] = ''


@dataclass
class OmnitronOrderDto:
    remote_id: str
    number: str
    channel: int
    customer: int
    shipping_address: int
    billing_address: int
    currency: str
    amount: Decimal
    shipping_amount: Decimal
    shipping_tax_rate: Decimal
    extra_field: dict
    cargo_company: int
    created_at: datetime.datetime
    delivery_type: Optional[str] = None
    discount_amount: Optional[Decimal] = "0.0"
    net_shipping_amount: Optional[Decimal] = "0.0"
    tracking_number: Optional[str] = None
    carrier_shipping_code: Optional[str] = ""
    remote_addr: Optional[str] = None
    has_gift_box: Optional[bool] = False
    gift_box_note: Optional[str] = ""
    client_type: Optional[str] = ""
    language_code: Optional[str] = ""
    notes: Optional[str] = ""
    delivery_range: Optional[str] = None
    shipping_option_slug: Optional[str] = ""
    status: Optional[str] = ""

@dataclass
class OrderItemDto:
    remote_id: str
    product: str
    price_currency: str
    price: Decimal
    tax_rate: Decimal
    extra_field: dict
    status: Optional[str] = None
    price_list: Optional[int] = None
    stock_list: Optional[int] = None
    tracking_number: Optional[str] = None
    invoice_number: Optional[str] = None
    invoice_date: Optional[str] = None
    carrier_shipping_code: Optional[str] = ""
    discount_amount: Optional[Decimal] = 0.0
    retail_price: Optional[Decimal] = 0.0
    attributes: Optional[dict] = None
    attributes_kwargs: Optional[dict] = None
    parent: Optional[str] = None
    delivered_date: Optional[str] = None
    estimated_delivery_date: Optional[str] = None

# dataclass used for omnitron.commands.orders.orders.CreateOrders
@dataclass
class OmnitronCreateOrderDto:
    order: OmnitronOrderDto
    order_item: List[OrderItemDto]

@dataclass
class CancelOrderDto:
    order: str  # remote order number
    cancel_items: List[str]  # order_item_remote_id list
    reasons: dict  # order_item_remote_id : reason code
    is_cargo_refund: Optional[bool] = False  # default False
    forced_refund_amount: Optional[bool] = None  # default False
    refund_invoice_number: Optional[str] = None

@dataclass
class CustomerDto:
    email: str  # "[email protected]"
    first_name: str  # "John"
    last_name: str  # "Doe"
    channel_code: str  # will be unique
    extra_field: Optional[dict] = None
    phone_number: Optional[str] = None  # "05556667788"
    is_active: Optional[bool] = True

@dataclass
class AddressDto:
    email: str  # "[email protected]"
    phone_number: str  # "05556667788"
    first_name: str  # "John"
    last_name: str  # "Doe"
    country: str  # 1
    city: str  # 80
    line: str  # "Hemen sahil kenarı"
    title: Optional[str] = None  # "COMM-876"
    township: Optional[str] = None  # 933
    district: Optional[str] = None  # 71387
    postcode: Optional[str] = None  # ""
    notes: Optional[str] = None  # null
    company_name: Optional[str] = None  # ""
    tax_office: Optional[str] = None  # ""
    tax_no: Optional[str] = None  # ""
    e_bill_taxpayer: Optional[bool] = False
    remote_id: Optional[str] = None  # null
    identity_number: Optional[str] = None  # null
    extra_field: Optional[dict] = None  # {}
    is_active: Optional[bool] = True  # true
    retail_store: Optional[str] = None

@dataclass
class ChannelOrderDto(OmnitronOrderDto):
    customer = CustomerDto
    shipping_address = AddressDto
    billing_address = AddressDto
    cargo_company = str

@dataclass
class ChannelCreateOrderDto:
    order: ChannelOrderDto
    order_item: List[OrderItemDto]

@dataclass
class ChannelUpdateOrderItemDto:
    remote_id: str
    order_remote_id: Optional[str] = None
    order_number: Optional[str] = None
    status: Optional[str] = None
    invoice_number: Optional[str] = None
    invoice_date: Optional[str] = None
    tracking_number: Optional[str] = None
    extra_field: Optional[dict] = None

Was this helpful?