1

I am trying to override below file:

/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php :

class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
   ...
   protected function _prepareColumns()
   {

      $this->addColumn('subscriber_id', array(
         'header'    => Mage::helper('newsletter')->__('ID'),
         'index'     => 'subscriber_id'
      ));

      /* Need to add own cloumn */

   }
   ....
}

Here is what I am trying to do with custom module: /app/code/local/Customletter/Phone/etc/config.xml:

<?xml version="1.0"?>
<config>
        <modules>
            <Customletter_Phone>
                <version>1.0.0</version>
            </Customletter_Phone>
        </modules>

    <global>

       <blocks>

             <phone>
                <class>Customletter_Phone_Block</class>
             </phone>

             <adminhtml>
               <rewrite>
                     <subscriber_grid>
                         Customletter_Phone_Adminhtml_Block_Newsletter_Subscriber_Grid
                     </subscriber_grid>
               </rewrite>
             </adminhtml>

      </blocks>


     <resources>
        <customletter_phone>
            <setup>
                <module>Customletter_Phone</module>
            </setup>
            <connection>
                <use>core_setup</use>
            </connection>
        </customletter_phone>
    </resources>

    </global>  

</config>

/app/code/local/Customletter/Phone/Adminhtml/Block/Newsletter/Subscriber/Grid.php:

class Customletter_Phone_Adminhtml_Block_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Newsletter_Subscriber_Grid
{

   protected function _prepareColumns()
   {


     $this->addColumn('customletter_phone', array(
        'header'    => Mage::helper('newsletter')->__('Customer Phone Number'),
        'index'     => 'customletter_phone',
        'default'   =>    '----'
    ));


        return parent::_prepareColumns();
  }
}

Problem: In Newsletter Subscribers grid Customer Phone Number not showing up.

I am using magento 1.9.2.4.

2 Answers 2

1

Your rewrite is wrong, please replace:

<adminhtml>
      <rewrite>
             <subscriber_grid>
                     Customletter_Phone_Adminhtml_Block_Newsletter_Subscriber_Grid
             </subscriber_grid>
      </rewrite>
</adminhtml>

With:

 <adminhtml>
      <rewrite>
           <newsletter_subscriber_grid>Customletter_Phone_Adminhtml_Block_Newsletter_Subscriber_Grid</newsletter_subscriber_grid>
      </rewrite>
 </adminhtml>
6
  • It's showing blank page now. Oct 10, 2016 at 10:41
  • @Hiranya see my edit Oct 10, 2016 at 10:45
  • Now it's only showing one column Custom Phone Number Oct 10, 2016 at 10:47
  • @Hiranya sorry I mixed my memories with the prepareCollection method Oct 10, 2016 at 10:48
  • Ok..it's coming up now but in first column,how can I make it in 3rd or 4th column. Oct 10, 2016 at 10:58
0

Replace your code

<adminhtml>
    <rewrite >
        <subscriber_grid >
    Customletter_Phone_Adminhtml_Block_Newsletter_Subscriber_Grid
        </subscriber_grid >
    </rewrite >
</adminhtml >

with

<adminhtml >
    <rewrite >
        <newsletter_subscriber_grid > Customletter_Phone_Adminhtml_Block_Newsletter_Subscriber_Grid</newsletter_subscriber_grid >
    </rewrite >
</adminhtml >

Replace protected function _prepareColumns() function code

$this->addColumn('customletter_phone', array(
    'header' => Mage::helper('newsletter')->__('Customer Phone Number'),
    'index' => 'customletter_phone',
    'default' => '----'
));


return parent::_prepareColumns();

with

$this->addColumn('subscriber_id', array(
    'header' => Mage::helper('newsletter')->__('ID'),
    'index' => 'subscriber_id'
));

$this->addColumn('email', array(
    'header' => Mage::helper('newsletter')->__('Email'),
    'index' => 'subscriber_email'
));

$this->addColumn('type', array(
    'header' => Mage::helper('newsletter')->__('Type'),
    'index' => 'type',
    'type' => 'options',
    'options' => array(
        1 => Mage::helper('newsletter')->__('Guest'),
        2 => Mage::helper('newsletter')->__('Customer')
    )
));

$this->addColumn('customletter_phone', array(
    'header' => Mage::helper('newsletter')->__('Customer Phone Number'),
    'index' => 'customletter_phone',
    'default' => '----'
));


return parent::_prepareColumns();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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