gpt4 book ai didi

image - Magento:在订单电子邮件中显示产品图像

转载 作者:行者123 更新时间:2023-12-03 04:23:39 27 4
gpt4 key购买 nike

为了在订单电子邮件中显示产品图片,我在 template/email/order/items/order/default.phtml 中编写了以下代码

<?php 
$_product = Mage::getModel('catalog/product')
->setStoreId($_item->getOrder()->getStoreId())
->load($_item->getProductId());
?>
<img src="<?php echo Mage::helper('catalog/image')
->init($_product, 'image')
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepFrame(FALSE)
->resize(50,50); ?>"
alt="<?php echo $_item->getName() ?>" />

效果很好。它在订单电子邮件中显示调整大小的产品图像。

但是,我有一个问题。

The product image is fetched from media/catalog/product/cache directory. And, if we Flush Images Cache from Magento Admin (System > Cache Management) then the product image which was displayed before is not displayed in order email. It’s because flushing image cache will clear all cache images from media/catalog/product/cache directory.

这个问题的合适解决方案是什么?在订单电子邮件中显示产品图片是个好主意吗?

最佳答案

试试这个:

<img src="<?php echo Mage::getModel('catalog/product_media_config')
->getMediaUrl($_product->getThumbnail()); ?>"
alt="<?php echo $_item->getName() ?>" />

您可以使用 getSmallImage()、getThumbnail() 来获取产品的不同图像。

关于image - Magento:在订单电子邮件中显示产品图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12328302/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com