1

I am new to Magento and i'm trying to override Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Tracking in a module to add extra options for carriers in the shipping and tracking section and i cant figure out why this is not working?

Heres my code:

Module xml: app/etc/modules/Essential_Emailtracking.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
 <modules>
  <Essential_Emailtracking>
   <active>true</active>
   <codePool>local</codePool>
  </Essential_Emailtracking>
 </modules>
</config>

Module config.xml: app/code/local/Essential/Emailtracking/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
 <config>

  <modules>
   <Essential_Emailtracking>
     <version>0.1.0</version>
   </Essential_Emailtracking>
  </modules>

  <global>
   </blocks>
    <adminhtml>
     <rewrite>
      <sales_order_shipment_create_tracking>Essential_Emailtracking_Block_Sales_Order_Shipment_Create_Tracking</sales_order_shipment_create_tracking>
     </rewrite>
    </adminhtml>
   </blocks>
  </global>
 </config>

My Block to override core mage block: app/code/local/Essential/Emailtracking/Block/Sales/Order/Shipment/Create/Tracking.php

<?php

class Essential_Emailtracking_Block_Sales_Order_Shipment_Create_Tracking extends Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Tracking
{
/**
 * Prepares layout of block
 *
 * @return Mage_Adminhtml_Block_Sales_Order_View_Giftmessage
 */
protected function _prepareLayout()
{
    $this->setChild('add_button',
        $this->getLayout()->createBlock('adminhtml/widget_button')
            ->setData(array(
                'label'   => Mage::helper('sales')->__('Add Tracking Number'),
                'class'   => '',
                'onclick' => 'trackingControl.add()'
            ))

    );

}

/**
 * Retrieve shipment model instance
 *
 * @return Mage_Sales_Model_Order_Shipment
 */
public function getShipment()
{
    return Mage::registry('current_shipment');
}

/**
 * Retrieve
 *
 * @return unknown
 */
public function getCarriers()
{
    $carriers = array();
    $carrierInstances = Mage::getSingleton('shipping/config')->getAllCarriers(
        $this->getShipment()->getStoreId()
    );
    $carriers['usps2'] = Mage::helper('sales')->__('USPS');
    $carriers['canada_post'] = Mage::helper('sales')->__('Canada Post');
    $carriers['aus_post'] = Mage::helper('sales')->__('Australia Post');
    $carriers['custom'] = Mage::helper('sales')->__('Custom Value');
    foreach ($carrierInstances as $code => $carrier) {
        if ($carrier->isTrackingAvailable()) {
            $carriers[$code] = $carrier->getConfigData('title');
        }
    }
    return $carriers;
  }
}
  • Where you are calling getCarriers() method? – Nidheesh Oct 7 '16 at 9:19
  • Its being called in the tracking.phtml file here app/design/adminhtml/default/default/template/sales/order/shipment/create/tracking.phtml – Aaron Sly Oct 7 '16 at 14:55
0

You have an error in your config.xml. Instead of opening blocks tag, you have closed it. Correct it as below:

<?xml version="1.0" encoding="UTF-8"?>
 <config>

  <modules>
   <Essential_Emailtracking>
     <version>0.1.0</version>
   </Essential_Emailtracking>
  </modules>
<global>
       <blocks>
        <adminhtml>
         <rewrite>
          <sales_order_shipment_create_tracking>Essential_Emailtracking_Block_Sales_Order_Shipment_Create_Tracking</sales_order_shipment_create_tracking>
         </rewrite>
        </adminhtml>
       </blocks>
      </global>
     </config>
  • I have made the change and still doesn't seem to want to work? – Aaron Sly Oct 10 '16 at 8:25
  • did you flush magento cache? – Nidheesh Oct 10 '16 at 8:55
  • yeah certainly did – Aaron Sly Oct 10 '16 at 10:28
  • It just worked fine for me... dropbox.com/s/soek1eljvnsdnwk/app.zip?dl=0 – Nidheesh Oct 10 '16 at 11:31
  • I've just tried it out in a clean install of magento with the sample data and i'm still not getting the updated options in the dropdown box under the shipping and tracking information on the shipment page? Am i missing something here? or am i looking in the wrong place? – Aaron Sly Oct 10 '16 at 14:25

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.