1
votes

I'm writing an API/Webservice module for magento.

I have a freight webservice, that returns me all available carriers and shipping methods based on the products I send as params.

I send

SKU0101
SKU0102

It returns

DHL
DHL OVERNIGHT 20.10
DHL EXPRESS 15.20

FEDEX
FEDEX OVERNIGHT 21.10
FEDEX EXPRESS 15.20

I want to populate that in the available carriers/methods in frontend, so the user can choose the shipping method, but magento (at least i guess), only provides a way to create ONE carrier, with multiple shipping methods, while i need to create MULTIPLE carriers with multiple shipping methods

Of course i could create many carriers in the module and populate them according to what i get from the webservice, but that way i would need to upgrade the module every time a new carrier is added to my webservice system, and also my clients, what will happen very often.

2
I don't understand. Why can't you generate the carriers within the Magento extension, which are retrieved from your web service? This should be achievable.Axel
It should, but i dont think it is. At least not using the proposed model. The default carriers function makes you create a model for each carrier, and set it to the config options, so they're configurable in system config (i dont need any config btw). I think ill have to override the default Mage_Shipping_Model_Shipping collectCarrierRates action so i can create the carriers at runtime and do not use the config it depends, but that's a guess. It would be very nice to get some advice, since its my first week working with magento.Fábio Carneiro

2 Answers

1
votes

Problem solved.

What i did:

Overrode the Shipping and Quote Adress Rate models extending the originals, so i dont need any config for the carriers and vendors that i will get from webservice, but kept the old parent code calling its parent function. Added my custom logic after that.

        <shipping>
            <rewrite>
                <shipping>Vendor_Shipping_Model_Shipping</shipping>
            </rewrite>
        </shipping>
        <sales>
            <rewrite>
                <quote_address_rate>Vendor_Shipping_Model_Quote_Address_Rate</quote_address_rate>
            </rewrite>
        </sales>
0
votes

May be worth speaking to David Craigon at Parcelhub about their multi carrier integration - http://www.parcelhub.co.uk/parcelhub-magento-shipping-software/

Hope this helps, Ross