<commit_before>{% extends 'SyliusWebBundle:Frontend:layout.html.twig' %}

{% set form = sylius_cart_form({'product': product}) %}
{% from 'SyliusWebBundle:Frontend/Product:macros.html.twig' import sylius_display_price %}

{% block head %}
    {{ sylius_metadata_render(product, null, { 'defaults': {
        'title': settings.title|default('sylius.meta.frontend_title'|trans),
        'description': settings.meta_description|default('sylius.meta.frontend_description'|trans),
        'keywords': settings.meta_description|default('sylius.meta.frontend_keywords'|trans)
    } })|raw }}
{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-3">
        <a href="{{ path(product) }}" class="thumbnail">
            <img src="{{ product.image ? product.image.path|imagine_filter('sylius_medium') : 'http://placehold.it/200x200' }}" alt="{{ product.name }}" />
        </a>
    </div>
    <div class="col-md-9">
        <a href="{{ path(product) }}" class="btn btn-link"><h3>{{ product.name }}</h3></a>
        <p>{{ product.shortDescription|default('sylius.product.no_description')|trans|raw }}</p>
        {% if product.averageRating %}
        <h3>{{ 'sylius.product.rating'|trans }}: {{ product.averageRating|round(2, 'floor') }}</h3>
        {% endif %}
    </div>
</div>
{% if product.images|length > 0 %}
<hr>
<div id="gallery">
    {% for image in product.images %}
        <a href="{{ image.path|imagine_filter('sylius_large') }}" title="{{ product.name }}">
            <img class="img-rounded" src="{{ image.path|imagine_filter('sylius_small') }}" alt="{{ product.name }}" />
        </a>
    {% endfor %}
</div>
{% endif %}
<hr>
<div class="row">
    <div class="col-md-6">
        {% if product.attributes|length > 0 %}
        <table class="table table-condensed">
            <thead>
                <tr>
                    <th colspan="2">{{ 'sylius.product.attributes'|trans }}</th>
                </tr>
            </thead>
            <tbody>
                {% for attribute in product.attributes %}
                <tr>
                    <td>{{ attribute.name }}</td>
                    {% set attributeTemplate = 'SyliusAttributeBundle:Types:' ~ attribute.attribute.type ~ '.html.twig' %}
                    {% include [attributeTemplate, 'SyliusWebBundle:Frontend/Product:_attribute.html.twig'] with {'attribute': attribute} %}
                </tr>
                {% endfor %}
            </tbody>
        </table>
        {% endif %}
    </div>
    <div class="col-md-6">
        <h4>{{ 'sylius.product.description'|trans }}</h4>
        <p>{{ product.description|default('sylius.product.no_description')|trans|raw }}</p>
    </div>
</div>
<hr>
<div class="row">
    <form action="{{ path('sylius_cart_item_add', {'id': product.id}) }}" method="post" class="clearfix form-horizontal">
    <div class="col-md-6">
        {% if product.hasVariants %}
            {% if product.isVariantSelectionMethodChoice %}
            <table class="table table-condensed" id="product-variants">
                <thead>
                    <tr>
                        <th></th>
                        <th>{{ 'sylius.variant.price'|trans }}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for variant in product.variants if variant.available %}
                    <tr>
                        <td>
                            {% if variant.presentation is empty %}
                            <ul class="unstyled">
                                {% for option in variant.options %}
                                <li><strong>{{ option.presentation }}</strong>: {{ option.value }}</li>
                                {% endfor %}
                            </ul>
                            {% else %}
                                {{ variant.presentation }}
                            {% endif %}
                        </td>
                        <td>
                            {{ sylius_display_price(variant) }}
                        </td>
                        <td>
                        {% if sylius_inventory_is_available(variant) %}
                            {{ form_widget(form.variant[loop.index0]) }}
                        {% else %}
                            <span class="label label-warning">{{ 'sylius.out_of_stock'|trans }}</span>
                        {% endif %}
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
                <div class="well clearfix">
                    {{ form_widget(form.variant) }}
                </div>
            {% endif %}
        {% else %}
            <h4>
                <span class="pull-right">
                   {{ sylius_display_price(product.masterVariant) }}
                </span>
                {{ 'sylius.variant.price'|trans }}
            </h4>
        {% endif %}
    </div>
    <div class="col-md-6 pull-right">
        {% if not product.hasVariants and not sylius_inventory_is_available(product.masterVariant) %}
            <span class="label label-warning">{{ 'sylius.out_of_stock'|trans }}</span>
        {% else %}
            {{ form_row(form.quantity, {'attr': {'class': 'center-text'}, 'empty_value': '1'}) }}
            {{ form_widget(form._token) }}
            <br>
            <br>
            {% if sylius_is_restricted(product) %}
            <button disabled="disabled" class="btn btn-success btn-lg btn-block"><i class="icon-shopping-cart icon-white icon-large"></i> {{ 'sylius.product_not_available_in_zone'|trans }}</button>
            {% else %}
                <button type="submit" class="btn btn-success btn-lg btn-block"><i class="icon-shopping-cart icon-white icon-large"></i> {{ 'sylius.add_to_cart'|trans }}</button>
            {% endif %}
        {% endif %}
    </div>
</form>
</div>

<hr />

<div>
    <h3>{{ 'sylius.review.header'|trans }}</h3><commit_msg>[WebBundle]: Displaying product associations in frontend product page<commit_after>{% extends 'SyliusWebBundle:Frontend:layout.html.twig' %}

{% set form = sylius_cart_form({'product': product}) %}
{% from 'SyliusWebBundle:Frontend/Product:macros.html.twig' import sylius_display_price, list %}

