Skip to main content

StyleMan - Item sync

StyleMan Connector - Item Update Overview This function synchronizes item data from the StyleMan REST API to App4Sales. It retrieves item...

Updated over a week ago

StyleMan Connector - Item Update

Overview

This function synchronizes item data from the StyleMan REST API to App4Sales. It retrieves items in batches, processes their details including pricing, images, stock, and various classifications (item groups), and then updates the App4Sales database. The StyleMan connector specifically disables batch updating for items, meaning it processes all available items in a single, large retrieval operation.

Data Source Configuration

Item data is pulled from the configured StyleMan REST API endpoint for items. The connector makes an HTTP GET request to {BaseUrl}/api/{Version}/Items?$orderby=ItemCode&$skip={offset}, where {BaseUrl} and {Version} are determined by the connector's configuration, and {offset} is used for pagination (though effectively disabled for StyleMan due to DisableBatchUpdate being true). Items are ordered by ItemCode.

Data Mapping Table (Items)

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

ItemCode

ItemCode

Directly mapped from the StyleMan API. Whitespace is trimmed.

EanCode

EanCode

Directly mapped.

FreeSortField

FreeSortField

Directly mapped.

LastAvailableStock

LastAvailableStock

Directly mapped. See "Stock & Availability" for detailed logic.

NextDelivery

NextDelivery

Directly mapped.

PurchasePackageSize

PurchasePackageSize

Directly mapped.

SalesPrice

SalesPriceExcl

Mapped from the exclusive sales price.

Unit

Unit

Directly mapped.

CreatedDate

Created

Mapped from the item creation timestamp. Defaults to current date/time if not provided.

Sysmodified

Modified

Mapped from the item modification timestamp. Defaults to current date/time if not provided.

VatIncluded

Hardcoded

Always set to 'E' (Exclusive).

VatPercentage

VatPercentage

Directly mapped.

AcceptsDefaultDiscount

AcceptsDefaultDiscount

Directly mapped. Defaults to true if not provided by the source.

MatrixParent

MatrixCode

Mapped from the matrix code.

MatrixParentDescription

MatrixDescription

Mapped from the matrix description.

MatrixParentId

MatrixId

Mapped from the matrix ID.

MatrixXValue

MatrixXValue

Mapped from the matrix X-axis value.

MatrixXDescription

MatrixXDescription

Mapped from the matrix X-axis description.

MatrixYValue

MatrixYValue

Mapped from the matrix Y-axis value.

MatrixYDescription

MatrixYDescription

Mapped from the matrix Y-axis description.

Description
​Description2
...
​Description5

Descriptions

Multi-language descriptions are mapped from the Descriptions list based on the LanguageCode and configured DescriptionField for each language.

FreeItemFields

FreeFields

Free fields are converted from a list of key-value pairs (RestJsonFreeField) into an XML string.

ItemClasses

ItemGroups

Mapped based on the UseMultipleItemGroupLevels setting. See "Matrix & Attributes" for detailed logic.

PicturesBytes

PictureUrls / PictureUrl

Image data (Base64) is downloaded from provided URLs. See "Image Handling" for detailed logic.

Data Mapping Table (Item Prices)

This table describes how individual item prices (per price list) are processed and mapped.

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

ItemCode

ItemCode (from RestJsonItemPrice, or derived from parent RestJsonItem if empty)

Unique identifier for the item.

Id (Price List ID)

Code (from matched RestJsonPriceList)

Internal App4Sales Price List ID.

Code (Price List Code)

Code (from matched RestJsonPriceList)

Textual code for the price list.

Description (Price List Description)

Description (from matched RestJsonPriceList)

Description for the price list.

Price

PriceExcl (from RestJsonItemPrice)

The price of the item, exclusive of VAT.

Special Logic & Filters

Price Logic

  • The connector fetches a list of available price lists.

  • It iterates through item sales prices (SalesPrices from the API). For each price, it attempts to match it to an existing price list using either the internal GUID (PriceList) or an external ID (PriceListExternalId).

  • If no matching price list is found in the ERP data, and a default Price List 1 is not provided by the ERP, the system will create a default Price List 1.

  • If the ERP *does* provide Price List 1, and an item price doesn't match any price list, that specific item price will be skipped to avoid overwriting ERP-provided Price List 1 data.

  • The ItemCode on individual sales price entries is populated from the main item's ItemCode if it's missing.

Image Handling

  • Images are processed only if the global PIM setting UseImagesOnlyFromPIM is disabled.

  • The connector first attempts to retrieve images from a list of picture URLs (PictureUrls). If this list is empty, it falls back to an obsolete single picture URL (PictureUrl).

  • Image data is downloaded either as raw content (if UseRelativePictureUrl is enabled) or from a full URL.

  • A cache is used to prevent re-downloading the same image multiple times.

  • If an image download or processing fails, the URL is added to an invalidUrls set to prevent future attempts for that specific URL within the same sync.

  • Downloaded images are stored as Base64 encoded byte arrays within App4Sales.

