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
-
Refer magento.stackexchange.com/questions/106922/…– JacksonCommented Sep 16, 2016 at 7:15
-
i tried that but not working for me– Ramkishan SutharCommented Sep 16, 2016 at 7:18
Add a comment
|
1 Answer
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
-
-
-
It's not working :( i put this header.html which included in my custom email template ? Commented Sep 16, 2016 at 10:11
-
1Try
<img src="{{view url='Magento_Email/logo_email.png'}}" height="30" width="30" alt="{{trans 'Logo'}}" />
. Commented Sep 16, 2016 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 ? Commented Sep 16, 2016 at 10:42