Manages the product catalogue for an account: products, SKUs, product parameters and their options, categories, ecommerce stores and inventory locations. It also creates and updates product and category images, calculates a product's popularity score from view and order history, and supports bulk creation and searching of SKUs. Registered as the "catalogManager" service, so app developers reach it from server-side JavaScript by name. Most lookups fall back to the parent organisation hierarchy when nothing is found locally, and most mutating methods fire a DefaultIndexedItemUpdatedEvent so search indexes stay in sync with the change.

Group: Managers


Properties

PropertyReturnsDescription
categoriesList<Category>All categories defined in the current organisation.
ecomStoresList<ECommerceStore>The account's ecommerce stores, excluding any whose website has been deleted.
inventoryLocationsList<InventoryLocation>The inventory locations defined in the current organisation.
parentOrgsWithProductsList<Pair>The ancestor organisations of the current organisation, including itself, that have at least one product, as ID and formatted-name pairs.
storesList<ECommerceStore>All of the account's ecommerce stores, including any whose website has been deleted. Unlike getEcomStores, this does not filter out stores with deleted websites.

Methods

createSku(Product product, String name, String title, BigDecimal baseCost) · createAlias(ProductSku mainSku, String aliasCode, String aliasTitle, Organisation distOrg) · addOrUpdateProductImage(Product product, String imageName, String imageHash) · addOrUpdateCategoryImage(Category cat, String imageHash) · addProductParameter(Product product, String title, String code) · deleteProductParameter(ProductParameter pp) · deleteProductParameterOption(ParameterOption ppo) · findParameterOption(Long id) · addProductParameterOption(ProductParameter productParameter, String title, String code) · undeleteSku(ProductSku sku, String newSkuCode) · deleteSku(ProductSku sku) · deleteProduct(Product product, Profile deleteBy) · productCount(ECommerceStore store) · findSkus(Product p) · findSku(Long skuId) · findSkuByProductAndOption(Product p, List<ParameterOption> opts) · findSku(String skuCode) · findDistSku(String skuCode, Organisation distributorOrg) · findSkuInHierarchy(String skuCode) · findSkuInHierarchy(Long skuId) · findProductByName(String productCode) · findProductById(Long id) · findProductInStore(String name, ECommerceStore store) · findProductInStoreById(Long productId, ECommerceStore store) · findProductInStore(Product p, ECommerceStore store) · findSkuInStore(Long id, ECommerceStore store) · findProductByAssetId(String assetId) · findCategoryByAssetId(String assetId) · findProductsByCategory(Category cat) · stockForSku(ECommerceStore store, ProductSku sku, InventoryLocation loc) · createAssetForProduct(Product p, ContentType type) · createAssetForCategory(Category cat, ContentType type) · findProductAssetTypes() · findCategoryAssetTypes() · checkCreateStore(String title, String storeName, String websiteName) · createStore(String storeName, String title, Website website) · addToStore(String productCode, String storeName) · addToStore(Product product, ECommerceStore store) · addProductToCategory(Category category, Product product) · removeProductFromCategory(Category category, Product product) · checkCreateCategory(String name, String title) · getOrCreateCategory(String name, String title) · checkCreateProduct(String name, String title, String category) · getOrCreateProduct(String name, String title, String category) · fireProductUpdated(Product p) · fireProductDeleted(Product p) · newProductSearchBuilder() · searchProducts(String storeName, String query, String category, String sortField, Boolean asc) · searchProducts(ECommerceStore store, String query, Category c, String sortField, Boolean asc) · searchProducts(String storeName, String query, String category, Integer startPrice, Integer endPrice, String sortField, Boolean asc) · searchProducts(ECommerceStore store, String query, Category cat, Integer startPrice, Integer endPrice, String sortField, Boolean asc) · searchProducts(KSearchQuery kSearchQuery, Organisation prodLibOrg, List<Organisation> suppliers, SearchProperties searchProperties) · countSearchProducts(KSearchQuery kSearchQuery, Organisation prodLibOrg, List<Organisation> suppliers) · searchSkus(SkuSearchBuilder b, SearchProperties props) · findSkus(SkuSearchBuilder b, int maxResults) · newSkuSearchBuilder() · locations(ProductSku sku, ECommerceStore store) · locations(ProductSku sku) · findProductInLocation(InventoryLocation location, ProductSku sku) · removeProductInLocation(ProductInLocation pil) · removeProductsFromStore(List<ProductInEComStore> pies) · fireProductInLocationRemoved(ProductInLocation pil) · attributeNames() · attributeTitle(String name) · getEcomStores() · getStores() · findStore(String name) · storeUpdated(ECommerceStore store) · findStore(Long id) · findStoresByWebsite(Website website) · findProductCategories(Product product) · getCategories() · findRootCategories() · findCategory(String code) · findCategory(long id) · updateProductCustomField(long id, FormContext fc) · findInventoryLocation(String code) · findInventoryLocationById(Long id) · getInventoryLocations() · createInventoryLocation(String name, String title) · addToLocation(ProductSku sku, InventoryLocation loc) · updateStock(ProductSku sku, InventoryLocation loc, Long quantity) · deleteInventoryLocation(InventoryLocation loc) · deleteCategory(Category cat) · deleteStore(ECommerceStore store) · newProductBuilder(String productCode) · newProductSkuBuilder(Product product, String skuCode) · countOfOrders(ProductInEComStore pis, Date start, Date finish) · calcPopularity(ProductInEComStore pis, Date now) · matchAndSaveProductImage(String newName, InputStream inputStream) · deleteAllImages() · getParentOrgsWithProducts() · variants(Product p) · createMissingSkus(String skuMode, String costMode, String query, Long stockQuantity) · startCreatingMissingSkusProcess(String skuMode, String costMode, String query, Long stockQuantity) · findProductCategoryContent(String categoryName) · isInCategory(Product product, Category category)

