» Category SDK Documentation

Getting All Categories

Function: admin_categories_get_list()

Purpose

The admin_categories_get_list function is designed to retrieve a list of all product categories available in the system. This function helps to fetch detailed information about each category, including their names, URLs, images, and associated products.

Parameters

This function does not require any input parameters.

Use Case

Use this function when you need to display or manage categories in your application, such as building category navigation menus, managing category hierarchies, or reviewing category details for administrative purposes.

def admin_categories_get_list_test():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        response = webcommander_sdk.admin_categories.list()
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a ShippingRatesListResponseDTO, which contains a list of ShippingRateDTO objects. Each object includes detailed information about a shipping rate, such as its ID, name, policy type, conditions, and timestamps.

CategoriesListResponseDTO(
    categories=[
        CategoryDTO(
            id=PLACEHOLDER_CATEGORY_ID,
            name="PLACEHOLDER_CATEGORY_NAME",
            sku="PLACEHOLDER_CATEGORY_SKU",
            title="PLACEHOLDER_TITLE",
            heading="PLACEHOLDER_HEADING",
            url="PLACEHOLDER_URL",
            available=True,
            visible=None,
            parentCategory=CategoryReferenceDTO(
                id=None,
                name=None,
                isInTrash=None,
                isParentInTrash=None,
                isDisposable=None
            ),
            layout=LayoutDTO(id=None, name=None),
            productPage=LayoutDTO(id=None, name=None),
            productLayout=LayoutDTO(id=None, name=None),
            availableOnDateRange=False,
            availableFromDate="",
            availableToDate="",
            availableFor="PLACEHOLDER_AUDIENCE",
            selectedCategories=[],
            passwordProtected=False,
            password="",
            imageUrl="PLACEHOLDER_IMAGE_URL",
            backgroundImageUrl=None,
            summary="PLACEHOLDER_SUMMARY",
            description="PLACEHOLDER_DESCRIPTION",
            products=[
                ProductDTO(id=PLACEHOLDER_PRODUCT_ID, name="PLACEHOLDER_PRODUCT_NAME")
            ],
            shippingProfile={},
            taxProfile={},
            disableTracking=False,
            seoConfigs=[],
            transactionNo=None,
            isDisposable=False,
            isInTrash=False,
            isParentInTrash=False,
            createdBy=CreatedByDTO(id=None, name=None),
            createdOn="PLACEHOLDER_CREATED_ON",
            updatedOn="PLACEHOLDER_UPDATED_ON"
        )
    ],
    pagination=PaginationDTO(
        records=PLACEHOLDER_TOTAL_RECORDS,
        limit=PLACEHOLDER_LIMIT,
        offset=PLACEHOLDER_OFFSET,
        nextPage=None,
        previousPage=None
    )
)

Getting Specific Categories

Functions: admin_categories_get_details() 

Purpose

The admin_categories_get_details function is designed to retrieve the details of a specific category using its unique identifier. This function helps to fetch comprehensive information about the selected category, including metadata, associated products, and configuration settings

Parameters

Parameter
Type
Description
id
String
The unique identifier of the product.

Use Case

Use this function when you need to display or validate the details of a particular category in your system. It's especially useful for administrative dashboards or during integration testing to ensure the category data is accurate and complete.

def admin_categories_get_details_test():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        id = 'PLACEHOLDER_CATEGORY_ID'
        response = webcommander_sdk.admin_categories.details(id=id)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns detailed information of the specified category, wrapped in a response DTO. The response includes attributes such as the category name, URL, availability status, parent category reference, associated products, and timestamps for creation and last update.

