Skip to content

Commit 2063bfb

Browse files
authored
FFWEB-3430: Add cart button in record list
Add cart button in record list
1 parent acff9ae commit 2063bfb

12 files changed

Lines changed: 124 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## Unreleased
3+
### Add
4+
- Add to cart button for record list
5+
26
## [v7.0.0] - 2025.07.23
37
### BREAKING
48
- IMPORTANT! Drop Shopware 6.6 compatibility

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ This section contains a plugin configuration, which is optional and provides add
133133
details about implementation [here](#enrich-data-received-from-fact-finder-in-proxycontroller).
134134
Note: Sending each request to FACT-Finder instance trough Shopware, you lose on performance as each request need to be handled first by HTTP server and then, by Shopware itself. This additional traffic could be easily avoided by not activating this feature if there's no clear reason to use it.
135135

136+
* Add cart button - select this option if you want the Add to cart button on the product list
136137
* Scenario how to count single click on "Add to cart" button
137138
* Redirect mapping for selected queries - put each pair `query=url` in separate row. If the phrase appears twice, the first one from the top of the list will be taken. Url can be relative path `/some/page` or absolute url `https://domain.com/some/page?someParameter=1`. If provided pair has an invalid format then it will be ignored.
138139

spec/Subscriber/ConfigurationSubscriberSpec.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function it_will_return_factfinderchannel_for_specific_sales_channel_id(
6868
$communication->getApiKey()->willReturn('abc-123');
6969
$communication->isSsrActive()->willReturn(false);
7070
$communication->isProxyEnabled()->willReturn(false);
71+
$communication->isCartBtnEnabled()->willReturn(false);
7172
$communication->getFactFinderFeatures()->willReturn([]);
7273
$communication->getChannel('main_sales_channel')->willReturn('some_ff_channel');
7374
$communication->getFieldRoles(Argument::any())->willReturn([]);
@@ -115,6 +116,7 @@ public function it_will_add_page_extension_for_storefront_render_event(
115116
$communication->getApiKey()->willReturn('abc-123');
116117
$communication->isSsrActive()->willReturn(false);
117118
$communication->isProxyEnabled()->willReturn(false);
119+
$communication->isCartBtnEnabled()->willReturn(false);
118120
$event->getRequest()->willReturn($request);
119121
$request->get('_route', Argument::any())->willReturn('factfinder');
120122
$request->getLocale()->willReturn('en');
@@ -157,6 +159,7 @@ public function it_will_throw_exception_when_event_does_not_have_page(
157159
$communication->getApiKey()->willReturn('abc-123');
158160
$communication->isSsrActive()->willReturn(false);
159161
$communication->isProxyEnabled()->willReturn(false);
162+
$communication->isCartBtnEnabled()->willReturn(false);
160163
$event->getRequest()->willReturn($request);
161164
$request->get('_route', Argument::any())->willReturn('factfinder');
162165
$request->getLocale()->willReturn('en');

src/Config/Communication.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public function isSsrPdpEnabled(): bool
6161
return (bool) $this->config('useSsrPdp');
6262
}
6363

64+
public function isCartBtnEnabled(): bool
65+
{
66+
return (bool) $this->config('addCartBtn');
67+
}
68+
6469
public function getFactFinderFeatures(): array
6570
{
6671
return [

src/Resources/app/storefront/dist/storefront/js/omikron-fact-finder/omikron-fact-finder.js

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

src/Resources/app/storefront/dist/storefront/js/omikron-fact-finder/omikron-fact-finder.offcanvas-filter.plugin.8e362a.js

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

src/Resources/config/config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
<helpText lang="de-DE">Mit Proxy können Sie die von FACT-Finder zurückkommenden Daten innerhalb des SDK-Codes verfeinern. Weitere Informationen finden Sie in der Dokumentation.</helpText>
6363
</input-field>
6464

65+
<input-field type="bool">
66+
<name>addCartBtn</name>
67+
<label>Add Cart button for product list</label>
68+
<label lang="de-DE">Schaltfläche „In den Warenkorb“ für die Produktliste</label>
69+
<defaultValue>false</defaultValue>
70+
</input-field>
71+
6572
<input-field type="single-select">
6673
<name>trackingAddToCartCount</name>
6774
<options>

src/Resources/config/services.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@
142142
<service id="Omikron\FactFinder\Shopware6\Api\UpdateFieldRolesController" />
143143
<service id="Omikron\FactFinder\Shopware6\Api\TestConnectionController" />
144144

145+
<service id="Omikron\FactFinder\Shopware6\Storefront\Controller\AddToCartController" public="true">
146+
<argument type="service" id="Shopware\Core\Checkout\Cart\SalesChannel\CartService"/>
147+
<argument type="service" id="product.repository"/>
148+
<tag name="controller.service_arguments"/>
149+
</service>
150+
145151
<service id="Omikron\FactFinder\Shopware6\MessageQueue\FeedExportHandler">
146152
<tag name="messenger.message_handler" />
147153
</service>

src/Resources/views/storefront/components/factfinder/record.html.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
data-redirect="{{ '{{masterValues.Deeplink}}' }}" data-anchor="{{ '{{masterValues.Deeplink}}' }}">
2626
{{ 'listing.boxProductDetails'|trans|sw_sanitize }}
2727
</a>
28+
29+
{% if page.extensions.factfinder.addCartBtn %}
30+
<a class="btn btn-primary"
31+
href="/fact-finder/cart/add-by-number/{{ '{{variantValues.0.ProductNumber}}' }}"
32+
title="{{ 'listing.boxAddToCart'|trans|sw_sanitize }}">
33+
{{ 'listing.boxAddProduct'|trans|sw_sanitize }}
34+
</a>
35+
{% endif %}
2836
</div>
2937
</div>
3038
</div>

src/Resources/views/storefront/layout/factfinder/suggest.html.twig

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{% block layout_search_suggest %}
22
<div class="search-suggest js-search-result">
33
<ff-suggest layout="list" unresolved>
4+
{% block layout_search_suggest_popular_searches %}
5+
<template data-role="popularSearches">
6+
<div class="ff-popular-searches">
7+
<h3>{{ "ff.suggest.PopularSearches"|trans }}</h3>
8+
<div data-template>{{ '{{name}}' }} </div>
9+
</div>
10+
</template>
11+
{% endblock %}
12+
413
{% block layout_search_suggest_result_suggest_container %}
514
<section class="ff-suggest-container row pb-4">
6-
<template data-role="popularSearches">
7-
<div class="ff-popular-searches">
8-
<h3>{{ "ff.suggest.PopularSearches"|trans }}</h3>
9-
<div data-template>{{ '{{name}}' }} </div>
10-
</div>
11-
</template>
12-
1315
<div data-container="searchTerm" class="col">
1416
<h3 class="h5 container-caption">{{ 'ff.suggest.SearchTerms'|trans|striptags }}</h3>
1517
<ff-suggest-item type="searchTerm">

0 commit comments

Comments
 (0)