public function getRelationsByChild($childrenIds)
    {
        $metadata      = $this->getEntityMetaData(\Magento\Catalog\Api\Data\ProductInterface::class);
        $entityTable   = $this->getTable($metadata->getEntityTable());
        $relationTable = $this->getTable('catalog_product_relation');
        $joinCondition = sprintf('relation.parent_id = entity.%s', $metadata->getLinkField());

        $select = $this->getConnection()->select()
            ->from(['relation' => $relationTable], [])
            ->join(['entity' => $entityTable], $joinCondition, [$metadata->getIdentifierField()])
            ->where('child_id IN(?)', array_map('intval', $childrenIds));

        return $this->getConnection()->fetchCol($select);
    }
public function getRelationsByChild($childrenIds)
    {
        $metadata      = $this->getEntityMetaData(\Magento\Catalog\Api\Data\ProductInterface::class);
        $entityTable   = $this->getTable($metadata->getEntityTable());
        $relationTable = $this->getTable('catalog_product_relation');
        $joinCondition = sprintf('relation.parent_id = entity.%s', $metadata->getLinkField());

        $select = $this->getConnection()->select()
            ->from(['relation' => $relationTable], [])
            ->join(['entity' => $entityTable], $joinCondition, [$metadata->getIdentifierField()])
            ->where('child_id IN(?)', array_map('intval', $childrenIds));

        return $this->getConnection()->fetchCol($select);
    }
public function getRelationsByChild ( $ childrenIds ) { $ metadata = $ this -> getEntityMetaData ( \ Magento \ Catalog \ Api \ Data \ ProductInterface :: class ) ; $ entityTable = $ this -> getTable ( $ metadata -> getEntityTable ( ) ) ; $ relationTable = $ this -> getTable ( 'catalog_product_relation' ) ; $ joinCondition = sprintf ( 'relation.parent_id = entity.%s' , $ metadata -> getLinkField ( ) ) ; $ select = $ this -> getConnection ( ) -> select ( ) -> from ( [ 'relation' => $ relationTable ] , [ ] ) -> join ( [ 'entity' => $ entityTable ] , $ joinCondition , [ $ metadata -> getIdentifierField ( ) ] ) -> where ( 'child_id IN(?)' , array_map ( 'intval' , $ childrenIds ) ) ; return $ this -> getConnection ( ) -> fetchCol ( $ select ) ; }
Retrieve products relations by childrens

@param array $childrenIds The product ids being reindexed

@return array
Retrieve products relations by childrens