CategoriesDetailsResponseDTO(
    category=CategoryDTO(
        id=PLACEHOLDER_CATEGORY_ID,
        name='PLACEHOLDER_CATEGORY_NAME',
        sku='PLACEHOLDER_CATEGORY_SKU',
        title='PLACEHOLDER_CATEGORY_TITLE',
        heading='PLACEHOLDER_CATEGORY_HEADING',
        url='PLACEHOLDER_CATEGORY_URL',
        available=True,
        visible=None,
        parentCategory=CategoryReferenceDTO(
            id=None,
            name=None,
            isInTrash=None,
            isParentInTrash=None,
            isDisposable=None
        ),
        layout=LayoutDTO(id=None, name=None),
        productPage=LayoutDTO(id=None, name=None),
        productLayout=LayoutDTO(id=None, name=None),
        availableOnDateRange=False,
        availableFromDate='PLACEHOLDER_FROM_DATE',
        availableToDate='PLACEHOLDER_TO_DATE',
        availableFor='PLACEHOLDER_AVAILABILITY_SCOPE',
        selectedCategories=[],
        passwordProtected=False,
        password='',
        imageUrl='PLACEHOLDER_IMAGE_URL',
        backgroundImageUrl=None,
        summary='PLACEHOLDER_SUMMARY',
        description='PLACEHOLDER_DESCRIPTION',
        products=[
            ProductDTO(id=PLACEHOLDER_PRODUCT_ID_1, name='PLACEHOLDER_PRODUCT_NAME_1'),
            ProductDTO(id=PLACEHOLDER_PRODUCT_ID_2, name='PLACEHOLDER_PRODUCT_NAME_2')
        ],
        shippingProfile={},
        taxProfile={},
        disableTracking=False,
        seoConfigs=[],
        transactionNo=None,
        isDisposable=False,
        isInTrash=True,
        isParentInTrash=False,
        createdBy=CreatedByDTO(id=None, name=None),
        createdOn='PLACEHOLDER_CREATED_ON',
        updatedOn='PLACEHOLDER_UPDATED_ON'
    )
)

Creating Specific Categories

Functions: admin_create_categories() 

Purpose

The admin_create_categories function is designed to create a new category in the system. It allows defining various properties of the category, such as name, title, parent category, availability, SEO configurations, images, and analytics settings. This function enables administrators to dynamically manage and expand their product catalog by adding new categories.

Parameters

Parameter
Type
Description
name
String
The unique name of the tax profiles.

Use Case

Use this function when you want to create a new category for organizing products in the system. It is useful for scenarios like launching a new product line, structuring the catalog with subcategories, or adding promotional categories. You can specify all the relevant category details, including availability settings, meta information, and SEO data to improve the discoverability of the category.

