Render a product¶
To customize the template for a product, first, you need to prepare a content view configuration.
By default, the anonymous user does not have permissions to view products.
To change this, add the
Product/View Policy to the Anonymous Role.
To match all products, you can use the
ProductBased\IsProduct view matcher.
1 2 3 4 5 6 7 8 9
This matching applies to Content items that are also products.
This enables you to access both content properties and product properties in the template.
You can use the
ibexa_get_product Twig filter to get the product object from a Content item:
1 2 3 4
You can access all attributes of a product with
1 2 3 4 5
ibexa_format_product_attribute filter formats the attributes, including number formatting.
For example, it renders human-readable labels instead of identifiers and applies correct decimal digit separators for the locale.
You can access the product's price information from the product object:
Add to basket¶
ibexa.commerce.basket.add route enables you to create an "Add to basket" button.
To make the button fully functional, you must first configure all necessary information for the product, otherwise the product will not be added to basket.
See Enable purchasing products for more information.
1 2 3 4 5 6