1

When viewing an order, my employees would like to be able to click on the product's name or SKU, and for that to be a link to that product's Product Info edit page.

I figured out how to change the product name into a link, with that link being the url of the product page on Front End, but I don't want the link going to the front end, I need it to link to the products edit page in Admin Dashboard.

This is the code I used in:

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

<div class="item-text">
<?php $_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>
<a target="_blank" rel="external" href="<?php echo Mage::getUrl() . $_pullProduct->getData('url_path'); ?>"><?php echo $this->getColumnHtml($_item, 'name') ?></a>
</div>

...and this properly links me to the product frontend page. Now, as I said, that's not what I want, so how do I get this to be a link to the product's admin dashboard edit page?

I attempted at changing the above code in the same file to:

<div class="item-text">
<?php $_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>
<a target="_blank" rel="external" href="<?php echo Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/catalog_product/edit', array('id' => $this->getProduct()->getId()))?>"><?php echo $this->getColumnHtml($_item, 'name') ?></a>
</div>

...however that's not right, and the Order View page breaks when I try this. I feel like I'm getting close, can any of you help me in the right direction, please?

3

This should work:

<div class="item-text">
<?php $_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>
<a target="_blank" rel="external" href="<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array('id' => $_pullProduct->getId()))?>"><?php echo $this->getColumnHtml($_item, 'name') ?></a>
</div>
| improve this answer | |
  • This worked perfectly! Thanks so much. Man, now that I've got this working, I had an employee say he'd like to see this same type of link on the product names within Order Create, in the Search Grid of "Items Ordered". I was hoping I could reuse this same code. I looked in app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search/Grid/Renderer/Product.php , but can't figure out where to add this url code. Any idea how I'd make this happen? I accepted your answer btw! Yay! Thanks again! – stephen wise May 6 '13 at 20:46
  • @Marius how to load product in admin means Mage::getModel('catalog/product')->loadByAttribute('sku', Mage::registry('mymodule')->getData('sku')); is not working – Keyur Shah Dec 21 '13 at 10:20
  • @KeyurShah. 'not working' it's kind of a large area. Narrow it down a little. Also, ask a different question. There is no point to discuss this in an other question comments. – Marius Dec 21 '13 at 11:50
  • after using your method in magento 1.9.1.1 the order page goes blank. is there any solution for it? – عثمان غني Oct 15 '15 at 7:03
0
<?php $_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>
<a target="_blank" rel="external" href="<?php echo Mage::getUrl() . $_pullProduct->getData('url_path'); ?>"><?php echo $this->getColumnHtml($_item, 'name') ?></a>
            <?php $_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getData('sku')); ?>         
<a target="_blank" rel="external" href="<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array('id' => $_pullProduct->getId()))?>"><?php echo $this->getColumnHtml($_item, 'qty') ?></a>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.