Magento 2 – Get Variants of Configurable Products

configurable-productmagento2simple-product

I'm new to Magento2 and finding it difficult to get information.
I'm trying to read simple (variants) products of a configurable product on the view page.

I created my custom block that extends AbstractProduct.

Then I was able to get upsell product ids like this:

$product = $this->_coreRegistry->registry('product');
$upSellProductIds = $product->getUpSellProductIds();

Now, how to get variants(simple products).

In Magento 1.x, I used getUsedProductCollection()

Please help

Best Answer

Try with $product->getTypeInstance()->getUsedProducts($product).