Frage

I am trying to retrieve the SKU of the first simple product of configurable product as soon as a certain SKU type is found to be "configurable" type. The code below helps find out if the main SKU is configurable or not. I need to find out the SKU of the first simple product of this configurable product. Please advice.

if($_product->getTypeId() == 'configurable'){
 echo 'This is a configurable product';
 // I need to retrieve the SKU of the first simple product for this configurable product and return the SKU
}else{
 echo 'This is not a configurable product';
}
War es hilfreich?

Lösung

You should be able to use this:

$_product->getTypeInstance()->getUsedProductCollection($_product)->getFirstItem()->getSku()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top