Magento: Get all configured rates of the tablerate shipping module

Magento: Get all configured rates of the tablerate shipping module

October 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Get all configured rates of the tablerate shipping module

Accessing All Configured Rates in Magento’s Table Rate Shipping Module

As a developer working with Magento, you might face situations where you need to retrieve all configured rates of the table rate shipping module, not just the one that fits certain conditions. I encountered this challenge recently and found the solution to be quite straightforward once you understand how Magento structures its data.

Understanding Magento’s Database Structure for Table Rates

The table rate shipping module stores its data in a single database table called shipping_carrier_tablerate. This table contains columns such as rate_id, condition, amount, and others that define the shipping rates. The key column is rate_id, which uniquely identifies each configured rate.

Retrieving All Configured Rates Using Magento’s Resource Model

To access all configured rates, you can extend Magento’s core resource model (shipping/carrier_tablerate) and override the getRates method. This allows you to perform a simple query that retrieves all records from the shipping_carrier_tablerate table without any limiting conditions.

Here is an example of how you can achieve this:

class CustomTablerate extends \Magento\Shipping\Model\Carrier\Tablerate
{
    public function getRates($request)
    {
        $rates = [];
        $collection = $this->getResourceCollection('rate_collection')->addFieldToFilter(
            'condition',
            ['gt' => 0]
        )->load();

        foreach ($collection as $item) {
            // Populate your rates array here using the item data
        }

        return $rates;
    }
}

In this example, I’m extending Magento’s core carrier model Tablerate and overriding the getRates method. The key line is $collection = $this->getResourceCollection('rate_collection')->addFieldToFilter('condition', ['gt' => 0])->load();. This line retrieves a collection of all rates without any limiting conditions applied.

Implementing Your Rate Population Logic

Once you have the collection of all configured rates, you can populate your $rates array using the data from each item in the collection. You can customize this part based on your specific requirements for handling and displaying the rates.

For example:

foreach ($collection as $item) {
    $rate = [
        'amount' => $item->getAmount(),
        'condition' => $item->getCondition(),
        // Add other relevant data from the item object
    ];
    array_push($rates, $rate);
}

Conclusion

Retrieving all configured rates in Magento’s table rate shipping module is indeed possible without resorting to custom database operations. By extending and overriding the core resource model methods, you can access this data seamlessly.

Remember that working with the Magento framework requires a solid understanding of its architecture and database structure. This knowledge helps you leverage built-in functionality like resource collections for efficient data retrieval.

For more advanced customizations in Magento development, I recommend exploring our Magento Development Guide at Laravel Company, which covers best practices and common solutions to streamline your projects.

Happy coding!

Database Extensions Configuration

Our network