Search code examples
magento

Magento: Get all configured rates of the tablerate shipping module


I'm stuck on what I think should be a minor problem, but I couldn't find a solution yet.

I'm working on a module that has to go through all configured rates of the tablerate shipping module. But how do I get all configured rates, and not just the one that fits a given condition? I looked into the code of the corresponding resource model ("shipping/carrier_tablerate"), and saw that the getRate($request)-method limits the select query to 1, so only 1 rate is returned.

Is there an easy way to get all configured rates? Is there a built-in way to do this at all or do I have to perform my own database operation?


Solution

  • $tablerateColl = Mage::getResourceModel('shipping/carrier_tablerate_collection');
    /* @var $tablerateColl Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection */
    
    foreach ($tablerateColl as $tablerate) {
        /* @var $tablerate Mage_Shipping_Model_Carrier_Tablerate */
        Zend_Debug::dump($tablerate->debug());
    }