Add a product link in admin order view

Many times it would be convenient to be able to quickly check a product on the frontend while we’re viewing the order detail in the backend order view.

There are many ways to accomplish this, such as adding new columns to the order item grid etc but here’s a quick and simple way to accomplish the same results without adding any additional block code or xml.

Locate:  app/design/adminhtml/default/template/sales/order/view/renderer/default.phtml

(note: keep an original copy as you’re modifying the default template and could get overwritten during upgrades)

make the following change by adding the section highlighted:


<?php $_item = $this->getItem() ?>
<?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 ?>

<?php // this section can be placed in any column ?>

<?php $_linkProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>
<br><br><a target="_blank" href="<?php echo Mage::getUrl() . $_linkProduct->getData('url_path'); ?>">[LINK]</a>

<?php // end of product link ?>
</td>

<td class="a-center"><?php echo $_item->getStatus() ?></td>
<td class="a-right"><?php echo $this->displayPriceAttribute('original_price') ?>
</td>
<td class="a-right">
<?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
<span class="price-excl-tax">
<?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
<span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
<?php endif; ?>

<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
<?php
echo $this->displayPrices(
$_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
$_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
);
?>
<?php else: ?>
<?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
<?php endif; ?>

The link was added below the item name and sku with a simple LINK name. This was done so that the sku or name information could still be copied and pasted if you’re transferring to another site.

You could replace the ‘LINK’ with actual information from the order detail if you prefer – here’s an example showing the product cost as the link to the item .. any attributes that are in the table ‘sales_flat_order_item’ could be used.


<?php $_linkProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>
<br><br><a target="_blank" href="<?php echo Mage::getUrl() . $_linkProduct->getData('url_path'); ?>">[<?php echo $this->displayPriceAttribute('base_cost') ?>]</a>

Now you’ve accomplished 2 goals – adding a product link AND showing the product cost on the admin order view!

Leave a Reply