Override Mage_Adminhtml_Block_Sales_Items_Column_Name Block
-
31-10-2019 - |
Question
I'm trying to add an extra data to the file:
/app/design/adminhtml/default/ad02/template/downloadable/sales/items/column/downloadable/name.phtml
Target idea: provide a link with a href="....":
<?php if ($this->getLinks()): ?>
<dl class="item-options">
<dt><?php echo $this->getLinksTitle(); ?></dt>
<?php foreach ($this->getLinks()->getPurchasedItems() as $_link): ?>
<dd>
<a title="Download" href="<?php echo $_link->getLinkHref() ?>">
<?php echo $_link->getLinkTitle() ?>
</a> (<?php echo $_link->getNumberOfDownloadsUsed() . ' / ' . ($_link->getNumberOfDownloadsBought()?$_link->getNumberOfDownloadsBought():Mage::helper('downloadable')->__('U')) ?>)</dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
<?php echo $this->htmlEscape($_item->getDescription()) ?>
I suppose to do that by extending a related Magento Block with a new method getLinkHref()(see above). This is current Block Class contents:
class Mage_Downloadable_Block_Adminhtml_Sales_Items_Column_Downloadable_Name extends Mage_Adminhtml_Block_Sales_Items_Column_Name
{
protected $_purchased = null;
public function getLinks()
{
$this->_purchased = Mage::getModel('downloadable/link_purchased')
->load($this->getItem()->getOrder()->getId(), 'order_id');
$purchasedItem = Mage::getModel('downloadable/link_purchased_item')->getCollection()
->addFieldToFilter('order_item_id', $this->getItem()->getId());
$this->_purchased->setPurchasedItems($purchasedItem);
return $this->_purchased;
}
public function getLinksTitle()
{
if ($this->_purchased && $this->_purchased->getLinkSectionTitle()) {
return $this->_purchased->getLinkSectionTitle();
}
return Mage::getStoreConfig(Mage_Downloadable_Model_Link::XML_PATH_LINKS_TITLE);
}
/* I want to insert this method */
public function getLinksHref()
{
return 'http://google.com/'
}
}
But. I don't want to edit the original file but I want to override this Block Class. And actually the question is how to Override this block?
My Module's config.xml
<?xml version="1.0"?> <config>
<modules>
<AD_DownloadablesGeneratedLink>
<version>1.0.0</version>
</AD_DownloadablesGeneratedLink>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<order_items>AD_DownloadablesGeneratedLink_Block_Adminhtml_Sales_Items_Column_Downloadable_Name</order_items>
</rewrite>
</adminhtml>
<AD_DownloadablesGeneratedLink>
<class>AD_DownloadablesGeneratedLink_Block</class>
</AD_DownloadablesGeneratedLink>
</blocks>
</global>
Thank you so much for you help in advance!
P.S. v1.4.0.1
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange