Setup
In the setup steps, the codes for the regularly running jobs that operate system-wide are located in the channel_app_template.app.tasks
file. There are three jobs that can run regularly related to the setup steps.
1. Update Channel Conf Schema
Creates the necessary settings for the sales channel to be established in the business process. The process starts by reading the settings through the development made in the sales channel integration, and then sends them to Akinon.
The process is managed via the update_channel_conf_schema
function within the Setup Service.
You can place your desired settings inside the sales channel as key-value pairs, and develop accordingly.
The class GetChannelConfSchema
needs to be modified.
GetChannelConfSchema
Class GetChannelConfSchema(integration, objects=None, batch_request=None, **kwargs)
normalize_response(data, validated_data, transformed_data, response)
Tuple[dict, Any, Any]
The dynamic sales channel configuration settings for the sales channel to be opened are defined here. You can specify the information you want to enter as the sales channel settings in the format below.
To access the main URL, you can use:
>>> self.integration.channel.conf.get("main_url")
Example Code:
schema = {
"main_url": ChannelConfSchemaField(
required=True,
data_type=ChannelConfSchemaDataTypes.text,
key="main_url",
label="Api Url"),
"marchant_id": ChannelConfSchemaField(
required=True,
data_type=ChannelConfSchemaDataTypes.text,
key="marchant_id",
label="Satıcı Kodu"),
}
2. Create or Update Category Tree & Nodes
Creates the category tree for the sales channel on the Akinon side.
The class GetCategoryTreeAndNodes needs to be modified.
GetCategoryTreeAndNodes
class GetCategoryTreeAndNodes(integration, objects=None, batch_request=None, **kwargs)
The category tree present in the sales channel provides the necessary data for it to be created on the Akinon side as well. The command operates without any parameters.
send_request(transformed_data) → HttpResponse
A request is made to access the category tree.
>>> response = self.session.get("url")
>>> return response
normalize_response(data, validated_data, transformed_data, response)
Tuple[CategoryTreeDto, ErrorReportDto, Any]
In category trees, there is a nested structure. The DataClass object to be returned is CategoryTreeDto.
Assuming the tree structure in the sales channel is as follows:
sales channel
├── Giyim
│ ├── Kadın
│ │ └── Elbise
│ └── Erkek
│ └── Pantalon
CategoryTreeDto can be created as follow:
node_elbise = CategoryNodeDto(name="Elbise", children=[], remote_id="Elbise", parent)
node_pantalon = CategoryNodeDto(name="Pantalon", children=[], remote_id="Pantalon", parent)
node_kadin = CategoryNodeDto(name="Kadın", children=[node_elbise], remote_id="Kadın", parent)
node_erkek = CategoryNodeDto(name="Erkek", children=[node_pantalon], remote_id="Erkek", parent)
node_giyim = CategoryNodeDto(name="Giyim", children=[node_kadin, node_Erkek], remote_id="Giyim", parent)
node_root = CategoryNodeDto(name="sales channel", children=[node_giyim], remote_id="sales channel", parent)
report = self.create_report(response)
return node_root, report, []
3. Create or Update Category Attributes
The class GetCategoryAttributes needs to be modified.
GetCategoryAttributes
This class is responsible for creating attributes and attribute values for the categories of the sales channel in Omnitron.
classGetCategoryAttributes(integration, objects=None, batch_request=None, **kwargs)
This service will generate the attributes and their values used in the category tree of the sales channel. The DataClass DataClass used for creating attributes is CategoryAttributeDto.
CategoryAttributeDto can be created as follow:
class CategoryAttributeDto:
remote_id: str # "If available, the remote_id of the attribute; otherwise, the name can be used as the remote_id."
name: str # "The name of the attribute, such as color, size, content, etc."
required: bool # "Indicates whether the attribute is mandatory."
variant: bool # "Indicates whether the attribute is used for variant breakdown."
allow_custom_value: bool # "Indicates whether values other than the predefined values in the sales channel are accepted."
# "For example, may not accept values other than defined for color."
# "For size, it may accept values not defined in the sales channel."
# "Descriptions cannot have defined values, so they always accept custom values."
values: List[CategoryAttributeValueDto]
The created attributes require mapping during product submission.
After the mapping is done, the mapped_attributes
are added to the product data. For detailed information, refer to Mapping Data in the Product.
CategoryAttributeValueDto can be created as follow:
class CategoryAttributeValueDto:
remote_id: str # "The code of the attribute in the sales channel."
name: str # "The value of the attribute."
send_request(transformed_data) → HttpResponse
A request is made to access the properties of the category tree.
>>> response = self.session.get("url")
>>> return response
normalize_response(data, validated_data, transformed_data, response)
Tuple[CategoryDto, ErrorReportDto, Any]
4. Create or Update Attributes
This service is responsible for creating attributes and attribute value pairs for the sales channel in Omnitron and can be used in scenarios where there are no attributes associated with categories.
The class GetAttributes needs to be modified.
GetAttributes
classGetAttributes(integration, objects=None, batch_request=None, **kwargs)
This service is responsible for retrieving the attributes and their values from the sales channel and creating the AttributeDto DataClass.
The created attributes require mapping during product submission.
After the mapping is done, the mapped_attributes
are added to the product data. For detailed information, refer to Mapping Data in the Product.
AttributeDto can be created as follow:
GetAttributes channel.setup.GetAttributes
class AttributeDto:
remote_id: str # "If the attribute exists, this is the code in the sales channel; if not, the name can be used as the remote_id."
name: str # "The name of the attribute, such as color, size, content, etc."
values: List[AttributeValueDto]
AttributeValueDto can be created as follow:
class AttributeValueDto:
remote_id: str # "The code of the attribute in the sales channel."
name: str # "The value of the attribute."
send_request(transformed_data) → HttpResponse
A request is made to access the attributes of the channel.
>>> response = self.session.get("url")
>>> return response
normalize_response(data, validated_data, transformed_data, response)
Tuple[List[AttributeDto], ErrorReportDto, Any]
Source Code
Source code of the channel.commands.setup item:
from typing import Tuple, Any, List
from channel_app.channel.commands.setup import (
GetCategoryTreeAndNodes as AppGetCategoryTreeAndNodes,
GetCategoryAttributes as AppGetCategoryAttributes,
GetAttributes as AppGetAttributes,
GetChannelConfSchema as AppGetChannelConfSchema
)
from channel_app.core.data import (
ErrorReportDto, CategoryTreeDto, CategoryDto, AttributeDto
)
class GetCategoryTreeAndNodes(AppGetCategoryTreeAndNodes):
def transform_data(self, data) -> Any:
raise NotImplementedError
def send_request(self, transformed_data) -> object:
raise NotImplementedError
def normalize_response(self, data, validated_data, transformed_data,
response) -> Tuple[CategoryTreeDto, ErrorReportDto,
Any]:
raise NotImplementedError
class GetCategoryAttributes(AppGetCategoryAttributes):
def get_data(self) -> object:
raise NotImplementedError
def validated_data(self, data) -> object:
raise NotImplementedError
def transform_data(self, data) -> object:
raise NotImplementedError
def send_request(self, transformed_data) -> object:
raise NotImplementedError
def normalize_response(self, data, validated_data, transformed_data,
response) -> Tuple[CategoryDto, ErrorReportDto,
Any]:
raise NotImplementedError
class GetAttributes(AppGetAttributes):
def get_data(self) -> object:
raise NotImplementedError
def validated_data(self, data) -> object:
raise NotImplementedError
def transform_data(self, data) -> object:
raise NotImplementedError
def send_request(self, transformed_data) -> object:
raise NotImplementedError
def normalize_response(self, data, validated_data, transformed_data,
response) -> Tuple[
List[AttributeDto], ErrorReportDto, Any]:
raise NotImplementedError
class GetChannelConfSchema(AppGetChannelConfSchema):
def normalize_response(self, data, validated_data, transformed_data,
response) -> Tuple[dict, Any, Any]:
raise NotImplementedError