ModelProducts module

Product

A model in the Products module, with 75 members for templates, 56 API properties and 84 members for admin templates.

View
What Smarty and Twig templates receive. Properties in REST API responses and job payloads. What admin screen templates receive when you override them.

Templates view

Properties 61

Take no arguments.

# getPricings()
Collection<ProductPricing>
Returns the general pricings only: one per currency, the way the storefront has always seen them.
The storefront never lists what other people or groups pay. The visitor's own personal pricings are available through getPersonalPricings().
# getPersonalPricings()
Collection
Returns the personal pricings of the current customer only: their own pricings and the pricings of their groups; for a guest the collection is empty
# __toString() Templates only
string
Returns the rendered HTML when the model is used in a string context.
# getPrimaryCategory()
?Category
# getShippingCategory()
?Category
# getCategoryElements()
?Collection<CategoryElement>
# getVariants()
?Collection<ProductVariant>
# isVariant()
bool
Returns false: a product is not a variant
# hasVariants()
bool
Returns whether the product has variants, counted without loading them
# getChildren()
?Collection
Returns the variants as the children of the product: the children side of the hierarchical-model protocol of the kernel
# getParent()
?Product
Returns the parent of the product, which is always null: a product is the root of its variants and never has a parent itself
# getTaxCategory()
?Category
# getCustomFieldValues()
?Collection<ProductCustomFieldValue>
# getCustomFields()
array
Get the custom fields for this entity
# getText()
?string
Get the short description in the default language for this product
# hasDefaultPricing()
bool
Checks if the product has a default pricing.
# getDefaultPricing()
ProductPricing
Gets the default pricing.
# getGeneralPricings()
Collection
Returns the general pricings of the product: one per currency, the prices everybody pays unless a personal pricing applies
# getName()
?string
Fetches the name in the default description for this container
# getSlug()
?string
Fetches the slug for the default description for this container
# getFullSlug()
string
Gets the effective full slug for the container by forwarding to its default description. All four UrlAddressable methods forward instead of using the urlAddressableModel defaults, because a container's URL is entirely its default description's URL: the custom URL lives on the description entity, not on the container entity, so the trait's resolveCustomUrl() would check the container's own entity — which has no getCustomUrl() — and silently drop the description's custom URL. The description itself uses urlAddressableModel, so the guarded custom-URL resolution still happens exactly once, one level down. That is why this trait does not use urlAddressableModel: every method it would contribute is replaced here.
# getFullPath()
string
Gets the effective full path for the container by forwarding to its default description
# getOriginalFullSlug()
string
Gets the original full slug for the container by forwarding to its default description
# getOriginalFullPath()
string
Gets the original path for the container without any custom urls applied by forwarding to its default description
# hasDefaultDescription()
bool
Checks if the container has a default description.
# getDefaultDescription()
Model
Fetches the description in the default language for this container.
# getOriginalPath()
string
It's an alias and deprecated! Directly use getOriginalFullPath() instead.
# hasChildren()
bool
Alias for hasVariants(): the variants are the children in the hierarchical-model protocol of the kernel, so a product answers for its variants and a variant answers false
# getId()
?int
# getCode()
?string
The code that uniquely identifies this product
# isPurchasable()
bool
# getAvailableFrom()
?DateTime
# getAvailableTill()
?DateTime
# getCreated()
?DateTime
Date the record was created.
# getModified()
?DateTime
Last modification date for the record.
# getPublished()
?DateTime
# isPublished()
bool
Determines if the record is published.
# getImage()
?Image
# getSite()
?Site
# getDescriptions()
?Collection<ProductDescription>
# getWidth()
?string
# getHeight()
?string
# getDepth()
?string
# getWeight()
?string
# getAvailableQuantity()
?int
# getInventoryTemplate()
?string
# getMinQuantity()
?int
Returns the smallest quantity a customer has to have in the cart; null when there is no minimum
# getMaxQuantity()
?int
Returns the largest quantity a customer can have in the cart; null when there is no maximum
# getQuantityStep()
?int
Returns the step the quantity is counted in from the minimum quantity (from 1 when there is no minimum): minimum 2 and step 3 allow 2, 5, 8, and so on; null when there is no step
# getQuantityMultiple()
?int
Returns the number the quantity has to be a multiple of: 5 allows 5, 10, 15, and so on; null when there is no multiple
# getOverallQuantity()
?int
Returns the total quantity a customer can buy within the overall period, counting the orders already placed; null when there is no overall limit
# getOverallPeriod()
int
Returns the period of the overall quantity in seconds; 0 means ever
# getPurchaseControls()
array
Returns the purchase controls as a whole: the stored JSON object with a key per rule
# getStocks()
?Collection<Stock>
# getInterests()
?Collection<ProductInterest>
# getExternalId()
?string
# isNewRecord() Not in API & Jobs
bool
Check if the record is a new record
# isHierarchicalModel() Not in API & Jobs
bool
Check whether a model is a hierarchical model, i.e. can have children
# isVersionedModel() Not in API & Jobs
bool
Check whether a model is versioned
# isInWishlist() Templates only
bool
Checks if the user is logged-in or if the product is available in the user's wishlist
# getHtml() Templates only
string
Gets the rendered HTML for the record using its layout template. Delegates to the default description, which holds the layout.

