Code Duplication    Length = 25-25 lines in 2 locations

Components/ProductToShop.php 2 locations

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