Code Duplication    Length = 25-25 lines in 2 locations

Components/ProductToShop.php 2 locations

@@ 1590-1614 (lines=25) @@
1587
     */
1588
    private function deleteRemovedRelations($articleId, $product)
1589
    {
1590
        if (count($product->related) > 0) {
1591
            $this->manager->getConnection()->executeQuery('DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND related_article_local_id NOT IN (?) AND relationship_type = ?',
1592
                [$articleId, $product->shopId, $product->related, self::RELATION_TYPE_RELATED],
1593
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR]);
1594
1595
            $oldRelatedIds = $this->manager->getConnection()->executeQuery(
1596
                'SELECT ar.id 
1597
                FROM s_articles_relationships AS ar
1598
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1599
                WHERE ar.articleID = ? AND ci.shop_id = ? AND ci.source_id NOT IN (?)',
1600
                [$articleId, $product->shopId, $product->related],
1601
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY])
1602
                ->fetchAll(\PDO::FETCH_COLUMN);
1603
        } else {
1604
            $this->manager->getConnection()->executeQuery('DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND relationship_type = ?',
1605
                [$articleId, $product->shopId, self::RELATION_TYPE_RELATED]);
1606
1607
            $oldRelatedIds = $this->manager->getConnection()->executeQuery(
1608
                'SELECT ar.id 
1609
                FROM s_articles_relationships AS ar
1610
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1611
                WHERE ar.articleID = ? AND ci.shop_id = ?',
1612
                [$articleId, $product->shopId])
1613
                ->fetchAll(\PDO::FETCH_COLUMN);
1614
        }
1615
1616
        $this->manager->getConnection()->executeQuery('DELETE FROM s_articles_relationships WHERE id IN (?)',
1617
            [$oldRelatedIds],
@@ 1620-1644 (lines=25) @@
1617
            [$oldRelatedIds],
1618
            [\Doctrine\DBAL\Connection::PARAM_INT_ARRAY]);
1619
1620
        if (count($product->similar) > 0) {
1621
            $this->manager->getConnection()->executeQuery('DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND related_article_local_id NOT IN (?) AND relationship_type = ?',
1622
                [$articleId, $product->shopId, $product->similar, self::RELATION_TYPE_SIMILAR],
1623
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR]);
1624
1625
            $oldSimilarIds = $this->manager->getConnection()->executeQuery(
1626
                'SELECT ar.id 
1627
                FROM s_articles_similar AS ar
1628
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1629
                WHERE ar.articleID = ? AND ci.shop_id = ? AND ci.source_id NOT IN (?)',
1630
                [$articleId, $product->shopId, $product->similar],
1631
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY])
1632
                ->fetchAll(\PDO::FETCH_COLUMN);
1633
        } else {
1634
            $this->manager->getConnection()->executeQuery('DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND relationship_type = ?',
1635
                [$articleId, $product->shopId, self::RELATION_TYPE_SIMILAR]);
1636
1637
            $oldSimilarIds = $this->manager->getConnection()->executeQuery(
1638
                'SELECT ar.id 
1639
                FROM s_articles_similar AS ar
1640
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1641
                WHERE ar.articleID = ? AND ci.shop_id = ?',
1642
                [$articleId, $product->shopId])
1643
                ->fetchAll(\PDO::FETCH_COLUMN);
1644
        }
1645
1646
        $this->manager->getConnection()->executeQuery('DELETE FROM s_articles_similar WHERE id IN (?)',
1647
            [$oldSimilarIds],