0

how can i send company logo in custom email templates ? I know that it is placed on header.html in vendor/magento/module-email/view/frontend/email

0

EDIT: We can use block technique. And put it where you want. For example, insert this block in your template:

{{block class='Company\\Module\\Block\\Email\\Logo' 
area='frontend' template='Company_Module::email/logo.phtml'}}

Your custom block:

<?php

namespace Company\Module\Block\Email;

use Magento\Framework\View\Element\Template;

class Logo extends \Magento\Framework\View\Element\Template
{
    protected $logo;

    public function __construct(
        Template\Context $context,
        \Magento\Theme\Block\Html\Header\Logo $logo,
        array $data = []
    )
    {
        $this->logo = $logo;
        parent::__construct($context, $data);
    }

    /**
     * Get logo image URL
     *
     * @return string
     */
    public function getLogoSrc()
    {
        return $this->logo->getLogoSrc();
    }

}

Template: view/templates/email/logo.phtml

<?php
/** @var $block \Company\Module\Block\Email\Logo */
/** @var $this  \Company\Module\Block\Email\Logo*/
?>

<img src="<?php echo $this->getLogoSrc()?>" alt="<?php echo __('Logo Image'); ?>"/>

See more here: vendor/magento/module-sales/view/frontend/email/shipment_new.html

  • In header.html ? – Ramkishan Suthar Sep 16 '16 at 9:59
  • Anywhere you want. – Khoa TruongDinh Sep 16 '16 at 10:00
  • It's not working :( i put this header.html which included in my custom email template ? – Ramkishan Suthar Sep 16 '16 at 10:11
  • Try <img src="{{view url='Magento_Email/logo_email.png'}}" height="30" width="30" alt="{{trans 'Logo'}}" />. – Khoa TruongDinh Sep 16 '16 at 10:21
  • Should i move header.html file and less files (email-inline.less and email.less) in my theme folder under module-email folder ? – Ramkishan Suthar Sep 16 '16 at 10:42

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.