Code Duplication    Length = 14-25 lines in 7 locations

Bootstrap/Update.php 7 locations

@@ 479-493 (lines=15) @@
476
        }
477
    }
478
479
    private function recreateRemoteCategoriesAndProductAssignments()
480
    {
481
        if (version_compare($this->version, '1.1.4', '<=')) {
482
            try {
483
                $this->db->query('INSERT INTO `s_plugin_connect_config` (`name`, `value`) VALUES ("recreateConnectCategories", "0")');
484
            } catch (\Exception $e) {
485
                // ignore it if exists
486
                $this->logger->write(
487
                    true,
488
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
489
                    $e->getMessage()
490
                );
491
            }
492
        }
493
    }
494
495
    private function setDefaultConfigForUpdateOrderStatus()
496
    {
@@ 495-509 (lines=15) @@
492
        }
493
    }
494
495
    private function setDefaultConfigForUpdateOrderStatus()
496
    {
497
        if (version_compare($this->version, '1.1.7', '<=')) {
498
            try {
499
                $this->db->query('INSERT INTO `s_plugin_connect_config` (`name`, `value`, `groupName`) VALUES ("updateOrderStatus", "0", "import")');
500
            } catch (\Exception $e) {
501
                // ignore it if exists
502
                $this->logger->write(
503
                    true,
504
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
505
                    $e->getMessage()
506
                );
507
            }
508
        }
509
    }
510
511
  /**
512
     * Create index by articleID in s_plugin_connect_product_to_categories table.
@@ 514-528 (lines=15) @@
511
  /**
512
     * Create index by articleID in s_plugin_connect_product_to_categories table.
513
     */
514
    private function addProductToCategoryIndex()
515
    {
516
        if (version_compare($this->version, '1.1.7', '<=')) {
517
            try {
518
                $this->db->query('ALTER TABLE s_plugin_connect_product_to_categories ADD INDEX article_id(articleID)');
519
            } catch (\Exception $e) {
520
                // ignore it if exists
521
                $this->logger->write(
522
                    true,
523
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
524
                    $e->getMessage()
525
                );
526
            }
527
        }
528
    }
529
530
    private function addShopIdToConnectCategories()
531
    {
@@ 571-587 (lines=17) @@
568
        }
569
    }
570
571
    private function changeExportStatusToVarchar()
572
    {
573
        if (version_compare($this->version, '1.1.8', '<=')) {
574
            try {
575
                $this->db->query('ALTER TABLE s_plugin_connect_items MODIFY export_status varchar(255)');
576
                $this->db->query('ALTER TABLE s_plugin_connect_items ADD INDEX IDX_revision (revision)');
577
                $this->db->query('ALTER TABLE s_plugin_connect_items ADD INDEX IDX_status (export_status)');
578
            } catch (\Exception $e) {
579
                // ignore it if exists
580
                $this->logger->write(
581
                    true,
582
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
583
                    $e->getMessage()
584
                );
585
            }
586
        }
587
    }
588
589
    private function addArticleRelationsTable()
590
    {
@@ 589-613 (lines=25) @@
586
        }
587
    }
588
589
    private function addArticleRelationsTable()
590
    {
591
        if (version_compare($this->version, '1.1.8', '<=')) {
592
            try {
593
                $this->db->query('CREATE TABLE IF NOT EXISTS `s_plugin_connect_article_relations` (
594
                  `id` int(11) NOT NULL AUTO_INCREMENT,
595
                  `article_id` int(11) unsigned NOT NULL,
596
                  `shop_id` int(11) NOT NULL,
597
                  `related_article_local_id` int(11) NOT NULL,
598
                  `relationship_type` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
599
                  PRIMARY KEY (`id`),
600
                  UNIQUE KEY `relations` (`article_id`, `shop_id`, `related_article_local_id`, `relationship_type`),
601
                  CONSTRAINT s_plugin_connect_article_relations_fk_article_id FOREIGN KEY (article_id) REFERENCES s_articles (id) ON DELETE CASCADE
602
                  ) ENGINE = InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
603
                );
604
            } catch (\Exception $e) {
605
                // ignore it if exists
606
                $this->logger->write(
607
                    true,
608
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
609
                    $e->getMessage()
610
                );
611
            }
612
        }
613
    }
614
615
    private function addOverwriteMainImage()
616
    {
@@ 615-630 (lines=16) @@
612
        }
613
    }
614
615
    private function addOverwriteMainImage()
616
    {
617
        if (version_compare($this->version, '1.1.8', '<=')) {
618
            try {
619
                $this->db->query('INSERT INTO `s_plugin_connect_config` (`name`, `value`, `groupName`) VALUES ("overwriteProductMainImage", "1", "import")');
620
                $this->db->query('ALTER TABLE `s_plugin_connect_items` ADD COLUMN `update_main_image` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL');
621
            } catch (\Exception $e) {
622
                // ignore it if exists
623
                $this->logger->write(
624
                    true,
625
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
626
                    $e->getMessage()
627
                );
628
            }
629
        }
630
    }
631
632
    private function changeGroupNameImportSettings()
633
    {
@@ 632-645 (lines=14) @@
629
        }
630
    }
631
632
    private function changeGroupNameImportSettings()
633
    {
634
        if (version_compare($this->version, '1.1.11', '<=')) {
635
            try {
636
                $this->db->query('UPDATE `s_plugin_connect_config` SET `groupName` = "import" WHERE `groupName` = "general" AND `name` IN ("createCategoriesAutomatically", "activateProductsAutomatically", "createUnitsAutomatically")');
637
            } catch (\Exception $e) {
638
                $this->logger->write(
639
                    true,
640
                    sprintf('An error occurred during update to version %s stacktrace: %s', $this->version, $e->getTraceAsString()),
641
                    $e->getMessage()
642
                );
643
            }
644
        }
645
    }
646
}
647