createSku(Product product, String name, String title, BigDecimal baseCost)

Returns: ProductSku

Creates a new SKU for the given product with the given code, display title and base cost, and persists it.

ParameterDescription
productthe product the new SKU belongs to
namethe SKU's code, used as its unique identifier
titlethe SKU's display title
baseCostthe SKU's base cost, before any pricing rules are applied

createAlias(ProductSku mainSku, String aliasCode, String aliasTitle, Organisation distOrg)

Returns: ProductSku

Creates and saves a new SKU that is an alias for the given main SKU, sharing its product but with its own code, display title and distributor organisation. Used to give a distributor its own SKU code for an existing product without duplicating the product itself.

ParameterDescription
mainSkuthe SKU the new alias points to
aliasCodethe alias SKU's own code
aliasTitlethe alias SKU's own display title
distOrgthe distributor organisation the alias is created for

addOrUpdateProductImage(Product product, String imageName, String imageHash)

Returns: ItemImage

Adds a new image to the product under the given name, or updates the existing image with that name if the given hash differs from the stored one. The hash identifies the image content in the blob store.

ParameterDescription
productthe product to add or update the image on
imageNamethe name of the image, used to find an existing image with the same name
imageHashthe content hash of the image data

addOrUpdateCategoryImage(Category cat, String imageHash)

Returns: void

Sets the category's main image hash to the given value, but only when the category currently has no image or its existing hash already equals the given one. The hash identifies the image content in the blob store.

ParameterDescription
catthe category to set the main image on
imageHashthe content hash of the image data

addProductParameter(Product product, String title, String code)

Returns: ProductParameter

Adds a new product parameter (for example "Colour" or "Size") to the product, used to define the variant dimensions that SKUs are built from.

ParameterDescription
productthe product to add the parameter to
titlethe parameter's display title
codethe parameter's unique code within the product

