Skip to content

Get Child Item In Shipment Email Template

I am trying to retrieve the Child Item of a Configurable Details in the Shipment email.

I have overwritten the default template file in my theme at:
app/code/design/MyTheme/theme/Magento_Sales/templates/email/items/order/default.phtml

I did this in the Order Confirmation email using $product = $_item->getProduct(). I’m unable to use this in the shipment email.

This snippet is how I retrieve Child Product Details in my Order Confirmation Template:

$_item = $block->getItem();
$_order = $_item->getOrder();
$product = $_item->getProduct();

// Normal Products
$productId = $product->getId();
$productName = $product->getName();
$productUrl = $product->getProductUrl();
$productSku = $product->getSku();

// Configurable Child Item Details
  foreach($_item->getChildrenItems() as $item){
    $product = $item->getProduct();
    $productId = $product->getId();
    $productName = $product->getName();
    $productUrl = $product->getProductUrl();
    $productSku = $product->getSku();
  }

This does not work in the Shipment email.

I see the table sales_shipment_item includes the Child Item in the name column. Can I retrieve this from there?

Thank you