Magento电子邮件模板:$ _item - > getDescription返回null

时间:2012-06-05 15:49:37

标签: magento email templates

项目

修改Magento的电子邮件模板以包含长描述

Magento版本

1.6.2.0

正在编辑的文件

app/design/frontend/default/<template name>/template/email/order/items/order/default.phtml

此文件中包含行号的感兴趣的代码:

31 <strong style="font-size:11px;"><?php echo $this->htmlEscape($_item->getName()) ?></strong>
46 <?php echo $this->escapeHtml($_item->getDescription()) ?>

问题

$ _ item - &gt; getName()有效,但 $ _ item - &gt; getDescription()返回null

调试

Zend转储 $ _ item (显示“name”定义;“description”为null):

array(79) {
["item_id"] => string(3) "584"
["order_id"] => string(3) "398"
["parent_item_id"] => NULL
["quote_item_id"] => string(4) "1951"
["store_id"] => string(1) "1"
["created_at"] => string(19) "2012-06-04 14:15:39"
["updated_at"] => string(19) "2012-06-04 14:16:18"
["product_id"] => string(3) "156"
["product_type"] => string(6) "simple"
["product_options"] => string(140) "a:1:{s:15:"info_buyRequest";a:3:{s:4:"uenc";s:48:"aHR0cDovL2Rldi5hcHBvZ2VlLmNvbS9iYXNlL21hYy5odG1s";s:7:"product";s:3:"156";s:3:"qty";i:1;}}"
["weight"] => string(6) "0.0100"
["is_virtual"] => string(1) "0"
["sku"] => string(9) "MC969LL/A"
["name"] => string(21) "11" MacBook Air 128GB"
["description"] => NULL
["applied_rule_ids"] => NULL
["additional_data"] => NULL
["free_shipping"] => string(1) "0"
["is_qty_decimal"] => string(1) "0"
["no_discount"] => string(1) "0"
["qty_backordered"] => NULL
["qty_canceled"] => string(6) "0.0000"
["qty_invoiced"] => string(6) "0.0000"
["qty_ordered"] => string(6) "1.0000"
["qty_refunded"] => string(6) "0.0000"
["qty_shipped"] => string(6) "1.0000"
["base_cost"] => NULL
["price"] => string(9) "1199.0000"
["base_price"] => string(9) "1199.0000"
["original_price"] => string(9) "1199.0000"
["base_original_price"] => string(9) "1199.0000"
["tax_percent"] => string(6) "7.0000"
["tax_amount"] => string(7) "83.9300"
["base_tax_amount"] => string(7) "83.9300"
["tax_invoiced"] => string(6) "0.0000"
["base_tax_invoiced"] => string(6) "0.0000"
["discount_percent"] => string(6) "0.0000"
["discount_amount"] => string(6) "0.0000"
["base_discount_amount"] => string(6) "0.0000"
["discount_invoiced"] => string(6) "0.0000"
["base_discount_invoiced"] => string(6) "0.0000"
["amount_refunded"] => string(6) "0.0000"
["base_amount_refunded"] => string(6) "0.0000"
["row_total"] => string(9) "1199.0000"
["base_row_total"] => string(9) "1199.0000"
["row_invoiced"] => string(6) "0.0000"
["base_row_invoiced"] => string(6) "0.0000"
["row_weight"] => string(6) "0.0100"
["base_tax_before_discount"] => NULL
["tax_before_discount"] => NULL
["ext_order_item_id"] => NULL
["locked_do_invoice"] => NULL
["locked_do_ship"] => NULL
["price_incl_tax"] => string(9) "1282.9300"
["base_price_incl_tax"] => string(9) "1282.9300"
["row_total_incl_tax"] => string(9) "1282.9300"
["base_row_total_incl_tax"] => string(9) "1282.9300"
["hidden_tax_amount"] => NULL
["base_hidden_tax_amount"] => NULL
["hidden_tax_invoiced"] => NULL
["base_hidden_tax_invoiced"] => NULL
["hidden_tax_refunded"] => NULL
["base_hidden_tax_refunded"] => NULL
["is_nominal"] => string(1) "0"
["tax_canceled"] => NULL
["hidden_tax_canceled"] => NULL
["tax_refunded"] => NULL
["gift_message_id"] => NULL
["gift_message_available"] => string(1) "0"
["base_weee_tax_applied_amount"] => string(6) "0.0000"
["base_weee_tax_applied_row_amnt"] => string(6) "0.0000"
["base_weee_tax_applied_row_amount"] => string(6) "0.0000"
["weee_tax_applied_amount"] => string(6) "0.0000"
["weee_tax_applied_row_amount"] => string(6) "0.0000"
["weee_tax_applied"] => string(6) "a:0:{}"
["weee_tax_disposition"] => string(6) "0.0000"
["weee_tax_row_disposition"] => string(6) "0.0000"
["base_weee_tax_disposition"] => string(6) "0.0000"
["base_weee_tax_row_disposition"] => string(6) "0.0000"
}

问题

为什么描述为null?

我发现在下订单后更改产品名称不会更改订单中的名称,因此订单对象似乎在订购的产品上有自己的数据,该数据与实时目录分开(我认为这是有道理的:你希望这些信息是静态的,不可改变的。)

由于数据库中浪费的空间,每次订购时都不会尝试存储项目的长描述和/或简短描述。但为什么要将描述字段包括在内以留空?

我唯一的方法是获取该信息以加载目录/产品模型,找到我想要的产品和属性(like here)?

1 个答案:

答案 0 :(得分:4)

你的一切都是正确的。我不知道他们为什么包含description字段,但在我的所有250,000个订单中都是空的。

您可以通过以下方法获取说明:

$_description = Mage::getModel('catalog/product')
    ->load($_item->getProductId())
    ->getDescription();

如果产品已被删除,这很可能会返回null