deleteProductParameter(ProductParameter pp)

Returns: void

Deletes a product parameter (for example "Colour"), first removing all of its options. Removing an option fails if any active, non-deleted SKU is still linked to it. Saves the owning product and fires a product updated event.

ParameterDescription
ppthe product parameter to delete

deleteProductParameterOption(ParameterOption ppo)

Returns: void

Deletes a single option of a product parameter (for example the "Red" option of a "Colour" parameter). Fails if any active, non-deleted SKU is still linked to the option. Saves the owning product parameter and product, and fires a product updated event.

ParameterDescription
ppothe product parameter option to delete

findParameterOption(Long id)

Returns: ParameterOption

Finds a product parameter option by its database ID.

ParameterDescription
idthe ID of the parameter option to find

addProductParameterOption(ProductParameter productParameter, String title, String code)

Returns: ParameterOption

Adds a new option (for example "Red") to a product parameter (for example "Colour") and saves it.

ParameterDescription
productParameterthe product parameter to add the option to
titlethe option's display title
codethe option's unique code within the parameter

undeleteSku(ProductSku sku, String newSkuCode)

Returns: void

Restores a previously soft-deleted SKU, giving it the given new code.

ParameterDescription
skuthe soft-deleted SKU to restore
newSkuCodethe code to give the restored SKU

deleteSku(ProductSku sku)

Returns: void

Deletes the given SKU. Hard-deletes it if no orders or line items reference it, otherwise soft-deletes it so order history stays intact.

ParameterDescription
skuthe SKU to delete

deleteProduct(Product product, Profile deleteBy)

Returns: void

Soft-deletes the given product, recording who deleted it and when.

ParameterDescription
productthe product to delete
deleteBythe profile performing the deletion

productCount(ECommerceStore store)

Returns: long

Counts the number of products in the given ecommerce store, using a database count rather than loading the products themselves.

ParameterDescription
storethe store to count products in

findSkus(Product p)

Returns: List<ProductSku>

Returns the non-deleted SKUs belonging to the given product.

ParameterDescription
pthe product to find SKUs for

findSku(Long skuId)

Returns: ProductSku

Finds a SKU by its numeric database ID, scoped to the current account.

ParameterDescription
skuIdthe ID of the SKU to find

findSkuByProductAndOption(Product p, List<ParameterOption> opts)

Returns: ProductSku

Finds the SKU of the given product that matches the given combination of parameter options.

ParameterDescription
pthe product to find the SKU in
optsthe combination of parameter options the SKU must match

findSku(String skuCode)

Returns: ProductSku

Finds a SKU by its code (alphanumeric). Only looks in the current organisation, not its parents.

ParameterDescription
skuCodethe code of the SKU to find

findDistSku(String skuCode, Organisation distributorOrg)

Returns: ProductSku

Finds a SKU by its code and distributor organisation, for SKUs created as distributor-specific aliases.

ParameterDescription
skuCodethe code of the SKU to find
distributorOrgthe distributor organisation the SKU was created for

findSkuInHierarchy(String skuCode)

Returns: ProductSkuBean

Finds a SKU by its code, searching the current organisation and then its ancestor organisations until a match is found. Returns a simple bean representation rather than the full entity.

ParameterDescription
skuCodethe code of the SKU to find

findSkuInHierarchy(Long skuId)

Returns: ProductSkuBean

Finds a SKU by its numeric database ID and returns a simple bean representation of it. Validates that the SKU belongs to the current account or one of its ancestor organisations.

ParameterDescription
skuIdthe ID of the SKU to find

findProductByName(String productCode)

Returns: Product

Finds a product by its unique name (code) within the current organisation.

ParameterDescription
productCodethe product's name

findProductById(Long id)

Returns: Product

Finds a product by its numeric database ID, searching the current organisation and then its ancestor organisations, up to twenty levels, until a match is found.

ParameterDescription
idthe ID of the product to find

