Code Duplication    Length = 14-25 lines in 8 locations

Bootstrap/Update.php 8 locations

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