Magento-在“销售订单"视图中显示类别信息 [英] Magento - Display Category information in Sales Orders view

查看:53
本文介绍了Magento-在“销售订单"视图中显示类别信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此此线程中的一个人说:"Magento中的所有订单数据都是特定于产品的.它不存储有关产品所属类别的任何信息.因此,正如您所发现的那样,Magento中没有针对此类情况的报告."这是真的?我正在尝试做一个失落的事业吗?

So a guy in this thread says the following: "All order data in Magento is product-specific. It doesn't store anything about what category the products are in. So, as you have found out, there are no reports available in Magento for that sort of thing." Is this true? Is what I am trying to do a lost cause?

我试图在Magento的后端销售">订单">特定订单视图">信息">已订购商品"网格上显示产品类别.这不是导航到销售">订单"时看到的主要订单网格".我要更改在第一个网格中单击特定顺序后看到的详细信息.

I am trying to display product categories on Magento's backend Sales > Order > specific order view > Information > Items Ordered grid. This is not the main "Orders grid" that you see when navigating to Sales > Order. I want to alter the more detailed one that you see after clicking on a specific order in that first grid.

遵循此线程的建议,我创建了一个新列,并为其指定了适当的标题(类别).

Following advice from this thread, I've made a new column and given it the proper title (Categories).

然后,为尝试填充该列,我在

Then, to try to populate that column, I added code from Joost de Valk's solution on this thread to app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml

我觉得我应该接近(或不应该),但是目前该代码只是返回单词"Array".有什么想法吗?

I feel like I should be close (or not) but currently that code is just returning the word "Array". Any thoughts?

我当前的代码如下.有问题的列是第二个td-呼应$ cats的那个:

My current code is below. The column in question is the second td - the one that echoes $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 ...

推荐答案

$ _ cat 是一个对象

$_cat = Mage::getModel('catalog/category')->load($category_id) ;

<td class="a-center"><?php echo $cats ?></td>

您需要知道要显示哪个属性

You need to know which property you want to display

echo $_cat->getXyz();

例如

echo $_cat->getName();

要查看其中某些属性的列表,请尝试

To see a list of some of it properties try

print_r($_cat->getData());

这篇关于Magento-在“销售订单"视图中显示类别信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