Jump to content

how to override or extend productController from a module


abdullacm

Recommended Posts

Well for that probably best way is overriding, but again depends what you want to do.

Maybe you could add additional tab in product edit in back office that could save some 

value, that value will be specific to each product.

Link to comment
Share on other sites

postProcess of the Cart Controller does not contain any hooks.  But the postProcess function really just executes a bunch of other functions for dealing with add, delete, update of a customer cart.

 

Do you need to do something for all of those events, or only 1 of them.

 

If you really want to do something during postProcess, then create the override file, and in that file you would have a single function that looks like this

public function postProcess()
{
    //add your logic here
    
    //then execute the parent postProcess here
    parent::postProcess();
}

Note that the above will execute your logic first, and then execute the standard logic second.  This is because the parent function will perform a redirect when it is finished, and your code would never execute if you move your custom logic after the parent call.

Link to comment
Share on other sites

i could accomplish this, placed cartController in my module's override folder and written a condition 

postProcess(){

  if(Module::isEnabled('my-module-name')
  {
         //my logic goes here
  }
 else
 {
      //non modified code here
  }
​
}

so the modified code is executed only if the module is enabled

:)  thanks for the replies.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...