Skip to content

Commit 2389da7

Browse files
committed
#24730: Fix Frontend Invoice PDF configured Logo image
1 parent 32ed03c commit 2389da7

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace Magento\Sales\Helper\Invoice;
4+
5+
use Magento\Framework\App\Helper\AbstractHelper;
6+
use Magento\Framework\UrlInterface;
7+
use Magento\Store\Model\ScopeInterface;
8+
9+
class Logo extends AbstractHelper
10+
{
11+
const XML_PATH_SALES_IDENTITY_LOGO_HTML = 'sales/identity/logo_html';
12+
13+
protected $logoBaseDir = 'sales/store/logo_html/';
14+
15+
/**
16+
* @return string|null
17+
*/
18+
public function getLogoFile()
19+
{
20+
$result = null;
21+
22+
$invoiceLogoPath = $this->getIdentityLogoHtml();
23+
if ($invoiceLogoPath) {
24+
$result = $this->_urlBuilder->getBaseUrl(
25+
['_type' => UrlInterface::URL_TYPE_MEDIA]
26+
) . $this->getLogoBaseDir() . $invoiceLogoPath;
27+
}
28+
29+
return $result;
30+
}
31+
32+
/**
33+
* @return string
34+
*/
35+
public function getLogoBaseDir()
36+
{
37+
return $this->logoBaseDir;
38+
}
39+
40+
/**
41+
* @param null|int|string $store
42+
* @return mixed
43+
*/
44+
public function getIdentityLogoHtml($store = null)
45+
{
46+
return $this->scopeConfig->getValue(
47+
self::XML_PATH_SALES_IDENTITY_LOGO_HTML,
48+
ScopeInterface::SCOPE_STORE,
49+
$store
50+
);
51+
}
52+
}

app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
<update handle="print" />
1212
<body>
1313
<attribute name="class" value="account"/>
14+
<referenceContainer name="header-wrapper">
15+
<referenceBlock name="logo">
16+
<arguments>
17+
<argument name="logo_src" xsi:type="helper" helper="Magento\Sales\Helper\Invoice\Logo::getLogoFile"/>
18+
</arguments>
19+
</referenceBlock>
20+
</referenceContainer>
1421
<referenceContainer name="page.main.title">
1522
<block class="Magento\Sales\Block\Order\PrintOrder\Invoice" name="order.status" template="Magento_Sales::order/order_status.phtml" />
1623
<block class="Magento\Sales\Block\Order\PrintOrder\Invoice" name="order.date" template="Magento_Sales::order/order_date.phtml" />

0 commit comments

Comments
 (0)