简体   繁体   English

在success.phtml中显示Magento自定义(是/否)属性值

[英]Show Magento custom (yes/no) Attribute value in success.phtml

In a Magento webstore I am creating people can order PDF products which they will receive by email. 在Magento网站商店中,我创建的人可以订购将通过电子邮件接收的PDF产品。 An external system will handle these emails, this isn't part of the Magento store. 外部系统将处理这些电子邮件,这不是Magento商店的一部分。 On the success.phtml page I'd like to add a message for the customer if he/she has ordered a PDF product saying something like "thanks for ordering, you should get the product in your inbox soon". 如果客户订购了PDF产品,我想在success.phtml页上向客户添加一条消息,上面写着“感谢订购,您应该尽快将产品放入收件箱”。

I'm using the following code to get info on the order: 我正在使用以下代码获取有关订单的信息:

$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);

$items = $order->getAllVisibleItems();
$itemcount=count($items);

foreach ($items as $itemId => $item)
{
    echo 'itemcount: '.$itemcount.'<br />';
    echo 'itemname: '.$item->getName().'<br />';
    echo 'itemprice: '.$item->getPrice().'<br />';
    echo 'itemsku: '.$item->getSku().'<br />';
    echo 'id: '.$item->getProductId().'<br />';
    echo 'qty: '.$item->getQtyToInvoice().'<br />';
    echo 'pdf: '.$item->getData('pdf_ticket');
}

Everything gets put on the success page, except for my custom attribute pdf_ticket . 除了我的自定义属性pdf_ticket之外,所有内容都放置在成功页面上。 I've also tried getPdfTicket() . 我也尝试过getPdfTicket() The attribute is a Yes/No attribute. 该属性是是/否属性。 After this works I should be able to do something like if($pdf == 'Yes'){ echo 'thanks!...' } 完成这项工作后,我应该能够执行类似if($pdf == 'Yes'){ echo 'thanks!...' }

I've found an answer that worked for me by Thomas Nielsen. 我找到了Thomas Nielsen对我有用的答案。 Question > 问题>

$custom = Mage::getModel('catalog/product')->load($item->getProductId());
echo $custom->getAttributeText('pdf_ticket');

I'm not really sure WHY this works. 我不太确定为什么会这样。 So if anyone could clarify this for me, it would be great! 因此,如果有人可以为我澄清这一点,那就太好了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM