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)
Get a product by ID
The method gets information about a product by ID.
Method signature
Product getProductById(String definitionName, String connectionName, String 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").
Get all categories
The method gets all categories.
Method signature
Collection<Category> getAllCategories(String definitionName, String 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)
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)
Get all products
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)