does anyone know howto programmatically show and make the field editable for tracking number field in order overview?
I am thinking this.
step 1. First enable showing the tracking field in Grid.php, so extend … Does anyone have an example how to add a column? (and for that matter hide an existing column)
Add this to /etc/config.xml under events so Magento knows what to call
<core_block_abstract_prepare_layout_before>
<observers>
<SNH_ShipMailInvoice_Observer_addTrackingColumnToGrid>
<type>model</type>
<class>SNH_ShipMailInvoice_Model_Observer</class>
<method>addTrackingColumnToGrid</method>
</SNH_ShipMailInvoice_Observer_addTrackingColumnToGrid>
</observers>
</core_block_abstract_prepare_layout_before>
step 2.a Then populate the Grid with the tracking code if applicable
So first add a field in /Model/Observer.php (that answers step 1)
public function addTrackingColumnToGrid($observer)
{
// this will return the block name for every block triggered by the observer
$block = $observer->getEvent()->getBlock();
// filter - we only want the block for the sales order grid
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_grid){
// well, that was easy!
$block->addColumn('tracking_number', array(
'header' => Mage::helper('sales')->__('Tracking number'),
'index' => 'tracking_number',
'type' => 'input',
'width' => '120px',
'renderer' => 'SNH_ShipMailInvoice_Block_Adminhtml_Renderer_addTrackingColumnToGrid'
));
}
}
step 2.b Then we need to populate the field with available tracking info
‘renderer’ =>
‘SNH_ShipMailInvoice_Block_Adminhtml_Renderer_addTrackingColumnToGrid’
should call to addTrackingColumnToGrid.php in /Block/Adminhtml/Renderer/addTrackingColumnToGrid.php
* CURRENT PROBLEM: ERROR **
This is where I am getting my white page no answer
step 2.c Lookup the tracking number per order in row. Currently untested/unconfirmed
// HOW DO I POPULATE VAR $order for each line?
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')->setOrderFilter($order)->load();
foreach ($shipmentCollection as $shipment){
// This will give me the shipment IncrementId, but not the actual tracking information.
foreach($shipment->getAllTracks() as $tracknum) {
$tracknums[]=$tracknum->getNumber(); }
// How to show the tracking information
// CODE HERE
}
}
step 3 Then when I click on the dropdown option Masssaction (already programmed) the backend should process the selected items only and store the tracking ID to the shipment (that is created shortly after)
(and after that continue invoice and ship)
Thanks in advance
If I may suggest something simpler:
How to add a column to the Sales Order grid
Setup an event observer. (You could use a rewrite in your config.xml file, but this can potentially cause conflicts with other modules.)
Create your observer in
./app/code/local/Namespace/Module/Model/Observer.php. It should look something like this.Try looking in Mage_Adminhtml_Block_Widget_Grid for clues on how to use the
addColumnmethod. It’s pretty much universal for all Magento admin grids, which is nice. If you’re looking to add custom functionality (besides just retrieving data), though, there’s a pretty good chance you’re going to need to figure out how to apply “renderers.”Once you’ve got that part figured out, you just need to setup an Ajax controller and drop in a little JavaScript to transmit the update information to your controller.
This is a pretty broad question, so I can’t exactly do it all for you (without writing an extension), but I’ll try to help you along the way.
For what it’s worth, you might look into the Tracking Import module over at Creativemgroup.com. Word on the street is a forthcoming version of this module includes the edit-in-place functionality you’re looking for.