1

I'm currently attempting to override the following file in order to add the color attribute to the Order Confirmation Email:

vendor/magento/module-sales/view/frontend/templates/email/items/order/default.phtml 

Under the "sku" line, I've created an additional line to display the color of the product (this is the only change I've made to the file):

<p class="product-name"><?= $block->escapeHtml($_item->getName()) ?></p> <p class="sku"><?= /* @escapeNotVerified */ __('SKU') ?>: <?= $block->escapeHtml($block->getSku($_item)) ?></p> <p class="color"><?= /* @escapeNotVerified */ __('Color') ?>: <?= $block->escapeHtml($block->getColor($_item)) ?></p> 

Having tested the email, I can see the label "Color" being output, However it's not returning the actual value.

1
  • what was your eventual code please... trying to use the below answer but it's still not working for me. Commented Nov 24, 2020 at 16:13

2 Answers 2

3

Item object has a product property that you can retrieve by

 $productcolor = $_item->getProduct()->getAttributeText('color'); 

Make sure that $_item is instance of Magento\Sales\Model\Order\Item

2
  • This appears to output a value now, but the value is a number instead of the actual color. I've tried a couple of different attributes with similar results. Commented Mar 20, 2019 at 12:17
  • Update getData to getAttributeText (or mention the difference) so I can accept answer. Commented Mar 20, 2019 at 12:20
0

Example to get the article information Country of Manufacture inside the shipment mail

<?php $product = $_item->getOrderItem()->getProduct(); ?> <?= $product->getCountryOfManufacture(); ?> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.