How to know the correct path to extend in Magento?
-
30-01-2021 - |
Pergunta
I am new in Magento. I am having a lot of problems to achieve each step in the learning curve. I needed to add a custom shipping method. I was fallowging this tutorial: https://www.mageplaza.com/devdocs/magento-2-create-shipping-method/ Is not working for me, maybe because multiple causes. But for example, I see the class Shipping is extending from "\Magento\Shipping\Model\Carrier\AbstractCarrier" but I don´t have this path in my Magento folder. I have Magento CE 2.1. That changes for each version? I am really confused, :(. Thank you very much
Solução
if you looking for path for Magento core modules, you could check on this folder :
<magento_root>/vendor/magento/*
especially for the module that you mention \Magento\Shipping\Model\Carrier\AbstractCarrier
you could get that class file on this path<magento_root>/vendor/magento/module-shipping/model/carrier/AbstractCarrier.php
Outras dicas
When you extend any file ( which is in vendor/magento/module-x folder ) its path is always start with \Magento\X so in your case if you are extending file from module-shipping then its path would be \Magento\Shipping\.
so here you will see module is replaced with Magento and module name will be named with first letter capital i.e shipping will become Shipping.