Read-only Attributes

Showcase

Datastandard definition

Code Example:

{
            "id": "DISABLED_IN_STATES",
            "name": "DISABLED_IN_STATES",
            "description": "Disabled in state 'Disabled'",
            "type": {
                "id": "string"
            },
            "groupIds": [
                "READONLY"
            ],
            "disableSubmitInStates": [ 
                "Disabled"
            ]
        },
        {
            "id": "DISABLED_ALWAYS",
            "name": "DISABLED_ALWAYS",
            "description": "Disabled always (*)",
            "type": {
                "id": "string"
            },
            "groupIds": [
                "READONLY"
            ],
            "disableSubmitInStates": [ 
                "*"
            ]
        },
        {
            "id": "READONLY_ALWAYS",
            "name": "READONLY_ALWAYS",
            "description": "Readonly attribute",
            "type": {
                "id": "string"
            },
            "groupIds": [
                "READONLY"
            ],
            "readOnlyCondition": "true"
        },
        {
            "id": "READONLY_CONDITIONAL_CONDITION",
            "name": "READONLY_CONDITIONAL_CONDITION",
            "description": "Conditionally readonly attribute - condition",
            "type": {
                "id": "string",
                "restriction": {
                    "listOfValues": [
                        "YES",
                        "NO"
                    ]
                }
            },
            "groupIds": [
                "READONLY"
            ]
        },
        {
            "id": "READONLY_CONDITIONAL",
            "name": "READONLY_CONDITIONAL",
            "description": "Conditionally readonly attribute",
            "type": {
                "id": "string"
            },
            "groupIds": [
                "READONLY"
            ],
            "readOnlyCondition": "READONLY_CONDITIONAL_CONDITION == \"YES\""
        },

Attributes with disableSubmitInStates

Attribute type idType specific restriction parameters
DISABLED_IN_STATESSetting disableSubmitInStates attribute in attribute definition allows to disable (i.e. make it read-only) attribute based on its' channelProcessingStages. It’s mainly used to lock some attributes when product is being processed in the adapter (i.e. channelProcessingStages: processing) or if some business logic on the channel side decides that vendor should not be able to alter attribute value (i.e. channelProcessingStages: paused).
DISABLED_ALWAYSSpecial case is when we want to disable attribute entirely (i.e. if it comes from retrieval), then " * " can be used to disable product in all possible states.

Consider using readOnlyCondition or externalChannelStatus as they may be a better fit.

Attributes with readOnlyCondition

Attribute type idType specific restriction parameters
READONLY_ALWAYSSimilarly to DISABLED_ALWAYS this mechanism can be used to disable attribute entirely by setting expression that is always true - i.e. "readOnlyCondition": "true".
READONLY_CONDITIONALWith readOnlyCondition attribute specified we can make attribute read-only based on other attributes of the product. This is useful if attribute should be read-only in some special cases - i.e. if client is not family owner.

Condition can use product attributes

📘

Please note that setting attributes as disabled/read-only does not prevent us from creating mapping for those attributes - making it possible to effectively change the values.