O'Reilly logo

Magento 2 Development Cookbook by Bart Delvaux

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing an adapter model

In the previous recipe, we enabled a new module with the settings for a new shipping method. This was a preparation for the business part, which we will do in this recipe.

We will add a model with the business logic for the shipping method. The model is called an adapter class because Magento requires an adapter class for each shipping method.

The adapter class will be used for the following things:

  • Making the shipping method available
  • Calculating the shipping costs
  • Setting the title in the frontend of the shipping methods

Getting ready

Ensure that you have installed the module that we created in the previous recipe because we need this for creating the adapter class.

How to do it...

The following steps describe how you can write ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required