{% block head %}
    {{ sylius_metadata_render(product, null, { 'defaults': {
        'title': settings.title|default('sylius.meta.frontend_title'|trans),
        'description': settings.meta_description|default('sylius.meta.frontend_description'|trans),
        'keywords': settings.meta_description|default('sylius.meta.frontend_keywords'|trans)
    } })|raw }}
{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-3">
        <a href="{{ path(product) }}" class="thumbnail">
            <img src="{{ product.image ? product.image.path|imagine_filter('sylius_medium') : 'http://placehold.it/200x200' }}" alt="{{ product.name }}" />
        </a>
    </div>
    <div class="col-md-9">
        <a href="{{ path(product) }}" class="btn btn-link"><h3>{{ product.name }}</h3></a>
        <p>{{ product.shortDescription|default('sylius.product.no_description')|trans|raw }}</p>
        {% if product.averageRating %}
        <h3>{{ 'sylius.product.rating'|trans }}: {{ product.averageRating|round(2, 'floor') }}</h3>
        {% endif %}
    </div>
</div>
{% if product.images|length > 0 %}
<hr>
<div id="gallery">
    {% for image in product.images %}
        <a href="{{ image.path|imagine_filter('sylius_large') }}" title="{{ product.name }}">
            <img class="img-rounded" src="{{ image.path|imagine_filter('sylius_small') }}" alt="{{ product.name }}" />
        </a>
    {% endfor %}
</div>
{% endif %}
<hr>
<div class="row">
    <div class="col-md-6">
        {% if product.attributes|length > 0 %}
        <table class="table table-condensed">
            <thead>
                <tr>
                    <th colspan="2">{{ 'sylius.product.attributes'|trans }}</th>
                </tr>
            </thead>
            <tbody>
                {% for attribute in product.attributes %}
                <tr>
                    <td>{{ attribute.name }}</td>
                    {% set attributeTemplate = 'SyliusAttributeBundle:Types:' ~ attribute.attribute.type ~ '.html.twig' %}
                    {% include [attributeTemplate, 'SyliusWebBundle:Frontend/Product:_attribute.html.twig'] with {'attribute': attribute} %}
                </tr>
                {% endfor %}
            </tbody>
        </table>
        {% endif %}
    </div>
    <div class="col-md-6">
        <h4>{{ 'sylius.product.description'|trans }}</h4>
        <p>{{ product.description|default('sylius.product.no_description')|trans|raw }}</p>
    </div>
</div>
<hr>
<div class="row">
    <form action="{{ path('sylius_cart_item_add', {'id': product.id}) }}" method="post" class="clearfix form-horizontal">
    <div class="col-md-6">
        {% if product.hasVariants %}
            {% if product.isVariantSelectionMethodChoice %}
            <table class="table table-condensed" id="product-variants">
                <thead>
                    <tr>
                        <th></th>
                        <th>{{ 'sylius.variant.price'|trans }}</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for variant in product.variants if variant.available %}
                    <tr>
                        <td>
                            {% if variant.presentation is empty %}
                            <ul class="unstyled">
                                {% for option in variant.options %}
                                <li><strong>{{ option.presentation }}</strong>: {{ option.value }}</li>
                                {% endfor %}
                            </ul>
                            {% else %}
                                {{ variant.presentation }}
                            {% endif %}
                        </td>
                        <td>
                            {{ sylius_display_price(variant) }}
                        </td>
                        <td>
                        {% if sylius_inventory_is_available(variant) %}
                            {{ form_widget(form.variant[loop.index0]) }}
                        {% else %}
                            <span class="label label-warning">{{ 'sylius.out_of_stock'|trans }}</span>
                        {% endif %}
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% else %}
                <div class="well clearfix">
                    {{ form_widget(form.variant) }}
                </div>
            {% endif %}
        {% else %}
            <h4>
                <span class="pull-right">
                   {{ sylius_display_price(product.masterVariant) }}
                </span>
                {{ 'sylius.variant.price'|trans }}
            </h4>
        {% endif %}
    </div>
    <div class="col-md-6 pull-right">
        {% if not product.hasVariants and not sylius_inventory_is_available(product.masterVariant) %}
            <span class="label label-warning">{{ 'sylius.out_of_stock'|trans }}</span>
        {% else %}
            {{ form_row(form.quantity, {'attr': {'class': 'center-text'}, 'empty_value': '1'}) }}
            {{ form_widget(form._token) }}
            <br>
            <br>
            {% if sylius_is_restricted(product) %}
            <button disabled="disabled" class="btn btn-success btn-lg btn-block"><i class="icon-shopping-cart icon-white icon-large"></i> {{ 'sylius.product_not_available_in_zone'|trans }}</button>
            {% else %}
                <button type="submit" class="btn btn-success btn-lg btn-block"><i class="icon-shopping-cart icon-white icon-large"></i> {{ 'sylius.add_to_cart'|trans }}</button>
            {% endif %}
        {% endif %}
    </div>
</form>
</div>

<hr />

<div>
    {% for association in product.associations %}
        {% if association.associatedObjects|length > 0 %}
            <h3>{{ association.type.name }}</h3>
            <hr />
            {{ list(association.associatedObjects) }}
        {% endif %}
    {% endfor %}
</div>

<hr />

<div>
    <h3>{{ 'sylius.review.header'|trans }}</h3>
{'fraction_non_alphanumeric': 0.16764872063927677, 'fraction_numerical': 0.004762289127451772, 'mean_word_length': 1.672562553925798, 'pattern_counts': {'":': 0, '<': 227, '<?xml version=': 0, '>': 232, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4156403', 'n_tokens_mistral': 3821, 'n_tokens_neox': 3480, 'n_words': 624}