Skip to content

Commit a34aeb6

Browse files
authored
INT-179: Add option to disable Web Components per sales channel
Add option to disable Web Components per sales channel
1 parent 0c68a29 commit a34aeb6

22 files changed

Lines changed: 319 additions & 179 deletions

File tree

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
->setRules([
2222
'@PSR2' => true,
2323
'@PSR12' => true,
24-
'@PHP74Migration:risky' => true,
24+
'@PHP7x4Migration:risky' => true,
2525
'@Symfony' => true,
2626
'array_syntax' => ['syntax' => 'short'],
2727
'binary_operator_spaces' => [

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22
## Unreleased
3+
### Add
4+
- Add possibility to disable Web Components integration per sales channel
5+
36
### Change
47
- Upgrade Web Components version to v5.1.7
58
- Add template to suggest element

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ store cache in order the new applied configuration to start working.
111111
* Server URL - FACT-Finder® instance url
112112
**Note:** Server URL should contain a used protocol: (e.g. `https://`) and should end with an
113113
endpoint ( `fact-finder` )
114-
* Channel - Channel you want to serve data from
114+
* Channel - Channel you want to serve data from. This field works for each sales channel separately, so you can, for example, adjust FactFinder integration to different store's language versions.
115115
* API key - your FACT-Finder® API key
116116

117117
You can check if the above data is correctly set by clicking on the `Test Connection` button. Please save your settings before clicking on button.
@@ -123,6 +123,13 @@ You can find more information about what Field Roles are in (Web Components docu
123123
**Note:**
124124
Updating process is ran for all sales channels, no need to run it separately for each of them
125125

126+
#### Disable FactFinder Web Components option
127+
128+
This option allows you to disable FACT-Finder® Web Components integration on the frontend. It works for each sales channel separately so you can use our plugin only on the sales channels you want.
129+
130+
**Note:** If you enable this option, FACT-Finder® integration on the frontend will stop working. Pay special attention not to define FACT-Finder® category pages for sales channels where you enable this option, as this will cause an error on the page or incorrect generation of HTML code
131+
132+
126133
## Advanced Settings
127134

128135
![Advanced Settings](docs/assets/advanced-settings.png "Advanced Settings")
@@ -462,6 +469,17 @@ Plugin implements a list of given Web Components:
462469
* ff-checkout-tracking
463470

464471

472+
## Sales channels management
473+
474+
The entire plugin configuration must be placed in `All Sales Channels`:
475+
476+
![sales-channels-management.png](docs/assets/sales-channels-management.png)
477+
478+
There are only two fields that can be defined for each sales channel separately:
479+
480+
- `Channel` - you can define different data comes from FACT-Finder®, especially in the case of multi-language stores
481+
- `Disable FactFinder Web Components on frontend?` - allows you to disable FACT-Finder® Web Components integration on the frontend. With this option you can use our plugin only on the sales channels you want.
482+
465483
## Modifications Examples
466484

467485
### Adding New Column to Feed

docs/assets/advanced-settings.png

7.02 KB
Loading
19.3 KB
Loading

spec/Storefront/Controller/ResultControllerSpec.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function let(
6767
$this->factfinderLogger = $factfinderLogger;
6868
$this->beConstructedWith($config, $pageLoader, $factfinderLogger);
6969
$requestStack->getCurrentRequest()->willReturn($request);
70+
$salesChannelContext->getSalesChannelId()->willReturn('main_sales_channel');
7071
$container->get('request_stack')->willReturn($requestStack);
7172
$this->request->attributes = $attributes;
7273
$attributes->get(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT)->willReturn($salesChannelContext);
@@ -93,6 +94,7 @@ public function it_should_return_original_response_content_when_ssr_is_not_activ
9394
$this->twig->render('@OmikronFactFinder/storefront/page/factfinder/result.html.twig', Argument::any())->willReturn($content);
9495
$this->seoUrlPlaceholderHandler->replace($content, 'https://shop.com', $this->salesChannelContext)->willReturn($content);
9596
$this->mediaUrlPlaceholderHandler->replace($content)->willReturn($content);
97+
$this->config->disableFFWebc('main_sales_channel')->willReturn(false);
9698
$response = $this->result(
9799
$this->request,
98100
$this->salesChannelContext,

src/Config/Communication.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function getChannel(?string $salesChannelId = null): string
1818
return (string) $this->config('channel', $salesChannelId);
1919
}
2020

21+
public function disableFFWebc(?string $salesChannelId = null): bool
22+
{
23+
return (bool) $this->config('disableFactFinderWebc', $salesChannelId);
24+
}
25+
2126
public function getCredentials(): array
2227
{
2328
return [

src/Domain/RedirectMapping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Omikron\FactFinder\Shopware6\Domain;
66

7-
readonly class RedirectMapping
7+
readonly class RedirectMapping implements \Stringable
88
{
99
public function __construct(private string $data)
1010
{

src/Export/Field/PriceCurrency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
1010
use Shopware\Core\System\Currency\CurrencyEntity;
1111

12-
class PriceCurrency extends Price
12+
class PriceCurrency extends Price implements \Stringable
1313
{
1414
private CurrencyEntity $currency;
1515
private NumberFormatter $numberFormatter;

src/Resources/config/config.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@
5454
<helpText lang="de-DE">Diese Option funktioniert nur, wenn das serverseitige Rendering [SSR] aktiviert ist. Wenn das SSR-Suchergebnis ein Ergebnis enthält, wird es automatisch auf die Produktdetailseite umgeleitet [PDP].</helpText>
5555
</input-field>
5656

57+
<input-field type="bool">
58+
<name>disableFactFinderWebc</name>
59+
<label>Disable FactFinder Web Components on frontend?</label>
60+
<label lang="de-DE">FactFinder-Webkomponenten im Frontend verwenden?</label>
61+
<defaultValue>false</defaultValue>
62+
<helpText>You can disable FactFinder integration on the frontend. This option works for each sales channel separately. Note. If you enable this option, FactFinder integration on the frontend will stop working.</helpText>
63+
<helpText lang="de-DE">Sie können die FactFinder-Integration im Frontend deaktivieren. Diese Option funktioniert für jeden Vertriebskanal separat. Notiz. Wenn Sie diese Option aktivieren, funktioniert die FactFinder-Integration im Frontend nicht mehr.</helpText>
64+
</input-field>
65+
5766
<input-field type="bool">
5867
<name>useProxy</name>
5968
<label>Use Proxy?</label>

0 commit comments

Comments
 (0)