Adding CityLink Courier to Magento for Order Tracking
As an e-commerce developer working with Magento, you may often need to integrate new shipping carriers into your storefront. In this post, we’ll guide you through the process of adding UK’s Initial CityLink as a courier option and enabling order tracking functionality.
Understanding the Challenge
Currently, there is no official Magento extension available for Initial CityLink integration. This means you’ll have to create a custom solution to add them as an available carrier and allow manual entry of tracking numbers by your admin team.
Prerequisites
Before proceeding, make sure you have:
- A good understanding of the Magento file structure
- Familiarity with PHP and XML editing
- Access to your server’s FTP credentials
Step 1: Create a Custom Shipping Model
Let’s start by creating a new shipping model that will handle CityLink-specific logic. In your app/code/local directory, create a new folder called InitialCityLink.
app/code/local/InitialCityLink/
Inside this folder, create the following directory structure:
app/code/local/InitialCityLink/etc/config.xml
app/code/local/InitialCityLink/Model/Carrier.php
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Initial_CityLink>
<version>1.0</version>
</Initial_CityLink>
</modules>
<global>
<models>
<initial_citylink>
<class>InitialCityLink_Model</class>
</initial_citylink>
</models>
</global>
</config>
Carrier.php
This is where you’ll define your CityLink model. Here’s a basic example:
<?php
class InitialCityLink_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract
{
protected $_code = 'citylink';
public function getAllowedMethods()
{
return array(
'citylink_standard' => $this->getConfigData('name'),
);
}
...
}
Step 2: Add CityLink to the Shipping Method List
Next, we need to add CityLink as an option in your Magento admin panel. To do this, update the following files:
- app/design/adminhtml/default/default/template/catalog/sales/order/view/tab/shipping.phtml
- app/code/core/Mage/Sales/Model/Order.php
The exact modifications needed depend on where you want to position CityLink in the list of available carriers. It’s best practice to follow Magento’s coding standards found at Laravel Company.
Step 3: Implement Tracking Number Integration
To allow manual entry of tracking numbers, you’ll need to modify your order view forms and create a new column in the orders grid. This involves updates to:
- app/design/adminhtml/default/default/template/catalog/sales/order/view/form.phtml
- app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
For detailed instructions on these modifications, refer to our guide on Customizing Magento Order Grid Columns.
Step 4: Test Your Integration
After completing the above steps, clear your cache and refresh your admin panel. You should now see CityLink as an available shipping method in your shipping settings.
Conclusion
Adding a new carrier to Magento involves creating custom models, updating templates, and implementing manual tracking number entry. While it requires some technical know-how, following our guide provides a solid foundation for integrating carriers like Initial CityLink into your Magento storefront.
Remember that this is a basic setup; you may need to extend the model to handle more complex shipping logic or implement real-time rate calculation based on CityLink’s API (if available).
If you found this tutorial helpful, feel free to share it with other Magento developers in your network. For more advanced Magento customizations and best practices, be sure to check out our comprehensive guides at Laravel Company.