custom/plugins/ProxaImport/src/ProxaImport.php line 10

Open in your IDE?
  1. <?php
  2. namespace ProxaImport;
  3. use Shopware\Core\Framework\Context;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  6. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  7. class ProxaImport extends Plugin
  8. {
  9.     const IMPORT_NAME 'Proxa product import';
  10.     const UPDATE_NAME 'Proxa product update';
  11.     public function activate(ActivateContext $activateContext): void
  12.     {
  13.         $this->makeImport();
  14.     }
  15.     private function makeImport()
  16.     {
  17.         $repo $this->container->get('import_export_profile.repository');
  18.         $upsert = [
  19.             [
  20.                 'id' => md5(self::IMPORT_NAME),
  21.                 'name' => self::IMPORT_NAME,
  22.                 'label' => self::IMPORT_NAME,
  23.                 'sourceEntity' => 'proxa_product',
  24.                 'fileType' => 'text/csv',
  25.                 'delimiter' => ';',
  26.                 'enclosure' => '"',
  27.             ], [
  28.                 'id' => md5(self::UPDATE_NAME),
  29.                 'name' => self::UPDATE_NAME,
  30.                 'label' => self::UPDATE_NAME,
  31.                 'sourceEntity' => 'proxa_product',
  32.                 'fileType' => 'text/csv',
  33.                 'delimiter' => ';',
  34.                 'enclosure' => '"',
  35.             ],
  36.         ];
  37.         $repo->upsert($upsertContext::createDefaultContext());
  38.     }
  39.     public function deactivate(DeactivateContext $deactivateContext): void
  40.     {
  41.         $this->deleteImport();
  42.     }
  43.     private function deleteImport()
  44.     {
  45.         $repo $this->container->get('import_export_profile.repository');
  46.         $repo->delete([
  47.             ['id' => md5(self::IMPORT_NAME)],
  48.             ['id' => md5(self::IMPORT_NAME)],
  49.         ], Context::createDefaultContext());
  50.     }
  51. }