【发布时间】:2012-12-03 02:23:29
【问题描述】:
编辑:所以this thread 的一个人说如下: “Magento 中的所有订单数据都是特定于产品的。它不存储有关产品所属类别的任何信息。因此,正如您所发现的,Magento 中没有关于此类事情的报告。” 这是真的?我正在努力做的事情是失败的吗?
我正在尝试在 Magento 的后端销售 > 订单 > 特定订单视图 > 信息 > 已订购商品网格中显示产品类别。这不是您在导航到“销售”>“订单”时看到的主要“订单网格”。我想更改您在单击第一个网格中的特定订单后看到的更详细的内容。
根据this thread 的建议,我创建了一个新专栏并为其指定了正确的标题(类别)。
然后,为了尝试填充该列,我将 this thread 上的 Joost de Valk 解决方案中的代码添加到 app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
我觉得我应该接近(或不接近),但目前该代码只是返回单词“Array”。有什么想法吗?
我当前的代码如下。有问题的列是第二个 td - 与 $cats 相呼应的那个:
<?php $_item = $this->getItem() ?>
// Here is the snippet I pasted in to define variables.
<?php $product = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIds();
foreach ($cats as $category_id) {
$_cat = Mage::getModel('catalog/category')->load($category_id) ;
echo $_cat->getName();
} ?>
<?php $this->setPriceDataObject($_item) ?>
<tr<?php if (!$this->canDisplayGiftmessage()): ?> class="border"<?php endif; ?>>
<td>
<?php if ($this->canDisplayContainer()): ?>
<div id="<?php echo $this->getHtmlId() ?>" class="item-container">
<?php endif; ?>
<div class="item-text">
<?php echo $this->getColumnHtml($_item, 'name') ?>
</div>
<?php if ($this->canDisplayContainer()): ?>
</div>
<?php endif ?>
</td>
// Here is the column in question.
<td class="a-center"><?php echo $cats ?></td>
<td class="a-center"><?php echo $_item->getStatus() ?></td>
<td class="a-right"><?php echo $this->displayPriceAttribute('original_price') ?></td>
etc, etc, etc ...
【问题讨论】:
-
<td class="a-center"><?php echo $cats ?></td>->$cats是一个数组。你到底想从中得到什么? -
感谢您的回复。好吧,我最终想要产品类别。但我对 php 很陌生,所以我什至不确定我定义的变量 ($cats = $product->getCategoryIds() 等) 是否包含我需要的信息......我猜 Magento 中没有标准调用产品类别?