Stock & Availability

  • The item's StockIndicator is mapped directly if provided by the API. Otherwise, it defaults to the existing stock indicator in App4Sales or -1.

  • If the connector's Warehouse setting is not specified, and the item from the API provides StockValues, these values are used to populate the fullStockValues dictionary, which is used for a global stock update.

  • If a specific item's stock values are present in fullStockValues but lack an explicit AvailableStock entry, the LastAvailableStock for that item is calculated using a predefined stock formula based on other stock values (e.g., ShelfStock, ToBeReceived, and ToBeDelivered).

Matrix & Attributes (Item Groups and Classification)

  • The way item groups are processed depends on the UseMultipleItemGroupLevels setting.

  • If UseMultipleItemGroupLevels is ON:

    • ItemGroups (which can have nested Children) are recursively converted into App4Sales ItemClass and ItemClassValueDescription entities.

    • If the App4Sales system has been "upgraded", these item groups are mapped to CMS Lookbooks (CmsLookbook, CmsLookbookItem, etc.), with images from the item groups' PictureUrl being stored as media files.

    • Otherwise (if not upgraded), they are mapped to legacy Editions (Edition) and Mood Pictures (MoodPicture), also handling associated images and translations.

    • Multi-language descriptions (Dutch, German, French) for item class values are extracted from the item group texts.

  • If UseMultipleItemGroupLevels is OFF:

    • ItemGroups that have a Value are converted into simple ItemClass and ItemClassValue pairs. The Name of the item group becomes the ItemClass description, and its Value becomes the ItemClassValue.

  • Translations for Item Group Names and Values are retrieved and updated separately.

Domain Specifics (Expanded)

Price Logic

The connector synchronizes item prices associated with price lists. Each item can have multiple prices, one for each price list. The system prioritizes exact matches for price list IDs or external IDs from the ERP. If a price is provided without a matching price list, it may be skipped or assigned to a default price list (Price List 1) based on existing configuration.

Image Handling

Images are linked to items by downloading them from specified URLs and storing them in App4Sales. The system supports both absolute and relative image URLs. Images are typically stored as Base64 encoded strings. A local cache is maintained to optimize performance and avoid redundant downloads. Images are not processed if the system is configured to use images only from the Product Information Management (PIM) system.

Stock & Availability

Stock information, including a stock indicator and detailed stock values, is synchronized. The connector can process stock values from multiple warehouses if configured. The LastAvailableStock is either provided directly by the ERP or calculated using a formula based on components like ShelfStock, ToBeReceived, and ToBeDelivered.

Matrix & Attributes

The connector supports flexible item classification through item groups. Depending on the UseMultipleItemGroupLevels setting, these groups can represent simple attributes or complex, hierarchical structures that translate into App4Sales Item Classes. For systems that have been upgraded, these hierarchical item groups also form the basis for CMS Lookbooks. For older implementations, they contribute to Editions and Mood Pictures. Multi-language descriptions for these classifications are also supported.

Related Settings & Prerequisites

  • DisableBatchUpdate (StyleMan specific): Set to true. This means all items are fetched and processed in one go, rather than in paginated batches.

  • FilterNonIso88591Characters (StyleMan specific): Set to true. This setting ensures that non-ISO-8859-1 characters are filtered out from strings where necessary.

  • Warehouse: (Optional) Specifies a particular warehouse code to filter stock information. If empty, the connector may aggregate stock values differently or from all warehouses.

  • UseRelativePictureUrl: (Boolean) If true, the connector expects relative image URLs and will attempt to download them as raw content. If false, it expects full URLs.

  • UseMultipleItemGroupLevels: (Boolean) Determines how item groups are processed. If true, hierarchical item groups are supported, leading to more complex mapping to ItemClasses and potentially Lookbooks/Editions. If false, only single-level item groups with values are processed.

  • DisallowDuplicateData: (Boolean) If true, the system checks for duplicate item codes across batches (though with DisableBatchUpdate being true for StyleMan, this primarily applies to duplicates within the single response from the API). An exception is thrown if duplicates are found.

  • SupportsStockBatchCall: (Boolean) Influences whether stock can be retrieved for multiple items in a single API call.

  • PIM Setting (AdministrationSession.CurrentSession.PimSettings.UseImagesOnlyFromPIM): If this global App4Sales setting is true, the connector will skip all image handling, assuming images are managed solely by the PIM system.

Known Limitations

  • The StyleMan connector's DisableBatchUpdate is hardcoded to true, meaning large item sets might lead to long processing times or memory issues as all items are retrieved in a single API call.

  • The PictureUrl property on RestJsonItem is marked as obsolete; it's recommended to use the PictureUrls list for multiple images.

Did this answer your question?