Alerted by a customer comment I discovered a nasty bug in the latest Magento release. All shipments submitted through the API are handled as if you had submitted an invoice!
Looking at the method prepareShipment in
app/code/core/Mage/Sales/Model/Order.php
/**
* Create new shipment with maximum qty for shipping for each item
*
* @return Mage_Sales_Model_Order_Shipment
*/
public function prepareShipment($qtys = array())
{
$shipment = Mage::getModel('sales/service_order', $this)->prepareInvoice($qtys);
return $shipment;
}
it becomes immediately clear that a copy & paste has gone wrong. Instead of prepareInvoice we need prepareShipment:
/**
* Create new shipment with maximum qty for shipping for each item
*
* @return Mage_Sales_Model_Order_Shipment
*/
public function prepareShipment($qtys = array())
{
$shipment = Mage::getModel('sales/service_order', $this)->prepareShipment($qtys);
return $shipment;
}
From my initial investigation so far only shipments created through the API are affected since the back-end calls the service_order model directly and doesn’t go via the order object.
Link to Bug report.
The only upside is that likely another bug in relation to the API would have prevented you from using it – see.
Originally published on magebase.com. Copyright © 2010 Magebase - All Rights Reserved.




Proud members of the 









These type(s) of bugs are very common when you develop with out release candidates. 1.4.1.0 is the most recent snapshot of the 1.4-trunk (short of a few payment modules).
Talking about broken API stuff in 1.4.1 here’s a thread form the Magento upgrade issues forum: http://www.magentocommerce.com/boards/viewthread/196097/
There is a curly bracket missing from the code in the Soap.php file…
Oh just noticed another post by a Varien dev who attached a patch for some fixes around the Sales module: http://www.magentocommerce.com/boards/viewreply/243525/
[...] shipment Api ^_^…the damage that copy-past can do is is unthinkable on your friday! P:S **http://magebase.com/magento-tutorials/shipment-api-in-magento-1-4-1-broken/ This entry was posted in Magento. Bookmark the [...]
[...] http://magebase.com/magento-tutorials/shipment-api-in-magento-1-4-1-broken/ Tags: magento, mysql, php, programming Category: Webtags: magento commercetags: programming [...]