<?php
namespace Biloba\IntlTranslationMoreEntities;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class BilobaIntlTranslationMoreEntities extends Plugin
{
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if ($context->keepUserData()) {
return;
}
$connection = $this->container->get(Connection::class);
// Delete all translations when uninstalling the plugin
$connection->exec('DELETE `product_manufacturer_translation` FROM `product_manufacturer_translation` LEFT JOIN `biloba_intl_translation_log` ON `biloba_intl_translation_log`.`entity_id` = `product_manufacturer_translation`.`product_manufacturer_id`
WHERE `biloba_intl_translation_log`.`target_language_id` = `product_manufacturer_translation`.`language_id`');
$connection->exec('DELETE `category_translation` FROM `category_translation` LEFT JOIN `biloba_intl_translation_log` ON `biloba_intl_translation_log`.`entity_id` = `category_translation`.`category_id`
WHERE `biloba_intl_translation_log`.`target_language_id` = `category_translation`.`language_id`');
$connection->exec('DELETE `property_group_translation` FROM `property_group_translation` LEFT JOIN `biloba_intl_translation_log` ON `biloba_intl_translation_log`.`entity_id` = `property_group_translation`.`property_group_id`
WHERE `biloba_intl_translation_log`.`target_language_id` = `property_group_translation`.`language_id`');
$connection->exec('DELETE `product_stream_translation` FROM `product_stream_translation` LEFT JOIN `biloba_intl_translation_log` ON `biloba_intl_translation_log`.`entity_id` = `product_stream_translation`.`product_stream_id`
WHERE `biloba_intl_translation_log`.`target_language_id` = `product_stream_translation`.`language_id`');
$connection->exec('DELETE `mail_template_translation` FROM `mail_template_translation` LEFT JOIN `biloba_intl_translation_log` ON `biloba_intl_translation_log`.`entity_id` = `mail_template_translation`.`mail_template_id`
WHERE `biloba_intl_translation_log`.`target_language_id` = `mail_template_translation`.`language_id`');
}
}