Code Duplication    Length = 25-25 lines in 2 locations

Components/ProductToShop.php 2 locations

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