| description | Storefront Twig function enable controlling the rendering of storefront elements. |
|---|---|
| edition | commerce |
| page_type | reference |
You can use storefront Twig functions to control the rendering of storefront elements.
ibexa_storefront_get_logo() returns current shop logo (configured in ibexa.system.<scope>.storefront.logo):
{% block logo %}
<img src="{{ asset(ibexa_storefront_get_logo()) }}" alt="Logo" />
{% endblock %}
ibexa_storefront_get_name() returns current shop name (configured in ibexa.system.<scope>.storefront.name):
{% block copyright %}
© {{ null|date('Y') }} {{ ibexa_storefront_get_name() }}
{% endblock %}
ibexa_storefront_get_main_menu_alias() returns the main menu alias.
ibexa_storefront_get_main_menu_options() returns the main menu's options (configured in ibexa.system.<scope>.storefront.main_menu / ibexa.system.<scope>.storefront.main_menu_options).
{% block main_menu %}
{% set main_menu_alias = ibexa_storefront_get_main_menu_alias() %}
{% set main_menu_options = ibexa_storefront_get_main_menu_options() %}
{{ knp_menu_render(main_menu_alias, main_menu_options) }}
{% endblock %}
ibexa_storefront_create_inline_product_search_form() creates a product search form:
{% block search %}
{{ form(ibexa_storefront_create_inline_product_search_form()) }}
{% endblock %}
ibexa_storefront_get_main_category() returns the main (first-level) category for a given category.
For example: if a given category is "Desks" and it has the following ancestors: "Furniture" > "Office" > "Desks", then the main category for "Office" is "Furniture".
{% set main_category = ibexa_storefront_get_main_category(category) %}
<p>Main category: {{ main_category.name }}</p>
ibexa_storefront_get_active_currency() returns the active currency object (Ibexa\Contracts\ProductCatalog\Values\CurrencyInterface).
{% set currency = ibexa_storefront_get_active_currency() %}
<p>Active currency code: {{ currency.code }}</p>
ibexa_storefront_get_language_name_by_code() displays language name based on its code or locale.
{% set languageName = ibexa_storefront_get_language_name_by_code(languageCode) %}
<p>Language name: {{ languageName }}</p>
ibexa_storefront_get_product_render_action() returns a rendering action to be used, as defined in settings.
It serves as an alternative for ibexa_render which heavily relies on content objects being not present within context of remote PIM.
You can use this, for example, to parametrize the display of products by using a custom controller.
{% if ibexa_is_pim_local() %}
{{ ibexa_render(product, { method: 'esi', viewType: 'card' }) }}
{% else %}
{{ render(
controller(ibexa_storefront_get_product_render_action(), {
product: product
})
) }}
{% endif %}
ibexa_get_anonymous_user_id() returns the configured user ID for the anonymous user (configured in ibexa.system.<scope>.anonymous_user_id).
{{ ibexa_get_anonymous_user_id() }}
This function detects if the Discounts LTS Update is installed.
{% if ibexa_storefront_are_discounts_enabled() %}
<div class="ibexa-store-maincart-item__subtotal-original-price-net ibexa-store-discount-price">
{{- product_price_original_subtotal -}}
</div>
{% endif %}