def admin_create_categories_test():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        request_data = CategoryDataDTO(
            name="PLACEHOLDER_CATEGORY_NAME",
            title="PLACEHOLDER_TITLE",
            heading="PLACEHOLDER_HEADING",
            available=True,
            categoryAvailable=True,
            parentCategory=ParentCategoryDTO(
                id="PLACEHOLDER_PARENT_CATEGORY_ID",
                name="PLACEHOLDER_PARENT_CATEGORY_NAME"
            ),
            productPage=PageDTO(
                id="PLACEHOLDER_PRODUCT_PAGE_ID"
            ),
            productLayout=PageDTO(
                id="PLACEHOLDER_PRODUCT_LAYOUT_ID"
            ),
            availability=AvailabilityDTO(
                onDateRange=True,
                fromDate="PLACEHOLDER_FROM_DATE",
                toDate="PLACEHOLDER_TO_DATE"
            ),
            availabilityDetails=AvailabilityDetailsDTO(
                availableFor="PLACEHOLDER_AVAILABLE_FOR",
                selectedCustomers=["PLACEHOLDER_CUSTOMER_ID"],
                restrictSelectedCustomers=True
            ),
            protectionDetails=ProtectionDetailsDTO(
                codeProtected=True,
                codeToProtect="PLACEHOLDER_PROTECTION_CODE"
            ),
            images=ImagesDTO(
                url="PLACEHOLDER_IMAGE_URL",
                baseUrl="PLACEHOLDER_BASE_URL",
                thumbUrl="PLACEHOLDER_THUMB_URL",
                backgroundImage=None
            ),
            summary="PLACEHOLDER_SUMMARY",
            description="PLACEHOLDER_DESCRIPTION",
            products=[
                ProductDTO(id="PLACEHOLDER_PRODUCT_ID")
            ],
            productSorting="PLACEHOLDER_PRODUCT_SORTING",
            disableTracking=False,
            loyaltyPoints=0,
            seoConfigurations=SEOConfigurationsDTO(
                url="PLACEHOLDER_SEO_URL",
                overwriteSeoSettings=False,
                seoTitle="PLACEHOLDER_SEO_TITLE",
                seoDescription="PLACEHOLDER_SEO_DESCRIPTION",
                searchEngineIndexing=False,
                canonicalUrl=CanonicalUrlDTO(
                    enable=True,
                    url=["PLACEHOLDER_CANONICAL_URL_1", "PLACEHOLDER_CANONICAL_URL_2"]
                )
            ),
            additionalMetaInfo=AdditionalMetaInfoDTO(
                enable=True,
                metaInfo=[
                    MetaInfoDTO(tagName="PLACEHOLDER_TAG_NAME", tagContent="PLACEHOLDER_TAG_CONTENT"),
                    MetaInfoDTO(name="PLACEHOLDER_META_NAME", value="PLACEHOLDER_META_VALUE")
                ]
            ),
            analytics=AnalyticsDTO(
                defaultProductListingConfigurations=False,
                thirdPartyAnalytics=ThirdPartyAnalyticsDTO(
                    enable=True,
                    platform="PLACEHOLDER_ANALYTICS_PLATFORM",
                    enableGoogleAnalytics=True,
                    googleAnalysis="PLACEHOLDER_GOOGLE_ANALYSIS",
                    googleAdsConversionId="PLACEHOLDER_CONVERSION_ID",
                    googleAdsConversionLabel="PLACEHOLDER_CONVERSION_LABEL",
                    debugMode=True,
                    facebookPixelId="PLACEHOLDER_FACEBOOK_PIXEL_ID",
                    trackEvent=TrackEventsDTO(
                        enable=True,
                        events={
                            "add_to_cart": True,
                            "view_item": False,
                            "view_item_list": True,
                            "begin_checkout": False,
                            "purchase": True,
                            "remove_from_cart": False,
                            "view_cart": True,
                            "add_payment_info": True,
                            "add_shipping_info": False,
                            "add_to_wish_list": True
                        }
                    )
                ),
                seoCustomCode=SEOCustomCodeDTO(
                    enable=True,
                    customCodeInHeader="PLACEHOLDER_CUSTOM_HEADER_CODE",
                    customCodeInFooter="PLACEHOLDER_CUSTOM_FOOTER_CODE"
                )
            )
        )

        response = webcommander_sdk.admin_categories.create_categories(request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns the details of the newly created category, including the CATEGORY_ID, CATEGORY_NAME, CATEGORY_URL, visibility status, parent category details, layout configurations, availability information, and timestamps for creation and updates.

CategoriesDetailsResponseDTO(
    category=CategoryDTO(
        id=PLACEHOLDER_CATEGORY_ID,
        name="PLACEHOLDER_CATEGORY_NAME",
        sku="PLACEHOLDER_CATEGORY_SKU",
        title="PLACEHOLDER_TITLE",
        heading="PLACEHOLDER_HEADING",
        url="PLACEHOLDER_CATEGORY_URL",
        available=True,
        visible=True,
        parentCategory=CategoryReferenceDTO(
            id=PLACEHOLDER_PARENT_CATEGORY_ID,
            name="PLACEHOLDER_PARENT_CATEGORY_NAME",
            isInTrash=False,
            isParentInTrash=False,
            isDisposable=False
        ),
        layout=LayoutDTO(id=None, name=None),
        productPage=LayoutDTO(id="PLACEHOLDER_PRODUCT_PAGE_ID", name="PLACEHOLDER_PRODUCT_PAGE_NAME"),
        productLayout=LayoutDTO(id="PLACEHOLDER_PRODUCT_LAYOUT_ID", name="PLACEHOLDER_PRODUCT_LAYOUT_NAME"),
        availableOnDateRange=False,
        availableFromDate="",
        availableToDate="",
        availableFor="PLACEHOLDER_AVAILABLE_FOR",
        selectedCategories=[],
        passwordProtected=False,
        password="",
        imageUrl=None,
        backgroundImageUrl=None,
        summary="PLACEHOLDER_SUMMARY",
        description="PLACEHOLDER_DESCRIPTION",
        products={},
        shippingProfile={},
        taxProfile={},
        disableTracking=False,
        seoConfigs=[],
        transactionNo=None,
        isDisposable=False,
        isInTrash=False,
        isParentInTrash=False,
        createdBy=CreatedByDTO(id="PLACEHOLDER_CREATED_BY_ID", name="PLACEHOLDER_CREATED_BY_NAME"),
        createdOn="PLACEHOLDER_CREATED_ON",
        updatedOn="PLACEHOLDER_UPDATED_ON"
    )
)

Updating Specific Categories

Functions: admin_update_categories() 

Purpose

The admin_update_categories function is used to update an existing category's details in the system. It allows modification of various attributes such as category name, URL, availability, SEO configurations, analytics, and associated products, providing comprehensive control over category management.

Parameters

Parameter
Type
Description
id
String
The unique identifier of the tax profiles.

Use Case

Use this function when you need to make changes to an existing category — for example, updating the category name, adjusting its visibility, setting availability dates, adding or removing products, configuring SEO metadata, or integrating third-party analytics. This is particularly useful for keeping the category structure and data up to date with business needs.

def admin_update_categories_test():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        request_data = CategoryDataDTO(
            name="PLACEHOLDER_CATEGORY_NAME",
            url="PLACEHOLDER_CATEGORY_URL",
            title="PLACEHOLDER_CATEGORY_TITLE",
            heading="PLACEHOLDER_CATEGORY_HEADING",
            available=True,
            categoryAvailable=True,
            parentCategory=ParentCategoryDTO(
                id="PLACEHOLDER_PARENT_CATEGORY_ID",
                name="PLACEHOLDER_PARENT_CATEGORY_NAME"
            ),
            productPage=PageDTO(
                id="PLACEHOLDER_PRODUCT_PAGE_ID"
            ),
            productLayout=PageDTO(
                id="PLACEHOLDER_PRODUCT_LAYOUT_ID"
            ),
            availability=AvailabilityDTO(
                onDateRange=True,
                fromDate="PLACEHOLDER_FROM_DATE",
                toDate="PLACEHOLDER_TO_DATE"
            ),
            availabilityDetails=AvailabilityDetailsDTO(
                availableFor="PLACEHOLDER_AVAILABLE_FOR",
                selectedCustomers=["PLACEHOLDER_CUSTOMER_ID"],
                restrictSelectedCustomers=True
            ),
            protectionDetails=ProtectionDetailsDTO(
                codeProtected=True,
                codeToProtect="PLACEHOLDER_PROTECTION_CODE"
            ),
            images=ImagesDTO(
                url="PLACEHOLDER_IMAGE_URL",
                baseUrl="PLACEHOLDER_IMAGE_BASE_URL",
                thumbUrl="PLACEHOLDER_THUMB_URL",
                backgroundImage=None
            ),
            summary="PLACEHOLDER_SUMMARY",
            description="PLACEHOLDER_DESCRIPTION",
            products=[
                ProductDTO(id="PLACEHOLDER_PRODUCT_ID")
            ],
            productSorting="PLACEHOLDER_PRODUCT_SORTING",
            disableTracking=False,
            loyaltyPoints=0,
            seoConfigurations=SEOConfigurationsDTO(
                url="PLACEHOLDER_SEO_URL",
                overwriteSeoSettings=False,
                seoTitle="PLACEHOLDER_SEO_TITLE",
                seoDescription="PLACEHOLDER_SEO_DESCRIPTION",
                searchEngineIndexing=False,
                canonicalUrl=CanonicalUrlDTO(
                    enable=True,
                    url=["PLACEHOLDER_CANONICAL_URL_1", "PLACEHOLDER_CANONICAL_URL_2"]
                )
            ),
            additionalMetaInfo=AdditionalMetaInfoDTO(
                enable=True,
                metaInfo=[
                    MetaInfoDTO(tagName="meta", tagContent="PLACEHOLDER_META_CONTENT"),
                    MetaInfoDTO(name="meta2", value="PLACEHOLDER_META_CONTENT_2")
                ]
            ),
            analytics=AnalyticsDTO(
                defaultProductListingConfigurations=False,
                thirdPartyAnalytics=ThirdPartyAnalyticsDTO(
                    enable=True,
                    platform="PLACEHOLDER_PLATFORM",
                    enableGoogleAnalytics=True,
                    googleAnalysis="PLACEHOLDER_GOOGLE_ANALYSIS",
                    googleAdsConversionId="PLACEHOLDER_CONVERSION_ID",
                    googleAdsConversionLabel="PLACEHOLDER_CONVERSION_LABEL",
                    debugMode=True,
                    facebookPixelId="PLACEHOLDER_PIXEL_ID",
                    trackEvent=TrackEventsDTO(
                        enable=True,
                        events={
                            "add_to_cart": True,
                            "view_item": False,
                            "view_item_list": True,
                            "begin_checkout": False,
                            "purchase": True,
                            "remove_from_cart": False,
                            "view_cart": True,
                            "add_payment_info": True,
                            "add_shipping_info": False,
                            "add_to_wish_list": True
                        }
                    )
                ),
                seoCustomCode=SEOCustomCodeDTO(
                    enable=True,
                    customCodeInHeader="PLACEHOLDER_HEADER_CODE",
                    customCodeInFooter="PLACEHOLDER_FOOTER_CODE"
                )
            )
        )
        id = "PLACEHOLDER_CATEGORY_ID"
        response = webcommander_sdk.admin_categories.update_categories(id=id, request_data=request_data)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns an updated category response object, which contains the latest details of the modified category, including IDs, names, descriptions, availability status, associated products, SEO configurations, and timestamps for creation and updates.

CategoriesDetailsResponseDTO(
    category=CategoryDTO(
        id=PLACEHOLDER_CATEGORY_ID,
        name="PLACEHOLDER_CATEGORY_NAME",
        sku="PLACEHOLDER_CATEGORY_SKU",
        title="PLACEHOLDER_CATEGORY_TITLE",
        heading="PLACEHOLDER_CATEGORY_HEADING",
        url="PLACEHOLDER_CATEGORY_URL",
        available=True,
        visible=True,
        parentCategory=CategoryReferenceDTO(
            id=PLACEHOLDER_PARENT_CATEGORY_ID,
            name="PLACEHOLDER_PARENT_CATEGORY_NAME",
            isInTrash=False,
            isParentInTrash=False,
            isDisposable=False
        ),
        layout=LayoutDTO(
            id=None,
            name=None
        ),
        productPage=LayoutDTO(
            id=PLACEHOLDER_PRODUCT_PAGE_ID,
            name="PLACEHOLDER_PRODUCT_PAGE_NAME"
        ),
        productLayout=LayoutDTO(
            id=PLACEHOLDER_PRODUCT_LAYOUT_ID,
            name="PLACEHOLDER_PRODUCT_LAYOUT_NAME"
        ),
        availableOnDateRange=False,
        availableFromDate="",
        availableToDate="",
        availableFor="everyone",
        selectedCategories=[],
        passwordProtected=False,
        password="",
        imageUrl=None,
        backgroundImageUrl=None,
        summary="PLACEHOLDER_SUMMARY",
        description="PLACEHOLDER_DESCRIPTION",
        products={},
        shippingProfile={},
        taxProfile={},
        disableTracking=False,
        seoConfigs=[],
        transactionNo=None,
        isDisposable=False,
        isInTrash=False,
        isParentInTrash=False,
        createdBy=CreatedByDTO(
            id=PLACEHOLDER_USER_ID,
            name="PLACEHOLDER_USER_NAME"
        ),
        createdOn="PLACEHOLDER_CREATED_ON",
        updatedOn="PLACEHOLDER_UPDATED_ON"
    )
)

Deleting a Categories

Function: admin_delete_categories()

Purpose

The admin_delete_categories function is used to delete an existing category by its unique identifier. This function helps in maintaining the relevance and accuracy of category listings by allowing the removal of outdated or incorrect categories.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the blog post to be deleted.

Use Case

Use this function when you need to permanently remove a category from the system. This is particularly useful when categories are deprecated, merged, or created in error, ensuring that only valid and current categories remain in your catalog.

def admin_delete_categories_test():
    SDKConfig.PRINT_REQUEST_DATA = False
    SDKConfig.PRINT_RAW_RESPONSE = False

    webcommander_sdk: WebCommanderSDK = WebCommanderSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())

    try:
        id = "PLACEHOLDER_CATEGORY_ID"
        response = webcommander_sdk.admin_categories.delete_categories(id=id)
        print(response)
    except WCException as ab:
        print(ab)
        print(ab.get_errors())
        print(ab.raw_response)

Response

The function returns a success message indicating that the category has been successfully deleted.