Magento - 如何在交易电子邮件中插入产品图片

发布于 2024-09-30 21:44:28 字数 364 浏览 3 评论 0原文

基本上我想将产品图片包含到订购产品时发送的新订单电子邮件中。

我从 email/order/items/order/default.phtml 开始使用此代码

<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>

如何使用此代码来获取图像?

Mage::helper('catalog/image')->init($_product, 'image')->resize(250)

感谢您的帮助:)

Basically I would like to include the product image to the New Order Email sent when ordering a product.

I started in email/order/items/order/default.phtml with this code

<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>

How do I use this code to fetch the image?

Mage::helper('catalog/image')->init($_product, 'image')->resize(250)

thanks for helping :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

要走干脆点 2024-10-07 21:44:28

因为我很早就找到了答案,所以我应该将其发布在这里以帮助其他有需要的人..:)

<?php //added for sending image with order
        $product = Mage::getModel('catalog/product')
        ->setStoreId($_item->getOrder()->getStoreId())
        ->load($_item->getProductId()); 
    ?>  
        <p align="center"><img src="<?php echo Mage::helper('catalog/image')->init($product, 'image')->resize(50); ?>" width="50" height="50" alt="" /></p>

只需将此片段放在下面

<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>

注意:对于 gmail 用户,不要忘记启用显示图像..:)

希望这会有所帮助!

Since I found the answer early I should post it here to help other s in need.. :)

<?php //added for sending image with order
        $product = Mage::getModel('catalog/product')
        ->setStoreId($_item->getOrder()->getStoreId())
        ->load($_item->getProductId()); 
    ?>  
        <p align="center"><img src="<?php echo Mage::helper('catalog/image')->init($product, 'image')->resize(50); ?>" width="50" height="50" alt="" /></p>

just put this snippet below

<?php $_item = $this->getItem() ?>
<?php $_order = $this->getItem()->getOrder() ?>

NOTE: For gmail users, don't forget to enable Display Image.. :)

Hope this helps!

写给空气的情书 2024-10-07 21:44:28

这也行得通吗?

$product = $_item->getProduct()

Does this also work?

$product = $_item->getProduct()
土豪 2024-10-07 21:44:28

在销售订单电子邮件中获取图像

请查看以下代码:

  1. $_item = $block->getItem();
  2. $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  3. $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProductId());
  4. $imageHelper = $objectManager->get('\Magento\Catalog\Helper\Image');
  5. $image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getFile())->resize(100, 100)->getUrl();

结束添加:


看起来不错!

Get Image in sale order email

Please view below code :

  1. $_item = $block->getItem();
  2. $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  3. $_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProductId());
  4. $imageHelper = $objectManager->get('\Magento\Catalog\Helper\Image');
  5. $image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getFile())->resize(100, 100)->getUrl();

End add : <img src="<?php echo $image_url; ?>" alt="" />


Good look !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文