magento shipping
I have recently created a new shipping modu开发者_如何学Pythonle in Magento 1.3.2 with the aid of the Magento developers guide. My module works correctly, however I cant seem to work how to get the functionality for it to become apart of the carriers down down list when a shipment is created within the admin area.
Once I have my carrier in this drop down list, I am going to need to apply additional functionality so that if my carrier is selected when the shipment order is placed then it does a whole heap of things.
So things i need to work out are:
- How can make my shipment option a carrier in the drop down list
- What class must I extend to add the functionality or can I simply add it to my shipment model?
I have found the problem.
The overall problem was that I had not set the method isTrackingAvailable() (within my shipping model) to return true.
For anyone wondering how to worked that out.
I looked through all of the templates files related to shipping. Once I found the file, I found where the drop down list was being created:
<?php foreach ($this->getCarriers() as $_code=>$_name): ?>
<option value="<?php echo $_code ?>"><?php echo $_name; ?></option>
<?php endforeach; ?>
After seeing that is was being called using $this. I did a echo get_class($this) to find the class name that was calling it, which was Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Tracking.
In there is where i found getCarriers() function.
In there it was collecting all of the carriers by creating an object called Mage_Shipping_Model_Config.
$carrierInstances = Mage::getSingleton('shipping/config')->getAllCarriers(
$this->getShipment()->getStoreId()
);
and calling its function getAllCarriers().
Inside this function it returned all of the carriers from the core_config_data table in the db.
So jumping back to the getCarriers() function.. we now have all the carriers. A little further down I could see that there was an IF statement that asked is the carrier had the function isTrackingAvailable() returning true before it would return the carrier.
foreach ($carrierInstances as $code => $carrier) {
if ($carrier->isTrackingAvailable()) {
$carriers[$code] = $carrier->getConfigData('title');
}
}
If anyone has any questions.. email me. mark@mbwebstudios.com (mind you I'm still learning myself but I will answer any questions as best I can)
have you added the necessary blocks under app/code/local/yournamespace/yourmodule/Blocks/Adminhtml
and a layout xml file in app/design/adminhtml/default/default/layout
?
精彩评论