How is \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::getParentIdsByChild() implemented and used?

Context: How to get the parents (configurable) products for a child (simple) one?

Implementation

ffea3cd/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable.php#L157-L180

/**
 * Retrieve parent ids array by required child
 *
 * @param int|array $childId
 * @return string[]
 */
public function getParentIdsByChild($childId)
{
	$parentIds = [];
	$select = $this->getConnection()
		->select()
		->from(['l' => $this->getMainTable()], [])
		->join(
			['e' => $this->getTable('catalog_product_entity')],
			'e.' . $this->getProductEntityLinkField() . ' = l.parent_id',
			['e.entity_id']
		)->where('l.product_id IN(?)', $childId);

	foreach ($this->getConnection()->fetchAll($select) as $row) {
		$parentIds[] = $row['entity_id'];
	}

	return $parentIds;
}

The single usage

\Magento\ConfigurableProduct\Model\Product\Type\Configurable::getParentIdsByChild()