Represents a stock keeping unit: one product, or one specific combination of a product's option values, that can be ordered and stocked. Every SKU belongs to a Product and carries the SKU code, a display title, the base cost and the physical dimensions of the item. The option values that make up the SKU are held in separate ProductSkuOptions rows rather than on the SKU itself, so getOptions and getParams run a query each time they are called instead of reading a mapped field. A distributor's own code for a product is modelled as a second SKU row with distOrg set and aliasFor pointing back at the brand's SKU, which is why the SKU code is only unique within an organisation and distributor. A SKU that is already referenced by an order or a line item cannot be removed, so it is soft deleted instead: the deleted date is set and _deleted_ plus a timestamp is appended to the name so the original code can be reused.

Group: Database Entities

Implements: Relational, Serializable


Properties

PropertyReturnsDescription
aliasesList<ProductSku>The distributor SKUs that point at this SKU through their aliasFor field. Not a mapped column: it runs a query on every call.
aliasForProductSkuThe brand's SKU that this row is an alias of. Used together with the distributor organisation so a distributor's own code can map onto the brand's stock item. Null for an ordinary SKU.
baseCostBigDecimalThe base cost of a single unit of this SKU. Optional, so it can be null; use baseCostDbl to read the same value as a plain number from script.
createdDateDateWhen this SKU was first created.
deletedByProfileThe profile that soft deleted this SKU.
deletedDateDateWhen this SKU was soft deleted. Soft deletion is used instead of a real delete whenever an order or a line item still refers to the SKU.
distOrgOrganisationThe distributor organisation that this SKU code belongs to. Null for the brand's own SKU; when it is set the row is normally an alias for the brand's SKU. It forms part of the uniqueness constraint, so the same code can exist once per distributor.
field1StringFree-text custom field with no fixed meaning, available for account specific data such as a supplier's own code. Optional and not unique.
field2StringFree-text custom field with no fixed meaning, available for account specific data such as a supplier's own code. Optional and not unique.
field3StringFree-text custom field with no fixed meaning, available for account specific data such as a supplier's own code. Optional and not unique.
heightCmBigDecimalHeight of a single unit in centimetres, recorded for packing and freight. Optional.
idlongDatabase identifier of this SKU, assigned when the row is first saved.
imageHashStringContent hash of the image uploaded for this specific SKU, which is how a variant can show a different picture from its product. Optional.
lengthCmBigDecimalLength of a single unit in centimetres, recorded for packing and freight. Optional.
modifiedDateDateWhen this SKU was last changed. It is set by the code that creates or updates the SKU rather than automatically, so it can be null on older rows.
nameStringThe SKU code: a portable identifier for this stock item, unique within the owning organisation and distributor. A soft deleted SKU has _deleted_ and a timestamp appended to its code, so a deleted SKU's code no longer matches what was ordered.
optionsList<ParameterOption>The parameter options that define this SKU, such as large and black. Not a mapped column: the options are read from the ProductSkuOptions join rows using the current session every time this is called, so treat it as a query rather than a cheap read.
paramsMap<ProductParameter,List<ParameterOption>>The options selected on this SKU grouped by the product parameter they belong to, as a map of ProductParameter to a list of ParameterOption. Not a mapped column: it is built from the SKU's option rows on every call, so it costs a query.
productProductThe product this SKU is a variant of, for example the duvet that this particular size and colour belongs to. Required.
titleStringFree-text display name for this SKU, such as King size black duvet. When the SKU is created automatically this defaults to the product title followed by the title of each selected option. Unlike the SKU code it carries no uniqueness guarantee.
weightKgsBigDecimalWeight of a single unit in kilogrammes, recorded for freight. Optional.
widthCmBigDecimalWidth of a single unit in centimetres, recorded for packing and freight. Optional.

Methods

getId() · getName() · getTitle() · getCreatedDate() · getModifiedDate() · getAliasFor() · getDistOrg() · getProduct() · getDeletedBy() · getDeletedDate() · getImageHash() · getBaseCost() · getHeightCm() · getLengthCm() · getWeightKgs() · getWidthCm() · getField1() · getField2() · getField3() · matches(Collection<ParameterOption> opts) · optionValue(String ppName) · optionValue(ProductParameter pp) · getParams() · getOptions() · deleted() · baseCostDbl() · getAliases()

getId()

Returns: long

Database identifier of this SKU, assigned when the row is first saved.

