ecomfn

The ecomfn templating functions provide access to the products from your external e-commerce solution in your FreeMarker templates.

The ecomfn templating functions are provided by the E-commerce templating module. The Java class that implements the methods is info.magnolia.ecommerce.templating.EcommerceTemplatingFunctions.

Get a category by ID

The method gets information about a category by ID.

Method signature

Category getCategoryById(String definitionName, String connectionName, String categoryId)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

categoryId

required

The category ID.

Returns

A category.

Usage

ecomfn.getCategoryById(definitionName, connectionName, categoryId)

Get a product by ID

The method gets information about a product by ID.

Method signature

Product getProductById(String definitionName, String connectionName, String productId)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

productId

required

The product ID.

Returns

A product.

Usage

ecomfn.getProductById(definitionName, connectionName, productId)

Get product information by product ID as a string

The argument productId represents a slash separated string of definitionName, connectionName and productId.

For example: ecomfn.getProductById("definitionName/connectionName/productId").

Method signature

Product getProductById(String productId)

Arguments

Argument Description

productId

required

The product ID.

Returns

Product information.

Usage

ecomfn.getProductById(productId)

Get all categories

The method gets all categories.

Method signature

Collection<Category> getAllCategories(String definitionName, String connectionName)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

Returns

A list of categories.

Usage

ecomfn.getAllCategories(definitionName, connectionName)

Get all categories by product ID

The method gets all categories by product ID. For example, you have a product with the ID redhandbag1 that belongs to categories such as accessories, red, evening-wear and formal.

Method signature

Collection<Category> getCategoriesByProductId(String definitionName, String connectionName, String productId)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

productId

required

The product ID.

Returns

A list of all categories by product ID.

Usage

ecomfn.getAllCategories(definitionName, connectionName, productId)

Get all categories by parent ID

The method gets all categories by parent category. For example, you have a parent category with the ID summer, that has child categories such as sun-glasses, sun-cream, swimwear and so on.

Method signature

Collection<Category> getCategoriesByParentCategoryId(String definitionName, String connectionName, String categoryId)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

categoryId

required

The ID of the parent category, for example summer.

Returns

A list of all categories by the parent category ID.

Usage

ecomfn.getCategoriesByParentCategoryId(definitionName, connectionName, categoryId)

Get all products

The method gets all products.

Method signature

Collection<Product> getAllProducts(String definitionName, String connectionName)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

Returns

A list of all products.

Usage

ecomfn.getAllProducts(definitionName, connectionName)

Get all products by category ID

The method gets all products by category ID.

Method signature

Collection<Product> getProductsByCategoryId(String definitionName, String connectionName, String categoryId)

Arguments

Argument Description

definitionName

required

The definition name, for example magentodefinition.

connectionName

required

The connection name, for example production.

categoryId

required

The ID of the category.

Returns

A list of products by category ID.

Usage

ecomfn.getProductsByCategoryId(definitionName, connectionName, categoryId)

The method gets a URL link to an image by product.

Method signature

String getImageLink(Product product)

Arguments

Argument Description

product

required

The product object.

Returns

An image URL.

Usage

ecomfn.getImageLink(product)

Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the E-commerce module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules