bi:export, after it finished, failed or was cancelled
Clear caches, notify, monitor
All three live in the namespace Batteryincluded\BatteryincludedBundle\Event.
PreExportEvent
Member
Type
Content
collection
string
Name of the collection, e.g. default
providers
list<DataProviderInterface>
Providers which will be exported
fullImport
bool
false for --provider, nothing is deleted then
dryRun
bool
--dry-run
cancel(string $reason)
Stops the export, nothing is sent, the command exits with 1
isCancelled(), getCancelReason()
useBatteryincluded\BatteryincludedBundle\Event\PreExportEvent;useSymfony\Component\EventDispatcher\Attribute\AsEventListener;#[AsEventListener]finalclassSkipExportDuringImport{publicfunction__construct(privateErpImportState$erpImport){}publicfunction__invoke(PreExportEvent$event):void{if($event->fullImport&&!$event->dryRun&&$this->erpImport->isRunning()){$event->cancel('the ERP import is running, the catalog is incomplete');}}}
DocumentsEvent
Dispatched for every batch before it is sent, the documents can be changed.
Member
Type
Content
getDocuments()
list<AbstractDto>
Documents of the batch
setDocuments(array $documents)
Replaces the documents
collection
string
Name of the collection
context
string
DocumentsEvent::CONTEXT_EXPORT (bi:export) or DocumentsEvent::CONTEXT_SYNC (everything else)
provider
?DataProviderInterface
Provider of the batch during an export, null for a sync
Removed documents are not sent. In a full import they are therefore deleted from the collection, a sync keeps the
version in the collection. A batch without documents is skipped.
useBatteryincluded\BatteryincludedBundle\Event\DocumentsEvent;useBatteryIncludedSdk\Dto\ProductBaseDto;#[AsEventListener]finalclassAddLivePrices{publicfunction__construct(privatePriceApi$prices){}publicfunction__invoke(DocumentsEvent$event):void{$products=array_filter($event->getDocuments(),staticfn($document)=>$documentinstanceofProductBaseDto);// one request for the whole batch instead of one per product$prices=$this->prices->forProducts(array_map(staticfn(ProductBaseDto$product)=>$product->getId(),$products));foreach($productsas$product){$product->setPrice($prices[$product->getId()]??$product->getPrice());}}}
PostExportEvent
Dispatched when bi:export ends after it started exporting: on success, on errors and when a PreExportEvent
listener cancelled it. Invalid options, a declined confirmation and a running export end the command before, without
event.
Member
Type
Content
collection
string
Name of the collection
fullImport
bool
dryRun
bool
successful
bool
Everything was sent (and committed) without rejected documents