1

I have used module-sales/view/frontend/templates/email/items/order/ default.html

<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

/** @var $block \Magento\Sales\Block\Order\Email\Items\DefaultItems */

/** @var $_item \Magento\Sales\Model\Order\Item */
$_item = $block->getItem();
$_order = $_item->getOrder();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
?>
<tr>
<td class="item-info<?php if ($block->getItemOptions()): ?> has-extra<?php endif; ?>">
    <p class="product-name"><?= $block->escapeHtml($_item->getName()) ?></p>
    <p class="product-name"><?= $block->escapeHtml($_item->getName()) ?></p>
    <p class="sku"><?= /* @escapeNotVerified */  __('SKU'); ?>: <?= $block->escapeHtml($block->getSku($_item)) ?></p>
    <?php if ($block->getItemOptions()): ?>
        <dl class="item-options">
        <?php foreach ($block->getItemOptions() as $option): ?>
            <dt><strong><em><?= /* @escapeNotVerified */  $option['label'] ?></em></strong></dt>
            <dd>
                <?= /* @escapeNotVerified */  nl2br($option['value']) ?>
            </dd>
        <?php endforeach; ?>
        </dl>
    <?php endif; ?>
    <?php $addInfoBlock = $block->getProductAdditionalInformationBlock(); ?>
    <?php if ($addInfoBlock) :?>
        <?= $addInfoBlock->setItem($_item)->toHtml() ?>
    <?php endif; ?>
    <?= $block->escapeHtml($_item->getDescription()) ?>
</td>
<td>
    <?php
        $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProductId());

    $imageHelper  = $objectManager->get('\Magento\Catalog\Helper\Image');

    $image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getFile())->resize(100, 100)->getUrl();
    ?>
    <img src="<?php echo $image_url; ?>">
</td>
<td class="item-qty"><?= /* @escapeNotVerified */  $_item->getQtyOrdered() * 1 ?></td>
<td class="item-price">
    <?= /* @escapeNotVerified */  $block->getItemPrice($_item); ?>
</td>
</tr>
<?php if ($_item->getGiftMessageId() && $_giftMessage = $this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessage($_item->getGiftMessageId())): ?>
<tr>
<td colspan="3" class="item-extra">
    <table class="message-gift">
        <tr>
            <td>
                <h3><?= /* @escapeNotVerified */  __('Gift Message') ?></h3>
                <strong><?= /* @escapeNotVerified */  __('From:'); ?></strong> <?= $block->escapeHtml($_giftMessage->getSender()) ?>
                <br /><strong><?= /* @escapeNotVerified */  __('To:'); ?></strong> <?= $block->escapeHtml($_giftMessage->getRecipient()) ?>
                <br /><strong><?= /* @escapeNotVerified */  __('Message:'); ?></strong>
                <br /><?= $block->escapeHtml($_giftMessage->getMessage()) ?>
            </td>
        </tr>
    </table>
</td>
</tr>
<?php endif; ?>

and in items.phtml i have used

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php $_order = $block->getOrder() ?>
<?php if ($_order): ?>
    <?php $_items = $_order->getAllItems(); ?>
    <table class="email-items">
        <thead>
            <tr>
                <th class="item-info">
                    <?= /* @escapeNotVerified */  __('Items'); ?>
                </th>
                <th class="item-qty">
                    <?= /* @escapeNotVerified */  __('Qty'); ?>
                </th>
                <th class="item-qty">
                    <?= /* @escapeNotVerified */  __('Image'); ?>
                </th>
                <th class="item-price">
                    <?= /* @escapeNotVerified */  __('Price'); ?>
                </th>
            </tr>
        </thead>
        <?php foreach ($_items as $_item): ?>
            <?php
                if ($_item->getParentItem()) {
                    continue;
                }
            ?>
            <tbody>
                <?= $block->getItemHtml($_item) ?>
            </tbody>
        <?php endforeach; ?>
        <tfoot class="order-totals">
            <?= $block->getChildHtml('order_totals') ?>
        </tfoot>
    </table>
        <?php if ($this->helper('Magento\GiftMessage\Helper\Message')->isMessagesAllowed('order', $_order, $_order->getStore()) && $_order->getGiftMessageId()): ?>
        <?php $_giftMessage = $this->helper('Magento\GiftMessage\Helper\Message')->getGiftMessage($_order->getGiftMessageId()); ?>
        <?php if ($_giftMessage): ?>
            <br />
            <table class="message-gift">
                <tr>
                    <td>
                        <h3><?= /* @escapeNotVerified */  __('Gift Message for this Order') ?></h3>
                        <strong><?= /* @escapeNotVerified */  __('From:'); ?></strong> <?= $block->escapeHtml($_giftMessage->getSender()) ?>
                        <br /><strong><?= /* @escapeNotVerified */  __('To:'); ?></strong> <?= $block->escapeHtml($_giftMessage->getRecipient()) ?>
                        <br /><strong><?= /* @escapeNotVerified */  __('Message:'); ?></strong>
                        <br />
    <?=    $block->escapeHtml($_giftMessage->getMessage()) ?>
                    </td>
                </tr>
            </table>
        <?php endif; ?>
    <?php endif; ?>
<?php endif; ?>

when seeing my confirmation mail iam getting below image: enter image description here

i want to show product thumbnail and product url in order-confirmation mail but its showing blank as in image shown above.kindly help?

0

There is no such type of order detail in default order template. You can achieve this from just a block calling from email and pass the order variable in that block and put your order detail :

in order email template just use this to call block

{{block class="Magento\Framework\View\Element\Template" order=$order name="order_sms" template="[vendor]_[module]::[filename].phtml" area="frontend"}}

And in your [vendor]/[module]/[frontend]/[templates]/[filename].phtml

$order = $this->getData('order');

After this you can perform your calculation and write your html here.

  • can you please explain in detail sir?I just want product thumbnail and product url(when user click it will go to product page) in order confirmation mail...if you explain in brief and step by step..iam a newbie to magento and i have to complete this task by tomorrow itself so kindly help me iam using magento 2.1.3 – Yogesh Raghav Feb 22 '17 at 14:24
  • its still unclear for me. i need to edit default.phtml file in order to get product thumbnail and product url in order-confirmation mail.. – Yogesh Raghav Feb 22 '17 at 16:05

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.