Skip to content

Commit eda1dde

Browse files
authored
Merge pull request #313 from damonsson/2.0
performance optimization
2 parents 4bb0415 + 50c68a3 commit eda1dde

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

config/packages/sylius_twig_hooks.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,24 @@ sylius_twig_hooks:
4949
homepage_metatags:
5050
template: "shop_metatags.html.twig"
5151
priority: 150
52+
53+
'sylius_shop.homepage.index':
54+
banner:
55+
template: '@SyliusShop/homepage/banner.html.twig'
56+
priority: 300
57+
latest_deals:
58+
component: 'sylius_shop:product:list'
59+
props:
60+
limit: 4
61+
template: '@SyliusShop/product/common/list.html.twig'
62+
configuration:
63+
title: 'sylius.homepage.latest_deals'
64+
test_attribute: 'latest-deals'
65+
priority: 200
66+
latest_products:
67+
component: 'sylius_shop:product:list'
68+
props:
69+
limit: 8
70+
template: '@SyliusShop/homepage/latest_products.html.twig'
71+
priority: 0
72+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="container mb-6">
2+
<h2 class="mb-5">{{ hookable_metadata.configuration.title|default('sylius.ui.latest_products')|trans }}</h2>
3+
4+
<div {{ sylius_test_html_attribute(hookable_metadata.configuration.test_attribute|default('latest-products')) }}>
5+
<div class="products-grid">
6+
{% for product in latest_products %}
7+
<div>{{ component('sylius_shop:product:card', { product: product, template: '@SyliusShop/homepage/product_card.html.twig' }) }}</div>
8+
{% endfor %}
9+
</div>
10+
</div>
11+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="container mb-6">
2+
<div class="mb-5">
3+
<h2>{{ 'sylius.homepage.new_collection'|trans }}</h2>
4+
</div>
5+
6+
<div class="photo-grid">
7+
{% for i in [1, 2, 3] %}
8+
<div class="photo-grid-item-{{ i }}">
9+
<img
10+
src="{{ asset('build/shop/images/homepage-new-collection-photo-' ~ i ~ '.webp', 'shop') }}"
11+
class="object-fit-cover w-100 h-100 rounded-3" loading="lazy"
12+
alt="{{ 'sylius.homepage.new_collection'|trans }}">
13+
</div>
14+
{% endfor %}
15+
</div>
16+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div {{ sylius_test_html_attribute('product', '%s'|format(product.code)) }} >
2+
<a class="link-reset" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}" {{ sylius_test_html_attribute('product-content') }}>
3+
<div class="mb-4">
4+
<div class="overflow-auto bg-light rounded-3" style="aspect-ratio: 3/4; ">
5+
{{ component('sylius_shop:main_image', {
6+
product: product,
7+
class: "w-100 h-100 object-fit-cover",
8+
loading: 'lazy',
9+
filter: 'sylius_shop_product_small_thumbnail'
10+
}) }}
11+
</div>
12+
</div>
13+
<div class="h6 text-break" {{ sylius_test_html_attribute('product-name', product.name) }}>
14+
{{ product.name }}
15+
</div>
16+
</a>
17+
<div>
18+
{% if not product.enabledVariants.empty() %}
19+
{{ component('sylius_shop:catalog_promotions', { variant: variant, appliedPromotions: applied_promotions, withDescription: false }) }}
20+
{{ component('sylius_shop:product:card:price', { variant: variant, template: '@SyliusShop/product/common/price.html.twig' }) }}
21+
{% endif %}
22+
</div>
23+
</div>

0 commit comments

Comments
 (0)