使用 Zend Framework 将自定义图像插入 Magento Invoice 或 Packingslip PDF
我正在尝试将新图像插入到我的 Magento 发票或装箱单中,并且我找到了以下代码:(来自 /app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php)
protected function insertLogo(&$page, $store = null)
{
$image = Mage::getStoreConfig('sales/identity/logo', $store);
if ($image) {
$image = Mage::getStoreConfig('system/filesystem/media', $store) . '/sales/store/logo/' . $image;
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, 25, 758, 170, 860);
}
}
//return $page;
}
我制作了一个复制到我的本地文件夹 /app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php 这是我试图修改的文件。我尝试了各种方法来指向我服务器上的文件(不是通过管理员上传,只是通过 FTP),但我无法让它指向另一个文件 - 它只是拒绝创建 PDF 或不执行任何操作...
这就是我到目前为止的情况:
$image = Mage::getStoreConfig('system/filesystem/media/Chris-Sig.gif');
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, $x, $y, $x+30, $y+15);
}
有什么想法吗?
I am trying to insert a new image into my Magento invoice or packing slip, and I have found this code: (from /app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php)
protected function insertLogo(&$page, $store = null)
{
$image = Mage::getStoreConfig('sales/identity/logo', $store);
if ($image) {
$image = Mage::getStoreConfig('system/filesystem/media', $store) . '/sales/store/logo/' . $image;
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, 25, 758, 170, 860);
}
}
//return $page;
}
I have made a copy in my local folder of /app/code/core/Mage/Sales/Model/Order/Pdf/Shipment.php which is the file i am trying to modify. I have tried various methods to point to a file i have on my server (not uploaded through the admin, just via FTP) but i can not get it to point to another file - it just refuses to create PDF or does nothing...
this is where I am at so far:
$image = Mage::getStoreConfig('system/filesystem/media/Chris-Sig.gif');
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, $x, $y, $x+30, $y+15);
}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了让
Mage::getStoreConfig('system/filesystem/media/Chris-Sig.gif')
正常工作,需要有一个名为system/filesystem/media/Chris-Sig.gif 的设置
,这不是文件位置。尝试这个更简单但不可配置的代码片段:当您确信它可以工作时,您可以尝试配置设置。
For
Mage::getStoreConfig('system/filesystem/media/Chris-Sig.gif')
to work there needs to be a setting calledsystem/filesystem/media/Chris-Sig.gif
, that is not a file location. Try this simpler but non-configurable snippet:When you're confident it works you can experiment with configuration settings.