findProductInStore(String name, ECommerceStore store)

Returns: ProductInEComStore

Finds the product-in-store record for the product with the given name in the given store.

ParameterDescription
namethe name of the product to find
storethe store to look in

findProductInStoreById(Long productId, ECommerceStore store)

Returns: ProductInEComStore

Finds the product-in-store record for the product with the given ID in the given store.

ParameterDescription
productIdthe ID of the product to find
storethe store to look in

findProductInStore(Product p, ECommerceStore store)

Returns: ProductInEComStore

Finds the product-in-store record linking the given product to the given store.

ParameterDescription
pthe product to find
storethe store to look in

findSkuInStore(Long id, ECommerceStore store)

Returns: ProductSku

Finds a SKU by its ID, returning it only if its product is present in the given store.

ParameterDescription
idthe ID of the SKU to find
storethe store the SKU's product must be in

findProductByAssetId(String assetId)

Returns: Product

Finds a product by the unique ID of its associated content asset.

ParameterDescription
assetIdthe unique ID of the product's asset

findCategoryByAssetId(String assetId)

Returns: Category

Finds a category by the unique ID of its associated content asset.

ParameterDescription
assetIdthe unique ID of the category's asset

findProductsByCategory(Category cat)

Returns: List<Product>

Finds all products in the given category.

ParameterDescription
catthe category to search

stockForSku(ECommerceStore store, ProductSku sku, InventoryLocation loc)

Returns: Long

Looks up the available stock quantity for the given SKU at the given inventory location, within the given store.

ParameterDescription
storethe store the stock lookup is scoped to
skuthe SKU to check stock for
locthe inventory location to check stock at

createAssetForProduct(Product p, ContentType type)

Returns: Asset

Creates a new content asset of the given type for the product, using the product's name as the asset's name, and links it to the product by ID. Saves and flushes the product.

ParameterDescription
pthe product to create the asset for
typethe type of content asset to create

createAssetForCategory(Category cat, ContentType type)

Returns: Asset

Creates a new content asset of the given type for the category, using the category's name as the asset's name, and links it to the category by ID. Saves and flushes the category.

ParameterDescription
catthe category to create the asset for
typethe type of content asset to create

findProductAssetTypes()

Returns: Set<ContentType>

Returns the content types that can be used for a product's asset.

findCategoryAssetTypes()

Returns: Set<ContentType>

Returns the content types that can be used for a category's asset.

checkCreateStore(String title, String storeName, String websiteName)

Returns: boolean

Creates a new ecommerce store with the given name, title and website, unless a store with that name already exists in the current organisation. Fires an index update event when a store is created.

ParameterDescription
titlethe display title for the new store
storeNamethe unique name for the new store
websiteNamethe name of the website the store belongs to

createStore(String storeName, String title, Website website)

Returns: ECommerceStore

Creates a new ecommerce store with the given name, title and website. Fires an index update event and invalidates the cached store-name lookup.

ParameterDescription
storeNamethe unique name for the new store
titlethe display title for the new store
websitethe website the store belongs to

addToStore(String productCode, String storeName)

Returns: ProductInEComStore

Adds the product with the given code to the store with the given name, both looked up in the current organisation.

ParameterDescription
productCodethe code of the product to add
storeNamethe name of the store to add it to

addToStore(Product product, ECommerceStore store)

Returns: ProductInEComStore

Adds the given product to the given store, creating a product-in-store record. Fires an index update event when the record is created.

ParameterDescription
productthe product to add
storethe store to add it to

addProductToCategory(Category category, Product product)

Returns: boolean

Adds the given product to the given category. Fires a product updated event when the product is added.

ParameterDescription
categorythe category to add the product to
productthe product to add

removeProductFromCategory(Category category, Product product)

Returns: boolean

Removes the given product from the given category. Fires a product updated event when the product is removed.

ParameterDescription
categorythe category to remove the product from
productthe product to remove

