0

I am working with Magento CE 1.9.0.1 and I like to extend the second controller from the first controller class.

First controller

class Federallawyer_Flphotos_SuggestController
    extends Mage_Core_Controller_Front_Action { 
}

Second controller

class Federallawyer_Flphotos_ConnectController
    extends Federallawyer_Flphotos_SuggestController {
}

the second controller is extended from the first controller, but Magento is throwing an error.

the error is

Call to undefined method Federallawyer_Flphotos_ConnectController::getCustomerSession(),

While I define this method in first controller file.

Any idea's or suggestions will help me

5

This will not work without an require():

<?php

require(Mage::getModuleDir('controllers', 'Federallawyer_Flphotos').DS.'SuggestController.php');

class Federallawyer_Flphotos_ConnectController extends Federallawyer_Flphotos_SuggestController
{
//...
}

Controller actions will resolve the main controller class (Federallawyer_Flphotos_ConnectController) based on configuration and routing, but it is extending another class (Federallawyer_Flphotos_SuggestController) which PHP has to resolve on its own using the autoloading conventions.

  • i follow your way but still throw an error.Fatal error: Class 'Federallawyer_Flphotos_ConnectController' not found in /home/vhosts/FederalLawyer/app/code/local/Federallawyer/Flphotos/controllers/SuggestController.php on line 2 – senthil May 29 '15 at 11:13
0

try adding following code in your second controller class

require_once 'Federallawyer/Flphotos/controllers/SuggestController.php';
class Federallawyer_Flphotos_ConnectController extends Federallawyer_Flphotos_SuggestController {
}
  • i follow your way but still throw an error.Fatal error: Class 'Federallawyer_Flphotos_ConnectController' not found in /home/vhosts/FederalLawyer/app/code/local/Federallawyer/Flphotos/controllers/SuggestController.php on line 2 – senthil May 29 '15 at 11:13

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.