3
  1. I want to delete Interface Mage_Shipping_Model_Carrier_Interface.

    interface Mage_Shipping_Model_Carrier_Interface
    {
    
        /**
         * Check if carrier has shipping tracking option available
         *
         * @return boolean
         */
        public function isTrackingAvailable();
    
        /**
         * Get allowed shipping methods
         *
         * @return array
         */
        public function getAllowedMethods();
    
    }
    
  2. And copy functions to isTrackingAvailable() & getAllowedMethods() to abstract class Mage_Shipping_Model_Carrier_Abstract.

  3. and any shipping method only extends like this

    class Mage_Shipping_Model_Carrier_Freeshipping
        extends Mage_Shipping_Model_Carrier_Abstract
    
    {
    .......................some code...............
    
    }
    

I think may be meaning less. But Can anyone explain what is wrong to do it like this?

  • Why would you want to remove the interface? does it bother you?. Keeping this interface, allows you to create shipping methods for which the main model does not extend Mage_Shipping_Model_Carrier_Abstract. I can't find an use case where you would need that, but if you need it, you can. Having the interface ensures that your new shipping method will function properly. – Marius Jul 18 '14 at 10:37
  • I don't need at any place.But I want to understand oop concepts with magento practically – sivakumar Jul 18 '14 at 13:44
2

The functions in the Interface are always abstract, means required, whichever class implements the interface must has to define those functions. If you don't want to use interface and you want to declare those functions in abstract class, here are two scenarios:

  1. you want each ..._..._Model_Carrier_.... class to must define this function in it: You have to make the function abstract and now all the child classes extended from this abstract class will require to define this function either they need it or not. This is useless if they don't have to do anything with these abstract functions.
  2. You don't want each inherited class to define this function: You will define this function as public in abstract class. but as we know this function is only used in ..._..._Model_Carrier_...., no other inherited class is using it and when such child class loads, the function is compiled every time which is useless/overhead. so better to move that function to interface so only the classes needs that function just implements it.
1

Later in the code you need to remove "instance of Mage_Shipping_Model_Carrier_Interface"

  • I think magento not using anywhere instanc of interface – sivakumar Jul 18 '14 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.