checkCreateCategory(String name, String title)

Returns: boolean

Creates a new category with the given name and title, unless a category with that name already exists in the current organisation.

ParameterDescription
namethe unique name for the new category
titlethe display title for the new category

getOrCreateCategory(String name, String title)

Returns: Category

Finds the category with the given name in the current organisation, or creates and saves a new one with the given name and title if none exists.

ParameterDescription
namethe unique name of the category to find or create
titlethe display title to use if a new category is created

checkCreateProduct(String name, String title, String category)

Returns: boolean

Creates a new product with the given name and title if none exists yet in the current organisation, and adds it to the named category if one is found. If the product already exists, it is instead added to the named category if one is found. Fires a product updated event whenever the product is created or its category membership changes.

ParameterDescription
namethe unique name for the product
titlethe display title for the product, used only when creating a new product
categorythe name of the category to add the product to, if it can be found

getOrCreateProduct(String name, String title, String category)

Returns: Product

Finds the product with the given name in the current organisation, or creates and saves a new one with the given name and title if none exists. Adds the product to the named category if one is found, and fires a product updated event whenever the product is created or its category membership changes.

ParameterDescription
namethe unique name of the product to find or create
titlethe display title to use if a new product is created
categorythe name of the category to add the product to, if it can be found

fireProductUpdated(Product p)

Returns: void

Fires an index update event for the given product, so search picks up the change. Does nothing if the product is null.

ParameterDescription
pthe product that was updated

fireProductDeleted(Product p)

Returns: void

Fires an index update event marking the given product as deleted, so search removes it. Does nothing if the product is null.

ParameterDescription
pthe product that was deleted

newProductSearchBuilder()

Returns: ProductSearchBuilder

Creates a new, empty builder for searching products in the catalogue.

searchProducts(String storeName, String query, String category, String sortField, Boolean asc)

Returns: List<ProductInStoreBean>

Searches for products in the named store and optional category, sorted by the given field, looking the store and category up in the current root organisation.

ParameterDescription
storeNamethe name of the store to search in
querythe search term or phrase, optional
categorythe name of the category to search in, optional
sortFieldthe name of a property to sort by
asctrue for ascending order, false for descending

searchProducts(ECommerceStore store, String query, Category c, String sortField, Boolean asc)

Returns: List<ProductInStoreBean>

Searches for products in the given store and optional category, sorted by the given field.

ParameterDescription
storethe store to search in
querythe search term or phrase, optional
cthe category to search in, optional
sortFieldthe name of a property to sort by
asctrue for ascending order, false for descending

searchProducts(String storeName, String query, String category, Integer startPrice, Integer endPrice, String sortField, Boolean asc)

Returns: List<ProductInStoreBean>

Searches for products in the named store and optional category within a price range, sorted by the given field.

ParameterDescription
storeNamethe name of the store to search in
querythe search term or phrase, optional
categorythe name of the category to search in, optional
startPricethe minimum price to include, optional
endPricethe maximum price to include, optional
sortFieldthe name of a property to sort by
asctrue for ascending order, false for descending

searchProducts(ECommerceStore store, String query, Category cat, Integer startPrice, Integer endPrice, String sortField, Boolean asc)

Returns: List<ProductInStoreBean>

Searches for products in the given store and optional category within a price range, sorted by the given field.

ParameterDescription
storethe store to search in
querythe search term or phrase, optional
catthe category to search in, optional
startPricethe minimum price to include, optional
endPricethe maximum price to include, optional
sortFieldthe name of a property to sort by
asctrue for ascending order, false for descending

searchProducts(KSearchQuery kSearchQuery, Organisation prodLibOrg, List<Organisation> suppliers, SearchProperties searchProperties)

Returns: List<Product>

Searches for products matching the given query within the given product library organisation and optional suppliers, scoped to the current organisation.

