Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## Unreleased
### Add
- Add to cart button for record list
- Add automated feed export base on Shopware Scheduled Task

## [v7.0.0] - 2025.07.23
### BREAKING
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,24 @@ Following settings are used for uploading already exported feed to a given FTP/S

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.

## Automatic Export Settings

![automatic-export-settings.png](docs/assets/automatic-export-settings.png)

The plugin provides a configuration section in the administration panel that allows you to enable or disable automatic export and define which sales channel and language should be used for the products export.
By default, the automatic export is disabled. Once the administrator enables it and choose the sales channel and language, the automatic export will be active.
By default, automatic export is performed once every 48 hours. If you want to change this value, you must overwrite the `ExportScheduledTask` file as follows:

//src/ScheduledTask/ExportScheduledTask.php
public static function getDefaultInterval(): int
{
// change this value to adjust the export interval. This value is in seconds.
// for example: 48 hours = 172800
return 172800;
}

Automatic Export is based on Shopware Scheduled Task. For more information, see the [Shopware documentation](https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/add-scheduled-task.html)

## Category Pages

Plugin offers a way to use FACT-Finder® Web Components on category pages using page builder Shopping Experiences. There
Expand Down
Binary file added docs/assets/automatic-export-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions src/Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,37 @@
<name>testApiConnection</name>
</component>
</card>

<card>
<title>Automatic Export Settings</title>
<title lang="de-DE">Einstellungen für automatischen Export</title>
<input-field type="bool">
<name>autoExportEnabled</name>
<label>Enable Automatic Export</label>
<label lang="de-DE">Automatischen Export aktivieren</label>
<helpText>Enable or disable the automatic export feature. More information in the documentation</helpText>
<helpText lang="de-DE">Aktivieren oder deaktivieren Sie die Funktion für den automatischen Export.</helpText>
<defaultValue>false</defaultValue>
</input-field>
<component name="sw-entity-single-select">
<name>autoExportSelectedSalesChannel</name>
<label>Select Sales Channel</label>
<label lang="de-DE">Vertriebskanal auswählen</label>
<helpText>Select the sales channel for automatic export.</helpText>
<helpText lang="de-DE">Wählen Sie den Vertriebskanal für den automatischen Export.</helpText>
<entity>sales_channel</entity>
<placeholder>Select a sales channel...</placeholder>
<placeholder lang="de-DE">Vertriebskanal auswählen...</placeholder>
</component>
<component name="sw-entity-single-select">
<name>autoExportSelectedLanguage</name>
<label>Select Language</label>
<label lang="de-DE">Sprache auswählen</label>
<helpText>Select the language for the export.</helpText>
<helpText lang="de-DE">Wählen Sie die Sprache für den Export des Vertriebskanals.</helpText>
<entity>language</entity>
<placeholder>Select a language...</placeholder>
<placeholder lang="de-DE">Sprache auswählen...</placeholder>
</component>
</card>
</config>
11 changes: 11 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,16 @@
<service id="Omikron\FactFinder\Shopware6\Utilites\Ssr\Template\Engine" />
<service id="Omikron\FactFinder\Shopware6\Config\FieldRolesInterface"
alias="Omikron\FactFinder\Shopware6\Config\FieldRoles" />

<service id="Omikron\FactFinder\Shopware6\ScheduledTask\ExportScheduledTask">
<tag name="shopware.scheduled.task" />
</service>
<service id="Omikron\FactFinder\Shopware6\ScheduledTask\ExportScheduledTaskHandler">
<argument type="service" id="scheduled_task.repository"/>
<argument type="service" id="monolog.logger.factfinder_channel"/>
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService" />
<argument type="service" id="Omikron\FactFinder\Shopware6\MessageQueue\FeedExportHandler" />
<tag name="messenger.message_handler" />
</service>
</services>
</container>
22 changes: 22 additions & 0 deletions src/ScheduledTask/ExportScheduledTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Omikron\FactFinder\Shopware6\ScheduledTask;

use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;

class ExportScheduledTask extends ScheduledTask
{
public static function getTaskName(): string
{
return 'factfinder.auto_export_task';
}

public static function getDefaultInterval(): int
{
// change this value to adjust the export interval. This value is in seconds.
// For example, to set the interval to 48 hours = 172800
return 172800;
}
}
49 changes: 49 additions & 0 deletions src/ScheduledTask/ExportScheduledTaskHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Omikron\FactFinder\Shopware6\ScheduledTask;

use Omikron\FactFinder\Shopware6\Message\FeedExport;
use Omikron\FactFinder\Shopware6\MessageQueue\FeedExportHandler;
use Psr\Log\LoggerInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler(handles: ExportScheduledTask::class)]
class ExportScheduledTaskHandler extends ScheduledTaskHandler
{
public function __construct(
EntityRepository $scheduledTaskRepository,
private readonly LoggerInterface $factfinderLogger,
private readonly SystemConfigService $systemConfig,
private readonly FeedExportHandler $feedExportHandler,
) {
parent::__construct($scheduledTaskRepository, $factfinderLogger);
}

public function run(): void
{
$autoExportEnabled = $this->systemConfig->get('OmikronFactFinder.config.autoExportEnabled');
$salesChannel = $this->systemConfig->get('OmikronFactFinder.config.autoExportSelectedSalesChannel');
$language = $this->systemConfig->get('OmikronFactFinder.config.autoExportSelectedLanguage');

if (!$autoExportEnabled || !$salesChannel || !$language) {
$this->factfinderLogger->info('FactFinder auto export is disabled or not configured properly.');

return;
}

try {
$this->feedExportHandler->__invoke(new FeedExport(
$salesChannel,
$language,
'products'
));
} catch (\Exception $e) {
$this->factfinderLogger->error($e->getMessage());
}
}
}
Loading