0

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.

2

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

  • 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. – Craig Mar 20 at 12:17
  • Update getData to getAttributeText (or mention the difference) so I can accept answer. – Craig Mar 20 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.