ParameterDescription
kSearchQuerythe parsed search query
prodLibOrgthe product library organisation to search within
suppliersthe supplier organisations to restrict the search to, optional
searchPropertiespaging and sorting options for the result page

countSearchProducts(KSearchQuery kSearchQuery, Organisation prodLibOrg, List<Organisation> suppliers)

Returns: long

Counts the products matching the given query within the given product library organisation and optional suppliers, scoped to the current organisation.

ParameterDescription
kSearchQuerythe parsed search query
prodLibOrgthe product library organisation to search within
suppliersthe supplier organisations to restrict the search to, optional

searchSkus(SkuSearchBuilder b, SearchProperties props)

Returns: List<ProductSku>

Searches for SKUs matching the given criteria within the current organisation only. Products shared down from parent organisations are not included, even if their SKUs would otherwise match.

ParameterDescription
bthe search criteria to match SKUs against
propspaging and sorting options for the result page

findSkus(SkuSearchBuilder b, int maxResults)

Returns: List<ProductSku>

Searches for SKUs matching the given criteria, including through parent organisations. Accepts only a single result limit rather than a page size and offset, so it does not support pagination.

ParameterDescription
bthe search criteria to match SKUs against
maxResultsthe maximum number of matching SKUs to return

newSkuSearchBuilder()

Returns: SkuSearchBuilder

Creates a new, empty builder for searching SKUs in the catalogue.

locations(ProductSku sku, ECommerceStore store)

Returns: List<ProductInLocation>

Finds all inventory location records for the given SKU. The store parameter is accepted for compatibility but is not used to filter the results.

ParameterDescription
skuthe SKU to find location records for
storenot used

locations(ProductSku sku)

Returns: List<ProductInLocation>

Finds all inventory location records for the given SKU.

ParameterDescription
skuthe SKU to find location records for

findProductInLocation(InventoryLocation location, ProductSku sku)

Returns: ProductInLocation

Finds the inventory location record linking the given SKU to the given inventory location.

ParameterDescription
locationthe inventory location to look in
skuthe SKU to find

removeProductInLocation(ProductInLocation pil)

Returns: void

Deletes the given inventory location record, removing the SKU from that location.

ParameterDescription
pilthe inventory location record to delete

removeProductsFromStore(List<ProductInEComStore> pies)

Returns: void

Deletes the given product-in-store records, removing each product from its store. Fires an index update event for each one removed.

ParameterDescription
piesthe product-in-store records to delete

fireProductInLocationRemoved(ProductInLocation pil)

Returns: void

Fires an index update event marking the given inventory location record as deleted. Does nothing if pil is null.

ParameterDescription
pilthe inventory location record that was removed

attributeNames()

Returns: List<Pair<String,String>>

Returns the custom attribute names defined for the account, as name/title pairs. These are configured in ecommerce settings, and the result is cached on the root folder for the life of the request.

attributeTitle(String name)

Returns: String

Looks up the display title for the given attribute name, from the account's configured attribute names.

ParameterDescription
namethe attribute name to look up

getEcomStores()

Returns: List<ECommerceStore>

The account's ecommerce stores, excluding any whose website has been deleted.

getStores()

Returns: List<ECommerceStore>

All of the account's ecommerce stores, including any whose website has been deleted. Unlike getEcomStores, this does not filter out stores with deleted websites.

findStore(String name)

Returns: ECommerceStore

Finds an ecommerce store by its name within the current organisation. The store's ID is cached briefly by name to speed up repeated lookups.

ParameterDescription
namethe name of the store to find

storeUpdated(ECommerceStore store)

Returns: void

Invalidates the entire store-name lookup cache, so subsequent findStore calls re-read from the database. Call this after a store's name changes.

ParameterDescription
storethe store that was updated

findStore(Long id)

Returns: ECommerceStore

Finds an ecommerce store by its numeric database ID, within the current organisation.

ParameterDescription
idthe ID of the store to find