Methods 14

Take arguments. The API serialises only getters that need none.

# getProductCategories(?array $criteria, string $sort, string $direction)
Collection
Helper that will fetch instances of Products\Models\Category through Products\Models\CategoryElement
# getCustomFieldValue(CustomField $customField)
?CustomFieldValue
Get the value for a custom field
# getCustomFieldValueByName(string $customFieldName)
?CustomFieldValue
Get the value for a custom field by the custom field name
# getCustomFieldContent(string $customFieldName)
?Content
Get the content for the custom field identified by the specified name
# getCustomFieldContentOrDefault(string $customFieldName)
?Content
Get the (default) content for the custom field identified by the specified name
# getCustomFieldBoolean(string $customFieldName, ?bool $default)
?bool
Get the (default) content of the custom field as boolean value
# getCustomFieldText(string $customFieldName, ?string $default)
?string
Get the (default) content of the custom field as text
# getCustomFieldImage(string $customFieldName)
?Image
Get the (default) image contained in the custom field
# getCustomFieldFile(string $customFieldName)
?File
Get the (default) file contained in the custom field
# hasCustomField(string $customFieldName)
bool
Check if the entity has a custom field with the specified name
# getPricingForCurrency(Currency $currency)
?ProductPricing
Returns the general pricing for a specific currency, i.e., the price everybody pays unless a personal pricing applies. Returns nothing if there is no pricing set for the given currency.
# getPersonalPricingsForPerson(?Person $person)
Collection
Returns the personal pricings that apply to a person: their own pricings and the pricings of the groups they belong to, in every currency. Without a person the collection is empty.
# getFinalPrice(?Currency $currency, ?Person $person)
?string
Calculates the final price of the product for the customer in the given currency. When a personal pricing applies to the customer, its price is the final price, even when it is higher than the general one: a personal pricing replaces the general pricing rather than discounts it. A person's own pricing wins over the pricings of their groups; among group pricings the sticky ones are considered first, and the lowest wins. The price of a pricing is the lower of its *base price* and its *special price*. If *base price* of the product is 0.00, such a product could be added to the cart. If other prices (e.g. *special price*) are 0, they are ignored, and *base price* is returned (that could be 0.00).
# getDescriptionForLanguage(Language $language)
?Model
Retrieves the description for the specified language. Returns null when there is no description in that language.

API & Jobs view

API & JobsEach property is a key in REST API responses and job payloads. Its name is the template getter without get, is or has. Methods that need arguments are not available here.

Properties 56

Read-only values on the record.

