Is it possible to add the 'Short Description' to the 'order view' within the 'Sales admin page'. Primarily in the 'items ordered' table so;
[Product][Item Status][Original Price][Price][Qty]…etc
to
[Short Description][Product][Item Status][Original Price][Price][Qty]…etc
This is the screen we'd like to edit.
url/sales_order/view/order_id….
The Short Description exists in a simple product.
If we could also add this functionality to the order grid, that would be great.
We've taken a look at mySQL and the entry exists in 'catalog_product_flat_1' and can probably cobble a custom SELECT query to achieve this but we were wondering if there is a better way?
Thanks in advance.
Best Answer
Editing the back end is the same as editing the front end - you can do anything from customising the templates through to extending the various blocks and models.
I don't have a 1.8 install active right now so this using 1.7.2.
If we trace through from the URL, via the controllers and XML layout files, you'll see that the rows of that table are rendered by the block model
app/code/core/Mage/Adminhtml/Block/Sales/Items/Renderer/Default.php
, using templateapp/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
.$this
in the template of course refers to the block model, and we can see that to render the product's name, it's using$this->getColumnHtml($_item, 'name')
. Looking at the code for that function, we can see it sometimes treats $_item as a sales order item, and looking at the code to see where that comes from, we can see in theMage_Adminhtml_Block_Sales_Order_View_Items
block that it comes from thegetItemsCollection
method called on a sales order model, so it's an actual sales order item model. Often in Magento, a collection will be constructed to contain only sparsely populated objects (in non-Magento terms, imagine a SELECT statement that only selects a few fields), but in this case it at least contains the product ID.Using that
Mage_Sales_Model_Order_Item
object, we can see from that model's code that we can callgetProduct
, giving us a fully loaded product object, and from there we can callgetShortDescription()
.So adding this:
echo $_item->getProduct()->getShortDescription()
somewhere in
app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
will show you the short description.
Tested on 1.7.2
Loading the full product model for each line shown there might be a little slow if the orders contain dozens of lines, but in most cases I expect staff will happily wait an extra second or two for the screen to load. You could optimise it by loading a sparsely populated product collection before rendering all the items... I'll leave that as an exercise to the reader!