第一种方法:
if ($product->getTypeId() == Configurable::TYPE_CODE) {
$childrenList = $product->getTypeInstance()
->getUsedProducts($product);
foreach ($childrenList as $children) {
$skuList[] = $children->getSku();
}
}第二种方法:
$linkManagement = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\ConfigurableProduct\Api\LinkManagementInterface::class);
if ($product->getTypeId() == Configurable::TYPE_CODE) {
$childrenList = $linkManagement->getChildren($product->getSku());
foreach ($childrenList as $children) {
$skuList[] = $children->getSku();
}
}以上就是 magento 2 获取 Configurable 产品的子产品的方法。