Skip to content

Commit

Permalink
fix: delete logo if already exists before carrier creation
Browse files Browse the repository at this point in the history
  • Loading branch information
PoulainMaxime committed Aug 28, 2024
1 parent 1f26035 commit d4feb12
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Adapter/Carrier/CommandHandler/AddCarrierHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function handle(AddCarrierCommand $command): CarrierId
$carrierId = $this->carrierRepository->add($carrier, $command->getAssociatedShopIds());
$carrier->setGroups($command->getAssociatedGroupIds());

// To verify if image is already upload before creation
if (file_exists(_PS_SHIP_IMG_DIR_ . $carrierId->getValue() . '.jpg')) {
$this->carrierLogoFileUploader->deleteOldFile($carrierId->getValue());
}

if ($command->getLogoPathName() !== null) {
$this->carrierValidator->validateLogoUpload(
$command->getLogoPathName()
Expand Down

0 comments on commit d4feb12

Please sign in to comment.