Azure and PowerBi configuration
Azure App registration
An app must be registered in Azure for the plugin to communicate with PowerBi.
Go to “App registrations” in Azure and click “New registration”
Name: the name of the app for example the store name
Supported account types
Redirect URL: for example the store URL
Go to “Api permissions” in the created app and click “Add a permission“
Select “Power Bi Service”
Select “Delegated permissions”
The PowerBi plugin only needs “Dataset.ReadWrite.Al” and “Workspace.Read.All” permissions
Click “Add permission”
Now we need to create a “Client secret”. Go to “Certificates & secrets” and click “New client secret”
Note down the “Value”.
PowerBi configuration
In PowerBi service principals must be allowed to use the PowerBi API.
Go to the “Admin portal” under settings.
Under “Tenant settings” search for “Developer settings”
Enable “Allow service principals to use Power BI APIs”
You also need to give the “PowerBi Service (Service Principal)” access for the workspace.
Go to your workspace (not “My Workspace”)
Click “Manage access”
Add “PowerBi Service (Service Principal)”
Add your created App
Installation and configuration
The Plugin can be installed normally like every other Plugin.
Settings
Email Export
Active: activate / deactivate email export
E-Mails: The emails that should get the email separated with a comma
If enabled, the order data will be sent once a day to the configured emails in a csv file.
The first export will export the orders from the current day. After that, the orders from the last execution until now are exported.
PowerBi Configuration (for direct export to PowerBi)
Set Workspace-ID: can be found in Url (for example: https://app.powerbi.com/groups/05asdede0-7cc2-4ad7-8e39-acd73fab27dk )
Dataset Name: choose a dataset name (must not exist in PowerBi)
Dataset ID: leave empty
Order Table Name: choose name for order table in PowerBi dataset
Azure Configuration (for direct export to PowerBi)
Client ID : can be found on overview page of Azure App Registration
Client Secret: above created in Azure App Registration
Tenant ID / Directory ID: can be found on overview page of Azure App Registration
After configuration
After configuration is done run php bin/console powerbi:init. This command will create the dataset und table in PowerBi.
Email Template
After installation, a new email template appears under Settings->Email Templates with the name PowerBi Export Orders Mail
Here you can insert your own text. Important: there are no variables available.
Export Orders to PowerBI
Setting the Date Range
From/To:
- Use the calendar picker to select your start/end date
- This determines the earliest/latest order date to include in the export
- If you want to export all orders leave both empty
Actions
Once you've set your date range, you have three action buttons:
Start Export
- Begins the export process immediately
- Exports all orders within the selected date range
Cancel Export
- Cancels any ongoing export process
- Use this if you need to stop an export in progress
Refresh
- Refreshes the current view
- Updates the interface to show the latest status
Monitoring Progress
Show History
- Click this link to view previous export activities
- See status of completed, failed, or ongoing exports
- Review export logs and timestamps
Troubleshooting
- If an export fails, check the history for error details
- Large date ranges may take longer to process - be patient
- Cancel and restart exports if they seem stuck
- Ensure your PowerBI connection is properly configured before starting exports
Messenger
Make sure all Shopware cron jobs are running.
php bin/console scheduled-task:run
php bin/console messenger:consume async
Technical
Events
EmailExportLineItemEvent
Is called every time a line item is added to a the CSV file.
Example:
public function onLineItemAdd(EmailExportLineItemEvent $event): void
{
$event->addExtension(['custom_name' => $event->getLineItemEntity()->getCustomFields()['test']]);
}
This will add a column to the CSV with the name “custom_name” und the value of the custom field “test“.
BeforeCsvCreatedEvent
Is called before CSV is created finally.
public function beforeCsvCreated(BeforeCsvCreatedEvent $event): void
{
$data = $event->getData();
foreach ($data as $lineItemId => $row) {
$lineItem = $this->lineItemRepository->search(new Criteria([$lineItemId]), Context::createDefaulktContext())->first();
$data[$lineItemId]['custom_name'] = $lineItem->getCustomFields()['test'];
}
$event->setData($data);
}
This will add a column to the CSV with the name “custom_name” und the value of the custom field “test“.
Exported fields
OrderNo
OrderPos
Date
ArticleNumber
ArticleDescription
Amount
Units
Price
User
Segment
Important Classes
Classname // Function
Migration1686394103AddMailTemplate: Create the default email template on installation
ExportOrdersTaskHandler: Export of order data to csv and sending the Email
PowerBiClient: Handles connection to PowerBi
SendOrderHandler: Sends order to PowerBi
Roadmap