OroCommerce give ability to organize your product attributes by group for example media group , price group … and every product family constructed from many attributes group .
So when the customer visits the product view page in the frontend they explore all infos related to current product – attributes value – Divided in many container each one contain many groups .
For example let’s talking about product_view_additional_container which contain additional attributes .
- System attributes like : media – prices …
- Additional Attribute : attributes which you have added to show more specification about your products for example .
Inside product_view_additional_container OroCommerce push all groups with additional attributes – that in case when you using default product view template or two columns page -
For example product_view_attributes_rest_attribute_group_markets or product_view_attributes_rest_attribute_group_docs which contain some attributes to show inside – the order of groups came from your order in admin -
The class responsible for managing additional attribute group is Oro\Bundle\EntityConfigBundle\Layout\Block\Type\AttributeGroupRestType , is a block type :
oro_entity_config.block_type.attribute_group_rest: class: 'Oro\Bundle\EntityConfigBundle\Layout\Block\Type\AttributeGroupRestType' arguments: - '@oro_entity_config.attribute_render_registry' - '@oro_locale.helper.localization' tags: - { name: layout.block_type, alias: attribute_group_rest }
Which you can add to your container and passing as options current entity and attribute_family to show you all group of current product based on attribute family
</p> <p> - '@addTree': items: product_view_attributes_rest: blockType: attribute_group_rest options: entity: '=data["product"]' attribute_family: '=context["attribute_family"]' attr: class: "product-view__attributes-container" vars: tabsOptions: '=data["attribute_groups_tabs_options_provider"].getTabsOptions(context["attribute_family"])' tree: product_view_additional_container: product_view_attributes_rest: ~
So how you can move and structured your group is easy for example lets imagine that you want move your group product_view_attributes_rest_attribute_group_docs above product_view_attributes_rest_attribute_group_markets is easy go to your layout .yml inside you layout handler folder oro_product_frontend_product_view and write:
- '@move': id: group product_view_attributes_rest_attribute_group_docs siblingId: product_view_attributes_rest_attribute_group_markets
or remove group by:
- '@remove': id: group product_view_attributes_rest_attribute_group_docs
Let’s move just attributes from product_view_additional_container to product_view_primary_container especially to product_view_description_container go to admin open your attribute from products→ Product Attribues for example the name (code) Is benefits from Frontend options change select field visible to no now go to your layout and add :
- '@add': id: product_view_ benefits parentId: product_view_description_container blockType: block prepend: false options: vars: parentProduct: '=data["parentProduct"]'
Go to twig related to this layout and add widget block:
{% block _product_view_benefits_widget %} <div {{ block('block_attributes') }}> <div class="benefits"> <h2>{{ 'ibnab.frontend.benefits' | trans}}</h2> {{ block.vars.parentProduct.benefits|raw }} </div> </div> {% endblock %}
The article of today is done!
Comments