diff --git a/vendor/wyomind/dynamiccategory/Model/ResourceModel/ReplaceParent.php b/vendor/wyomind/dynamiccategory/Model/ResourceModel/ReplaceParent.php
index d85b212..597f052 100644
--- a/vendor/wyomind/dynamiccategory/Model/ResourceModel/ReplaceParent.php
+++ b/vendor/wyomind/dynamiccategory/Model/ResourceModel/ReplaceParent.php
@@ -27,12 +27,71 @@ class ReplaceParent extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
      */
     public function getItems($ids = [])
     {
-        $table = $this->getTable('catalog_product_relation');
-        $parentIds = $this->getConnection()->fetchPairs(
+        $parentIds = [];
+        /* start TCS customize query */
+	$table = $this->getTable('catalog_product_relation');
+
+	if($ids){
+        /*$parentIds = $this->getConnection()
+            ->fetchAll($this->getConnection()
+            ->select()
+	    ->from($table, ['DISTINCT(parent_id)'])->where('child_id IN (?)', $ids));*/
+	$connection = $this->getConnection();
+
+	// TCS removed the bundle product from parent product
+        $select_qry = "select distinct(parent_id) from catalog_product_relation
+inner join catalog_product_entity on catalog_product_relation.parent_id = catalog_product_entity.row_id  and type_id != 'bundle'
+where child_id in (".implode(",",$ids).")";
+	$parentIds = $connection->fetchAll($select_qry);
+
+        if ($parentIds)
+        {
+            foreach ($parentIds as $key => $result)
+            {
+                foreach ($result as $value)
+                {
+                    $parent[] = $value;
+                }
+            }
+            $parentIds = $parent;
+            /* end TCS customize query */
+
+            //comment original query
+            /*$parentIds = $this->getConnection()->fetchPairs(
             $this->getConnection()->select()
                         ->from($table, ['child_id', 'parent_id'])
                         ->where('child_id IN (?)', $ids)
-        );
-        return array_map('intval', $parentIds);
+            );
+            return array_map('intval', $parentIds);*/
+
+            //TCS patch start
+            //$parentIds = array_map('intval', $parentIds);print_r($parentIds);exit;
+            // convert row_id into entity_id
+            $a = [];
+            foreach ($parentIds as $key => $value)
+            {
+                $a[] = $value;
+            } //print_r($a);
+            if ($a)
+            {
+                $tableName = $this->getTable('catalog_product_entity');
+                $query = 'SELECT row_id,entity_id FROM ' . $tableName . ' WHERE row_id in (' . implode(', ', $a) . ')';
+                $ids = $this->getConnection()
+                    ->fetchAll($query);
+                $b = [];
+                foreach ($ids as $id)
+                {
+                    $b[$id['row_id']] = $id['entity_id'];
+                }
+                foreach ($parentIds as $key => $value)
+                {
+                    $parentIds[$key] = $b[$value];
+                }
+            }
+	}
+	}
+        return $parentIds;
+        //TCS patch end
+
     }
 }
