1

I'm trying to find a solution since a couple hours now. Unfortunately without any luck, so I need to ask you for help.

I'm trying to add a download button to a grid which will be provided by an extension. If I'm customize the concerning file in Block/Adminhtml/O directly the button shows up (Add a button to admin grid). But I don't want to customize the extension - I want to overwrite the concerning block. And this is where I got stuck. Nothing happens, it seems there is an issue somewhere but I can't find it.

Here is my code

My confix.xml

<?xml version="1.0"?>
<config>
   <modules>
       <Foo_Quotedownload>
           <version>0.1.0</version>
       </Foo_Quotedownload>
   </modules>
   <global>
      <blocks>
          <rewrite>
  <adminhtml_qquoteadv>Foo_Quotedownload_Block_Adminhtml_Qquoteadv</adminhtml_qquoteadv>
            </rewrite>
      </blocks>
   </global>
</config>

My app/etc/modules/Foo_Quotedownload.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Foo_Quotedownload>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Ophirah_Qquoteadv/>
            </depends>
        </Foo_Quotedownload>
    </modules>   
</config>

The original config.xml from the module (only interesting part)

<blocks>
<qquoteadv>
    <class>Ophirah_Qquoteadv_Block</class>
</qquoteadv>
<checkout>
    <rewrite>
        <onepage_shipping_method_available>Ophirah_Qquoteadv_Block_Checkout_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
    </rewrite>
</checkout>
</blocks>

The original concerning Block

<?php
class Ophirah_Qquoteadv_Block_Adminhtml_Qquoteadv extends    
Mage_Adminhtml_Block_Widget_Grid_Container

My block which lives in Foo/Quotedownload/Block/Adminhtml/Qquoteadv.php

<?php
class Foo_Quotedownload_Block_Adminhtml_Qquoteadv extends   
Ophirah_Qquoteadv_Block_Adminhtml_Qquoteadv {

public function __construct()
{
  echo "works";
  die;  
    $this->_controller = 'adminhtml_qquoteadv';
    $this->_blockGroup = 'qquoteadv';
    $this->_headerText = Mage::helper('qquoteadv')->__('Quotations');
    $this->_addButtonLabel = Mage::helper('sales')->__('Create Neeeew Quote');

           ///////CUSTOM code for new button:
   $data = array(
           'label' =>  'Download Quotes',
           'onclick'   => "setLocation('".$this->getUrl('qquoteadv/adminhtml_qquoteadv/download')."')"
           );
   ///////The URL I am using is a custom module that I set up earlier, Magento parses it to <MySite.com/shop/index.php/downloadtomas>, which then runs the script I have in the IndexController.php file
   Mage_Adminhtml_Block_Widget_Container::addButton('download_to_mas', $data, 0, 100,  'header', 'header');
   ///////End CUSTOM code


    parent::__construct();
}

Does anyone know what I'm doing wrong here? Thank you so much in advance.

3

I think that you are missing the block node for the original extension you are rewriting in your config.xml. Try this:

<?xml version="1.0"?>
<config>
    <modules>
        <Foo_Quotedownload>
            <version>0.1.0</version>
        </Foo_Quotedownload>
    </modules>
    <global>
        <blocks>
            <qquoteadv>
                <rewrite>
                    <adminhtml_qquoteadv>Foo_Quotedownload_Block_Adminhtml_Qquoteadv</adminhtml_qquoteadv>
                </rewrite>
            </qquoteadv>
        </blocks>
    </global>
</config>
| improve this answer | |
  • Thank you so much! You were right, now it works. You really helped me a lot! Have a nice weekend. – Stefan Jul 18 '14 at 17:26

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.