# primaryCategory
?Category
# shippingCategory
?Category
# categoryElements
?Collection<CategoryElement>
# variant
bool
Returns false: a product is not a variant
# variants
bool
Returns whether the product has variants, counted without loading them
# children
?Collection
Returns the variants as the children of the product: the children side of the hierarchical-model protocol of the kernel
# parent
?Product
Returns the parent of the product, which is always null: a product is the root of its variants and never has a parent itself
# taxCategory
?Category
# customFieldValues
?Collection<ProductCustomFieldValue>
# customFieldContent
object
Get a serialized representation of the custom fields associated with the record
# customFields
array
Get the custom fields for this entity
# text
?string
Get the short description in the default language for this product
# defaultPricing
bool
Checks if the product has a default pricing.
# defaultPricing
ProductPricing
Gets the default pricing.
# generalPricings
Collection
Returns the general pricings of the product: one per currency, the prices everybody pays unless a personal pricing applies
# personalPricings
Collection
Returns the personal pricings of the product: the prices for specific people and for groups of people, in every currency
# name
?string
Fetches the name in the default description for this container
# slug
?string
Fetches the slug for the default description for this container
# fullSlug
string
Gets the effective full slug for the container by forwarding to its default description. All four UrlAddressable methods forward instead of using the urlAddressableModel defaults, because a container's URL is entirely its default description's URL: the custom URL lives on the description entity, not on the container entity, so the trait's resolveCustomUrl() would check the container's own entity — which has no getCustomUrl() — and silently drop the description's custom URL. The description itself uses urlAddressableModel, so the guarded custom-URL resolution still happens exactly once, one level down. That is why this trait does not use urlAddressableModel: every method it would contribute is replaced here.
# fullPath
string
Gets the effective full path for the container by forwarding to its default description
# originalFullSlug
string
Gets the original full slug for the container by forwarding to its default description
# originalFullPath
string
Gets the original path for the container without any custom urls applied by forwarding to its default description
# defaultDescription
bool
Checks if the container has a default description.
# defaultDescription
Model
Fetches the description in the default language for this container.
# originalPath
string
It's an alias and deprecated! Directly use getOriginalFullPath() instead.
# children
bool
Alias for hasVariants(): the variants are the children in the hierarchical-model protocol of the kernel, so a product answers for its variants and a variant answers false
# id
?int
# code
?string
The code that uniquely identifies this product
# purchasable
bool
# availableFrom
?DateTime
# availableTill
?DateTime
# created
?DateTime
Date the record was created.
# modified
?DateTime
Last modification date for the record.
# published
?DateTime
# published
bool
Determines if the record is published.
# image
?Image
# site
?Site
# width
?string
# height
?string
# depth
?string
# weight
?string
# availableQuantity
?int
# inventoryTemplate
?string
# minQuantity
?int
Returns the smallest quantity a customer has to have in the cart; null when there is no minimum
# maxQuantity
?int
Returns the largest quantity a customer can have in the cart; null when there is no maximum
# quantityStep
?int
Returns the step the quantity is counted in from the minimum quantity (from 1 when there is no minimum): minimum 2 and step 3 allow 2, 5, 8, and so on; null when there is no step
# quantityMultiple
?int
Returns the number the quantity has to be a multiple of: 5 allows 5, 10, 15, and so on; null when there is no multiple
# overallQuantity
?int
Returns the total quantity a customer can buy within the overall period, counting the orders already placed; null when there is no overall limit
# overallPeriod
int
Returns the period of the overall quantity in seconds; 0 means ever
# purchaseControls
array
Returns the purchase controls as a whole: the stored JSON object with a key per rule
# stocks
?Collection<Stock>
# externalId
?string

Admin view

AdminAvailable in cdna-admin templates. Copy an admin template into your site repository to change how this record is edited.

Properties 70

Take no arguments.

# getPrimaryCategory()
?Category
# getShippingCategory()
?Category
# getCategoryElements()
?Collection<CategoryElement>
# getVariants()
?Collection<ProductVariant>
# isVariant()
bool
Returns false: a product is not a variant
# hasVariants()
bool
Returns whether the product has variants, counted without loading them
# getChildren()
?Collection
Returns the variants as the children of the product: the children side of the hierarchical-model protocol of the kernel
# getParent()
?Product
Returns the parent of the product, which is always null: a product is the root of its variants and never has a parent itself
# getTaxCategory()
?Category
# getCustomFieldValues()
?Collection<ProductCustomFieldValue>
# getCustomFields()
array
Get the custom fields for this entity
# getText()
?string
Get the short description in the default language for this product
# hasDefaultPricing()
bool
Checks if the product has a default pricing.
# getDefaultPricing()
ProductPricing
Gets the default pricing.
# getGeneralPricings()
Collection
Returns the general pricings of the product: one per currency, the prices everybody pays unless a personal pricing applies
# getPersonalPricings()
Collection
Returns the personal pricings of the product: the prices for specific people and for groups of people, in every currency
# getName()
?string
Fetches the name in the default description for this container
# getSlug()
?string
Fetches the slug for the default description for this container
# getFullSlug()
string
Gets the effective full slug for the container by forwarding to its default description. All four UrlAddressable methods forward instead of using the urlAddressableModel defaults, because a container's URL is entirely its default description's URL: the custom URL lives on the description entity, not on the container entity, so the trait's resolveCustomUrl() would check the container's own entity — which has no getCustomUrl() — and silently drop the description's custom URL. The description itself uses urlAddressableModel, so the guarded custom-URL resolution still happens exactly once, one level down. That is why this trait does not use urlAddressableModel: every method it would contribute is replaced here.
# getFullPath()
string
Gets the effective full path for the container by forwarding to its default description
# getOriginalFullSlug()
string
Gets the original full slug for the container by forwarding to its default description
# getOriginalFullPath()
string
Gets the original path for the container without any custom urls applied by forwarding to its default description
# hasDefaultDescription()
bool
Checks if the container has a default description.
# getDefaultDescription()
Model
Fetches the description in the default language for this container.
# getOriginalPath()
string
It's an alias and deprecated! Directly use getOriginalFullPath() instead.
# getImageRootTargetFolderPath() Admin only
string
Retrieves the *root* target folder path for uploaded images. This is usually the root entity path without the ID or slug sub folder.
# getImageTargetFolderPath() Admin only
string
Retrieves the target folder path for uploaded images. Images will be moved to this path after the upload has been processed.
# hasChildren()
bool
Alias for hasVariants(): the variants are the children in the hierarchical-model protocol of the kernel, so a product answers for its variants and a variant answers false
# getId()
?int
# getCode()
?string
The code that uniquely identifies this product
# isPurchasable()
bool
# getAvailableFrom()
?DateTime
# getAvailableTill()
?DateTime
# getCreated()
?DateTime
Date the record was created.
# getModified()
?DateTime
Last modification date for the record.
# getPublished()
?DateTime
# isPublished()
bool
Determines if the record is published.
# getImage()
?Image
# getSite()
?Site
# getDescriptions()
?Collection<ProductDescription>
# getPricings()
?Collection<ProductPricing>
# getWidth()
?string
# getHeight()
?string
# getDepth()
?string
# getWeight()
?string
# getAvailableQuantity()
?int
# getInventoryTemplate()
?string
# getMinQuantity()
?int
Returns the smallest quantity a customer has to have in the cart; null when there is no minimum
# getMaxQuantity()
?int
Returns the largest quantity a customer can have in the cart; null when there is no maximum
# getQuantityStep()
?int
Returns the step the quantity is counted in from the minimum quantity (from 1 when there is no minimum): minimum 2 and step 3 allow 2, 5, 8, and so on; null when there is no step
# getQuantityMultiple()
?int
Returns the number the quantity has to be a multiple of: 5 allows 5, 10, 15, and so on; null when there is no multiple
# getOverallQuantity()
?int
Returns the total quantity a customer can buy within the overall period, counting the orders already placed; null when there is no overall limit
# getOverallPeriod()
int
Returns the period of the overall quantity in seconds; 0 means ever
# getPurchaseControls()
array
Returns the purchase controls as a whole: the stored JSON object with a key per rule
# getStocks()
?Collection<Stock>
# getInterests()
?Collection<ProductInterest>
# getExternalId()
?string
# isNewRecord() Not in API & Jobs
bool
Check if the record is a new record
# isHierarchicalModel() Not in API & Jobs
bool
Check whether a model is a hierarchical model, i.e. can have children
# isVersionedModel() Not in API & Jobs
bool
Check whether a model is versioned
# getAvailableCategories() Admin only
Collection
Get the available categories
# getDuplicateUrl() Admin only
?string
Get the url for duplicating the record.
# getPublishUrl() Admin only
?string
Get the url for publishing the record.
# getDefaultLanguage() Admin only
Language
Gets the default language for the record.
# getSupportedLanguages() Admin only
Collection
Gets the supported languages.
# getDefaultCurrency() Admin only
Currency
Gets the default currency for the record.
# getSupportedCurrencies() Admin only
Collection
Gets the supported currencies.
# getAvailableWarehouses() Admin only
array
Returns the list of warehouses sorted by name and indexed by ID
# getStockQuantities() Admin only
array
Fetches stock quantities (indexed by warehouse ID) and keeps current value, value (submitted by user) and original value (value fetched as current on HTML form rendering)