getName()

Returns: String

The SKU code: a portable identifier for this stock item, unique within the owning organisation and distributor. A soft deleted SKU has _deleted_ and a timestamp appended to its code, so a deleted SKU's code no longer matches what was ordered.

getTitle()

Returns: String

Free-text display name for this SKU, such as King size black duvet. When the SKU is created automatically this defaults to the product title followed by the title of each selected option. Unlike the SKU code it carries no uniqueness guarantee.

getCreatedDate()

Returns: Date

When this SKU was first created.

getModifiedDate()

Returns: Date

When this SKU was last changed. It is set by the code that creates or updates the SKU rather than automatically, so it can be null on older rows.

getAliasFor()

Returns: ProductSku

The brand's SKU that this row is an alias of. Used together with the distributor organisation so a distributor's own code can map onto the brand's stock item. Null for an ordinary SKU.

getDistOrg()

Returns: Organisation

The distributor organisation that this SKU code belongs to. Null for the brand's own SKU; when it is set the row is normally an alias for the brand's SKU. It forms part of the uniqueness constraint, so the same code can exist once per distributor.

getProduct()

Returns: Product

The product this SKU is a variant of, for example the duvet that this particular size and colour belongs to. Required.

getDeletedBy()

Returns: Profile

The profile that soft deleted this SKU.

getDeletedDate()

Returns: Date

When this SKU was soft deleted. Soft deletion is used instead of a real delete whenever an order or a line item still refers to the SKU.

getImageHash()

Returns: String

Content hash of the image uploaded for this specific SKU, which is how a variant can show a different picture from its product. Optional.

getBaseCost()

Returns: BigDecimal

The base cost of a single unit of this SKU. Optional, so it can be null; use baseCostDbl to read the same value as a plain number from script.

getHeightCm()

Returns: BigDecimal

Height of a single unit in centimetres, recorded for packing and freight. Optional.

getLengthCm()

Returns: BigDecimal

Length of a single unit in centimetres, recorded for packing and freight. Optional.

getWeightKgs()

Returns: BigDecimal

Weight of a single unit in kilogrammes, recorded for freight. Optional.

getWidthCm()

Returns: BigDecimal

Width of a single unit in centimetres, recorded for packing and freight. Optional.

getField1()

Returns: String

Free-text custom field with no fixed meaning, available for account specific data such as a supplier's own code. Optional and not unique.

getField2()

Returns: String

Free-text custom field with no fixed meaning, available for account specific data such as a supplier's own code. Optional and not unique.

getField3()

Returns: String

Free-text custom field with no fixed meaning, available for account specific data such as a supplier's own code. Optional and not unique.

matches(Collection<ParameterOption> opts)

Returns: boolean

Tests whether the options selected on this SKU are exactly the given set, comparing option ids and ignoring order. A null or empty argument matches only a SKU that has no options. This is how the SKU for a shopper's chosen combination is identified, and it reads the SKU's options from the database.

ParameterDescription
optsthe options to compare against, may be null or empty

optionValue(String ppName)

Returns: String

The name of the option this SKU has selected for the named product parameter, for example large for the parameter size. Reads the SKU's options from the database on each call.

ParameterDescription
ppNamethe name of the product parameter to look up

optionValue(ProductParameter pp)

Returns: String

The name of the option this SKU has selected for the given product parameter, matched by parameter id. Reads the SKU's options from the database on each call.

ParameterDescription
ppthe product parameter to look up

getParams()

Returns: Map<ProductParameter,List<ParameterOption>>

The options selected on this SKU grouped by the product parameter they belong to, as a map of ProductParameter to a list of ParameterOption. Not a mapped column: it is built from the SKU's option rows on every call, so it costs a query.

getOptions()

Returns: List<ParameterOption>

The parameter options that define this SKU, such as large and black. Not a mapped column: the options are read from the ProductSkuOptions join rows using the current session every time this is called, so treat it as a query rather than a cheap read.

deleted()

Returns: boolean

Whether this SKU has been soft deleted, that is whether its deleted date is set. Soft deleted SKUs remain in the database because orders and line items may still refer to them, so listing code normally has to filter them out.

baseCostDbl()

Returns: Double

The base cost as a plain number, for callers that cannot work with a BigDecimal.

getAliases()

Returns: List<ProductSku>

The distributor SKUs that point at this SKU through their aliasFor field. Not a mapped column: it runs a query on every call.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.