Skip to content

[5.x]: The SKU is not editable if an automatic format is used #4249

@MoritzLost

Description

@MoritzLost

What happened?

Description

The SKU field for variants seems to have two modes:

  • If the Automatic SKU Format for the product type is empty, the SKU field shows up in the field layout for product variants and is required, but empty by default.
  • If an Automatic SKU Format is defined, the SKU is filled automatically and the SKU field is hidden, making manual changes impossible.

The second behavior is troublesome for multiple reasons:

  • It's impossible to have an automatic/default format, but still have the ability to manually override the SKU for individual product variant.
  • If the automatic format results in a duplicate SKU, editors can't save the variant at all, with no way to fix this. For example, if the SKU format is just {product.slug}, you will never be able to create a second variant for any product. Granted, that format is not a good idea. But there are non-trivial cases where you may still end up with duplicates. In those cases, being able to manually edit the SKU would be helpful.
  • The instructions for the Automatic SKU Format contradict the actual behavior:

What the unique auto-generated SKUs should look like, when a SKU field is submitted without a value.

This implies that this is a fallback in case an author doesn't enter a format manually. But in fact, entering an automatic format prevents authors from doing that in the first place.

Expected behavior

  • It should be possible to control the visibility of the SKU field independently of whether an automatic/default SKU format is defined.
  • In case of duplicate SKUs, authors should be able to recover from that error by manually editing the SKU, even if an automatic format is defined.

Actual behavior

The automatic SKU format implicitly also controls whether the input field will be displayed, resulting in problematic AX and irrecoverable errors.

Craft CMS version

5.9.15

Craft Commerce version

5.5.4

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions