Skip to content

Commit 3048eba

Browse files
committed
INT-285: Add Recently viewed component
Add Recently viewed component
1 parent 3128fb7 commit 3048eba

8 files changed

Lines changed: 101 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
## Unreleased
33
### Add
44
- Add support for PHP 8.4
5+
- Add Recently viewed component
6+
7+
### Change
8+
- Upgrade Web Components version to v5.2.1
59

610
## [v6.5.2] - 2026.03.02
711
### Add

src/Config/Communication.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function getFactFinderFeatures(): array
7878
'useSimilarProducts' => (bool) $this->config('useSimilarProducts'),
7979
'usePushedProductsCampaigns' => (bool) $this->config('usePushedProductsCampaigns'),
8080
'usePopularSearches' => (bool) $this->config('usePopularSearches'),
81+
'useRecentlyViewed' => (bool) $this->config('useRecentlyViewed'),
8182
];
8283
}
8384
}

src/Resources/config/config.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@
157157
<label>Popular searches</label>
158158
<defaultValue>true</defaultValue>
159159
</input-field>
160+
161+
<input-field type="bool">
162+
<name>useRecentlyViewed</name>
163+
<label>Recently Viewed Products</label>
164+
<defaultValue>false</defaultValue>
165+
</input-field>
160166
</card>
161167

162168
<card>

src/Resources/public/ff-web-components/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/public/ff-web-components/default-styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ ff-similar-products {
274274
}
275275

276276

277+
/* ---- ff-recently-viewed ---- */
278+
279+
ff-recently-viewed {
280+
display: block;
281+
}
282+
283+
277284
/* ---- ff-onfocus-suggest ---- */
278285

279286
ff-onfocus-suggest {
@@ -727,6 +734,13 @@ ff-slider .ffw-slider-button-right {
727734
transform: translate(0, -50%);
728735
}
729736

737+
/* Hidden visibility is important to take nested elements out of the tabindex chain when group is collapsed.
738+
`display:none` cannot be used because it breaks the recalculation of the slider's position. */
739+
ff-asn-group .ffw-wrapper:not([opened]),
740+
ff-asn-group-slider .ffw-wrapper:not([opened]) {
741+
visibility: hidden;
742+
}
743+
730744
ff-asn-remove-all-filters {
731745
display: inline-block;
732746
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{% block component_factfinder_recently_viewed %}
2+
<ff-recently-viewed wait-for-update>
3+
<h3>Recently viewed:</h3>
4+
5+
<ff-record-list subscribe="false" class="row grid-row grid-view">
6+
<template data-role="record">
7+
<ff-record class="cms-listing-col col-sm-6 col-lg-4 col-xl-3">
8+
<div class="card product-box box-standard">
9+
<div class="card-body">
10+
<div class="product-image-wrapper">
11+
<a class="product-image-link is-standard" title="{{ '{{Name}}' }}"
12+
data-redirect="{{ '{{Deeplink}}' }}" data-anchor="{{ '{{Deeplink}}' }}"
13+
data-redirect-target="_self">
14+
<img class="product-image is-standard" data-image="{{ '{{ImageUrl}}' }}"
15+
alt="{{ '{{Name}}' }}" title="{{ '{{Name}}' }}"/>
16+
</a>
17+
</div>
18+
<div class="product-info">
19+
<a class="product-name stretched-link" title="{{ '{{Name}}' }}" data-redirect-target="_self"
20+
data-redirect="{{ '{{Deeplink}}' }}" data-anchor="{{ '{{Deeplink}}' }}">
21+
{{ '{{Name}}' }}
22+
</a>
23+
<div class="product-description">{{ '{{Description}}' }}</div>
24+
<div class="product-price-info">
25+
<p class="product-price">{{ '{{ $ Price}}' }} *</p>
26+
</div>
27+
<div class="product-action">
28+
<div class="d-grid">
29+
<a class="btn btn-light btn-detail" title="{{ '{{Name}}' }}" data-redirect-target="_self"
30+
data-redirect="{{ '{{Deeplink}}' }}" data-anchor="{{ '{{Deeplink}}' }}">
31+
{{ 'listing.boxProductDetails'|trans|sw_sanitize }}
32+
</a>
33+
</div>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
38+
</ff-record>
39+
</template>
40+
</ff-record-list>
41+
</ff-recently-viewed>
42+
{% endblock %}

src/Resources/views/storefront/element/cms-element-product-description-reviews.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@
3535
} %}
3636
{% endif %}
3737

38+
{% if page.extensions.factfinder.features.useRecentlyViewed %}
39+
{% sw_include '@Parent/storefront/components/factfinder/recently_viewed.html.twig' %}
40+
{% endif %}
41+
3842
</div>
3943
{% endblock %}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% sw_extends '@Storefront/storefront/page/product-detail/meta.html.twig' %}
2+
3+
{% block layout_head_canonical %}
4+
{{ parent() }}
5+
6+
7+
{% if page.extensions.factfinder.features.useRecentlyViewed and page.product %}
8+
{% set product = page.product %}
9+
10+
<script>
11+
document.addEventListener(`ffCoreReady`, ({ factfinder }) => {
12+
factfinder.components.recentlyViewed.config({
13+
maxLength: 5,
14+
});
15+
16+
factfinder.components.recentlyViewed.addEntry({
17+
Name: '{{ product.translated.name|escape('js') }}',
18+
Master: '{{ product.productNumber|escape('js') }}',
19+
ProductNumber: '{{ product.productNumber|escape('js') }}',
20+
Deeplink: '{{ seoUrl('frontend.detail.page', {'productId': product.id})|escape('js') }}',
21+
Price: {{ product.calculatedPrice.unitPrice|default(0) }},
22+
ImageUrl: '{{ product.cover.media.url|escape('js') }}'
23+
});
24+
});
25+
</script>
26+
{% endif %}
27+
28+
29+
{% endblock %}

0 commit comments

Comments
 (0)