I'm developing a dropship extension. Everything is going really well. The integration so far is seamless. I've added a column to sales_flat_shipment_item, called 'dropshipped'. Boolean data, defaults to false. This way normal shipments do their thing the same way as always, but a dropshipped item has this extra flag. So, when I choose to 'Submit Dropship', how can I attach this custom field to the save?

I have used proper extends calls to use the same system as the normal Order->Shipment workflow. So, when a use clicks submit, it is effectively all the same class as a normal Shipment submit. (Mage_Adminhtml_Sales_Order_ShipmentController)

I have tried to add the new field to my global fieldset, as shown below.


I am fairly certain something about this config.xml entry is wrong.

So, the new column is called 'dropshipped'. It is a boolean, by default false. This way, when the user executes a normal shipment, all the regular functions work normally. Now, on a dropship, I want to set this field to 'true', or 1. For example:



 $shipment->setData('dropshipped', 1);

In my custom controller,

Namespace_Module_Adminhtml_Sales_Order_DropshipController extends Mage_Adminhtml_Controller_Sales_Shipment

The code is a copy of Mage_Adminhtml_Sales_Order_ShipmentController except for some descriptive text changes ('shipment' changed to 'dropship' in messages that the user sees) and a couple routing changes to support my custom routes. In other words, saveAction and _initShipment are unchanged from the Mage core.

My theory is that this is the simplest, most straightforward solution to implementing dropshipping. One field that flags a sales_flat_shipment_item record as 'dropshipped' is elegant and simple. So far, my module works with Magento rather than against it, and I'm pretty happy with it.

I'm sure the solution is fairly straightforward, my config.xml might be setup incorrectly, and I'm looking forward to a bit of assistance. Thanks!

1 Answer 1


Here is my solution.

I abandoned the fieldset solution, and removed that from my config.xml.

In the DropshipController, which is very similar to Mage_Adminhtml_Sales_Order_ShipmentController, there is an _initShipment function. This function is called to build the shipment array, and return it to the saveShipment function.

Inside _initShipment, before $shipment is saved to the registry and before it is returned to saveShipment, I push a variable 'dropshipped' onto the array.

I created an event observer in the adminhtml/events node in my config.xml. This observer watches for the "sales_order_shipment_save_before" event. When this event is dispatched, my observer does the following.

class namespace_module_Model_Observer
    public function saveDropshippedAttribute (Varien_Event_Observer $observer)
        $shipment = $observer->getEvent()->getShipment();
        //In namespace_module_Adminhtml_Sales_Order_DropshipController we pushed 'dropshipped=1' onto the $shipment array.  If it isn't set, this is a regular shipment.
        if ($shipment->dropshipped == 1)
            foreach($shipment->getAllItems() as $item)
                $product = Mage::getModel('catalog/product')->load($item->getProductId());
                if ($product->getData('dropship') == 1)
                    $item->dropshipped = 1;

If the $shipment has the 'dropshipped' key pushed onto it, this came from my dropshipController and not the regular shipmentController. I go through each item in the shipment, and push my new column's value onto every item that is being dropshipped. Now, every row in sales_flat_shipment_item that came from a dropship is marked with a 1, and regular shipments have a 0.

I hope this helps someone else heavily modifying Magento.

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.