findStoresByWebsite(Website website)

Returns: List<ECommerceStore>

Finds the ecommerce stores belonging to the given website, provided the website belongs to the current organisation.

ParameterDescription
websitethe website to find stores for

findProductCategories(Product product)

Returns: List<Category>

Finds the categories the given product belongs to that are owned by the current organisation, ignoring categories owned by other organisations.

ParameterDescription
productthe product to find categories for

getCategories()

Returns: List<Category>

All categories defined in the current organisation.

findRootCategories()

Returns: List<Category>

Finds the top-level categories in the current organisation, that is, categories with no parent category.

findCategory(String code)

Returns: Category

Finds a category by its unique name (code) within the current organisation.

ParameterDescription
codethe category's name

findCategory(long id)

Returns: Category

Finds a category by its numeric database ID, within the current organisation.

ParameterDescription
idthe ID of the category to find

updateProductCustomField(long id, FormContext fc)

Returns: Product

Updates the product with the given ID from the field1, field2 and field3 parameters in the given form context, and saves it. Fires a product updated event.

ParameterDescription
idthe ID of the product to update
fcthe form context to read the field1, field2 and field3 parameters from

findInventoryLocation(String code)

Returns: InventoryLocation

Finds an inventory location by its unique name (code) within the current organisation.

ParameterDescription
codethe location's name

findInventoryLocationById(Long id)

Returns: InventoryLocation

Finds an inventory location by its numeric database ID, within the current organisation.

ParameterDescription
idthe ID of the inventory location to find

getInventoryLocations()

Returns: List<InventoryLocation>

The inventory locations defined in the current organisation.

createInventoryLocation(String name, String title)

Returns: InventoryLocation

Creates and saves a new inventory location with the given name and title in the current organisation.

ParameterDescription
namethe unique name for the new inventory location
titlethe display title for the new inventory location

addToLocation(ProductSku sku, InventoryLocation loc)

Returns: boolean

Adds the given SKU to the given inventory location, unless it is already there.

ParameterDescription
skuthe SKU to add
locthe inventory location to add it to

updateStock(ProductSku sku, InventoryLocation loc, Long quantity)

Returns: ProductInLocation

Updates how much of the given SKU is held at the given inventory location, creating the stock record when the SKU has never been held there before, and re-indexing the SKU. The quantity is the count on hand, not a movement, and must not be null: a null stock figure reads as "this account does not do stock control", which makes the checkout skip its insufficient-stock check.

ParameterDescription
skuthe SKU to set the quantity for
locthe inventory location the stock is held at
quantitythe quantity now on hand at that location, zero or more

deleteInventoryLocation(InventoryLocation loc)

Returns: void

Deletes the given inventory location, along with the stock records held at it. The SKUs themselves are untouched; only the record of how much of each was held there goes with the location. Pricing rules refer to a location by name and are not checked here, so deleting a location a PricingRulesSet names makes checkout fail for the stores using it. Neither the location nor its stock records are Auditable, so there is no restore path.

ParameterDescription
locthe inventory location to delete

deleteCategory(Category cat)

Returns: void

Deletes the given category. The category's products are not deleted: their membership of it is removed, any sub-categories are detached rather than deleted with it, and any product using it as a brand has its brand cleared. Fires an index update event for each product that was in it, so search stops reporting the category against them.

ParameterDescription
catthe category to delete

deleteStore(ECommerceStore store)

Returns: void

Deletes the given ecommerce store, recording who deleted it and when. Stores are deleted softly, so the orders placed through it keep pointing at a store which still exists; it simply stops being returned by the finders. The products stay in the catalogue; only this shop front for them goes. Also invalidates the cached store-name lookup, so a store of the same name can be created again afterwards, and removes the store's products from the search index - nothing indexes the store itself, so its product-in-store documents would otherwise keep answering store searches for a store that no longer exists.

ParameterDescription
storethe store to delete