Methods 14

Take arguments. The API serialises only getters that need none.

# getProductCategories(?array $criteria, string $sort, string $direction)
Collection
Helper that will fetch instances of Products\Models\Category through Products\Models\CategoryElement
# getCustomFieldValue(CustomField $customField)
?CustomFieldValue
Get the value for a custom field
# getCustomFieldValueByName(string $customFieldName)
?CustomFieldValue
Get the value for a custom field by the custom field name
# getCustomFieldContent(string $customFieldName)
?Content
Get the content for the custom field identified by the specified name
# getCustomFieldContentOrDefault(string $customFieldName)
?Content
Get the (default) content for the custom field identified by the specified name
# getCustomFieldBoolean(string $customFieldName, ?bool $default)
?bool
Get the (default) content of the custom field as boolean value
# getCustomFieldText(string $customFieldName, ?string $default)
?string
Get the (default) content of the custom field as text
# getCustomFieldImage(string $customFieldName)
?Image
Get the (default) image contained in the custom field
# getCustomFieldFile(string $customFieldName)
?File
Get the (default) file contained in the custom field
# hasCustomField(string $customFieldName)
bool
Check if the entity has a custom field with the specified name
# getPricingForCurrency(Currency $currency)
?ProductPricing
Returns the general pricing for a specific currency, i.e., the price everybody pays unless a personal pricing applies. Returns nothing if there is no pricing set for the given currency.
# getPersonalPricingsForPerson(?Person $person)
Collection
Returns the personal pricings that apply to a person: their own pricings and the pricings of the groups they belong to, in every currency. Without a person the collection is empty.
# getFinalPrice(?Currency $currency, ?Person $person)
?string
Calculates the final price of the product for the customer in the given currency. When a personal pricing applies to the customer, its price is the final price, even when it is higher than the general one: a personal pricing replaces the general pricing rather than discounts it. A person's own pricing wins over the pricings of their groups; among group pricings the sticky ones are considered first, and the lowest wins. The price of a pricing is the lower of its *base price* and its *special price*. If *base price* of the product is 0.00, such a product could be added to the cart. If other prices (e.g. *special price*) are 0, they are ignored, and *base price* is returned (that could be 0.00).
# getDescriptionForLanguage(Language $language)
?Model
Retrieves the description for the specified language. Returns null when there is no description in that language.