有人知道如何在交易电子邮件模板中访问 magento 礼品卡 sku 吗?

发布于 2024-10-15 04:16:12 字数 1549 浏览 2 评论 0原文

我有一个自定义实用程序任务,允许用户选择一个图像来伴随礼品卡通知,当在 magento 运行的商店购买礼品卡时,该通知会发送给收件人。在模板中,有各种可用变量,因此您可以自定义发送的电子邮件。但是,为了添加正确的图像,我需要访问礼品卡 sku 编号,因为我的处理方法是简单地创建许多礼品卡并为每张礼品卡应用单独的图像,然后使用 javascript 交换 sku 编号当用户单击图像时。够简单的。

在 app/code/core/Enterprise/GiftCard/Model/Observer.php 文件中,设置了变量:

                $templateData = array(
                    'name'                   => $item->getProductOptionByCode('giftcard_recipient_name'),
                    'email'                  => $item->getProductOptionByCode('giftcard_recipient_email'),
                    'sender_name_with_email' => $sender,
                    'sender_name'            => $senderName,
                    'gift_message'           => $item->getProductOptionByCode('giftcard_message'),
                    'giftcards'              => $codeList->toHtml(),
                    'balance'                => $balance,
                    'is_multiple_codes'      => 1 < $goodCodes,
                    'store'                  => $order->getStore(),
                    'store_name'             => $order->getStore()->getName(), // @deprecated after 1.4.0.0-beta1
                    'is_redeemable'          => $isRedeemable,
                );

因此我可以将产品 sku 添加到此数组中,并且它将在模板系统中可用。问题是,我不知道在哪里可以追溯到甚至不知道如何获取 Sku。我假设它在 $item var 中以某种方式可用,但是 magento 没有关于这种特殊情况的文档,并且我无法猜测,因为没有测试方法。购买卡时会激活电子邮件脚本,因此我不能仅单击“发送测试”按钮来查看发送给用户的电子邮件中显示的内容。预览按钮会忽略变量。

有人知道这件事吗?可能类似于 $item->getSku()

任何输入都有帮助。 谢谢

I had a custom utility task that allowed users to choose an image to accompany the gift card notice that is sent to the recipient when a gift card is purchased at the magento run shop. In the template, there is an assortment of variables available so you can customize the email that is sent. However, in order to add the correct image, I need to have access to the gift card sku number since my method for handling this was to simply create many gift cards and apply separate images for each one, then use javascript to swap the sku numbers when the user clicks the images. Simple enough.

In the app/code/core/Enterprise/GiftCard/Model/Observer.php file, the variables are set:

                $templateData = array(
                    'name'                   => $item->getProductOptionByCode('giftcard_recipient_name'),
                    'email'                  => $item->getProductOptionByCode('giftcard_recipient_email'),
                    'sender_name_with_email' => $sender,
                    'sender_name'            => $senderName,
                    'gift_message'           => $item->getProductOptionByCode('giftcard_message'),
                    'giftcards'              => $codeList->toHtml(),
                    'balance'                => $balance,
                    'is_multiple_codes'      => 1 < $goodCodes,
                    'store'                  => $order->getStore(),
                    'store_name'             => $order->getStore()->getName(), // @deprecated after 1.4.0.0-beta1
                    'is_redeemable'          => $isRedeemable,
                );

So I could add the product sku to this array and it would be available in the template system. Problem is, I don't know where to trace this back to even know how to get the Sku. I assume it is somehow available in the $item var, but magento has no documentation on this particular case and I can't guess since there is no method for testing. The email script is activated when the card is purchased so I can't just click a "Send test" button to see what comes out in the email that is sent to the user. The preview button dismisses variables.

Anyone happen to know about this? Possibly something like $item->getSku()

Any input helps.
Thanks

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

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

发布评论

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

评论(1

爱人如己 2024-10-22 04:16:12

该代码片段来自 Enterprise_GiftCard_Model_Observer::generateGiftCardAccounts() 方法,该方法注册为 sales_order_save_after 事件的处理程序。该事件传递与“新订单”电子邮件相同的“订单”对象。您可以通过更改该电子邮件模板进行实验,并通过从管理中的订单页面重新发送来触发新电子邮件。

$item->getSku() 几乎肯定是正确的。

That snippet is from the method Enterprise_GiftCard_Model_Observer::generateGiftCardAccounts() which is registered as a handler for sales_order_save_after event. That event is passed the same 'order' object as the "new order placed" emails have. You can experiment by altering that email template and triggering a new email by resending from the order page in admin.

$item->getSku() is almost certainly right.

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