newProductBuilder(String productCode)

Returns: ProductBuilder

Creates a new builder for creating a product with the given code in the current organisation.

ParameterDescription
productCodethe code for the new product

newProductSkuBuilder(Product product, String skuCode)

Returns: ProductSkuBuilder

Creates a new builder for creating or updating a SKU with the given code on the given product.

ParameterDescription
productthe product the SKU belongs to
skuCodethe code for the SKU

countOfOrders(ProductInEComStore pis, Date start, Date finish)

Returns: Long

Counts how many orders have been placed for the given product-in-store, optionally within a date range.

ParameterDescription
pisthe product-in-store to count orders for
startthe start of the date range, optional
finishthe end of the date range, optional

calcPopularity(ProductInEComStore pis, Date now)

Returns: Long

Calculates a product-in-store's popularity score at the given date and time, combining a decayed view-count component and a decayed order-count component, each weighted and half-lifed by the account's ecommerce settings.

ParameterDescription
pisthe product-in-store to calculate popularity for
nowthe date and time to calculate the score as of

matchAndSaveProductImage(String newName, InputStream inputStream)

Returns: MatchImageNameResult

Attempts to match an uploaded image's file name against a product, a product-and-ordinal combination, a product option, a product SKU or a variant code, and saves the image against whichever it matches first. Does nothing and returns null if the file name has no extension, the input stream is null, or the file is not a recognised image type.

ParameterDescription
newNamethe file name of the uploaded image, including its extension
inputStreamthe image data

deleteAllImages()

Returns: int

Deletes every product image in the current account, along with clearing the image hash from every parameter option and SKU. Fires a product updated event for each affected product.

getParentOrgsWithProducts()

Returns: List<Pair>

The ancestor organisations of the current organisation, including itself, that have at least one product, as ID and formatted-name pairs.

variants(Product p)

Returns: List<Variant>

Builds the full set of variant lines for the given product: one line per combination of its parameter options, matched to an existing SKU where one exists, plus a line for any SKU that does not correspond to a current combination of options.

ParameterDescription
pthe product to build variants for

createMissingSkus(String skuMode, String costMode, String query, Long stockQuantity)

Returns: int

Creates SKUs for any variant combinations of products matching the given search query that do not already have one. The SKU code and cost are either built by combining the product's own code or cost with its parameter options, or left blank/zero and built purely from the options, depending on skuMode and costMode. If stockQuantity is given, the new SKUs are stocked at that quantity in every inventory location. Fires a product updated event for each affected product.

ParameterDescription
skuMode"combine" to seed the SKU code from the product's own code, any other value to build it purely from the variant's parameter options
costMode"combine" to seed the SKU cost from the product's own base cost, any other value to build it purely from the variant's parameter options
querythe search query used to select which products to process
stockQuantitythe stock quantity to apply to new SKUs in every inventory location, or null to skip stocking them

startCreatingMissingSkusProcess(String skuMode, String costMode, String query, Long stockQuantity)

Returns: AsyncJob

Enqueues an asynchronous job that runs createMissingSkus in the background, for use when the operation may take too long to run within a request.

ParameterDescription
skuMode"combine" to seed the SKU code from the product's own code, any other value to build it purely from the variant's parameter options
costMode"combine" to seed the SKU cost from the product's own base cost, any other value to build it purely from the variant's parameter options
querythe search query used to select which products to process
stockQuantitythe stock quantity to apply to new SKUs in every inventory location, or null to skip stocking them

findProductCategoryContent(String categoryName)

Returns: ProductCategoryContent

Finds the content configuration for products and SKUs in the named category, if any has been defined in the account's query configuration. The returned object controls how fields are presented.

ParameterDescription
categoryNamethe name of the category to find content configuration for

isInCategory(Product product, Category category)

Returns: boolean

Checks whether the given product is in the given category.

ParameterDescription
productthe product to check
categorythe category to check membership of
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.