Code Duplication    Length = 25-25 lines in 2 locations

Components/ProductToShop.php 2 locations

@@ 1624-1648 (lines=25) @@
1621
     */
1622
    private function deleteRemovedRelations($articleId, $product)
1623
    {
1624
        if (count($product->related) > 0) {
1625
            $this->manager->getConnection()->executeQuery(
1626
                'DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND related_article_local_id NOT IN (?) AND relationship_type = ?',
1627
                [$articleId, $product->shopId, $product->related, self::RELATION_TYPE_RELATED],
1628
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR]
1629
            );
1630
1631
            $oldRelatedIds = $this->manager->getConnection()->executeQuery(
1632
                'SELECT ar.id 
1633
                FROM s_articles_relationships AS ar
1634
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1635
                WHERE ar.articleID = ? AND ci.shop_id = ? AND ci.source_id NOT IN (?)',
1636
                [$articleId, $product->shopId, $product->related],
1637
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY]
1638
            )
1639
                ->fetchAll(\PDO::FETCH_COLUMN);
1640
        } else {
1641
            $this->manager->getConnection()->executeQuery(
1642
                'DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND relationship_type = ?',
1643
                [$articleId, $product->shopId, self::RELATION_TYPE_RELATED]
1644
            );
1645
1646
            $oldRelatedIds = $this->manager->getConnection()->executeQuery(
1647
                'SELECT ar.id 
1648
                FROM s_articles_relationships AS ar
1649
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1650
                WHERE ar.articleID = ? AND ci.shop_id = ?',
1651
                [$articleId, $product->shopId]
@@ 1662-1686 (lines=25) @@
1659
            [\Doctrine\DBAL\Connection::PARAM_INT_ARRAY]
1660
        );
1661
1662
        if (count($product->similar) > 0) {
1663
            $this->manager->getConnection()->executeQuery(
1664
                'DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND related_article_local_id NOT IN (?) AND relationship_type = ?',
1665
                [$articleId, $product->shopId, $product->similar, self::RELATION_TYPE_SIMILAR],
1666
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY, \PDO::PARAM_STR]
1667
            );
1668
1669
            $oldSimilarIds = $this->manager->getConnection()->executeQuery(
1670
                'SELECT ar.id 
1671
                FROM s_articles_similar AS ar
1672
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1673
                WHERE ar.articleID = ? AND ci.shop_id = ? AND ci.source_id NOT IN (?)',
1674
                [$articleId, $product->shopId, $product->similar],
1675
                [\PDO::PARAM_INT, \PDO::PARAM_INT, \Doctrine\DBAL\Connection::PARAM_INT_ARRAY]
1676
            )
1677
                ->fetchAll(\PDO::FETCH_COLUMN);
1678
        } else {
1679
            $this->manager->getConnection()->executeQuery(
1680
                'DELETE FROM s_plugin_connect_article_relations WHERE article_id = ? AND shop_id = ? AND relationship_type = ?',
1681
                [$articleId, $product->shopId, self::RELATION_TYPE_SIMILAR]
1682
            );
1683
1684
            $oldSimilarIds = $this->manager->getConnection()->executeQuery(
1685
                'SELECT ar.id 
1686
                FROM s_articles_similar AS ar
1687
                INNER JOIN s_plugin_connect_items AS ci ON ar.relatedarticle = ci.article_id
1688
                WHERE ar.articleID = ? AND ci.shop_id = ?',
1689
                [$articleId, $product->shopId]