We are doing custom Magento themes, Magento design, custom Magento extensions and creative services through Magento designers & developers for worldwide shop owners.

Last News
Magento : clean compare list programmatically? and Get instance of Conrtoller

Magento : clean compare list programmatically? and Get instance of Conrtoller

I was browsing the Web and found a lesson for us old, I had one of them replied to a question:
clean compare list programmatically?

for get instance of class ComapreController and execute directly the clear action

1
2
3
4
5
6
7
8
9
10
11
$app = Mage::app();
$frontController = $app->getFrontController();
$request = $frontController->getRequest();
//get the Magento Router (controls which controller to get, and which action to call for front end)
$router =new  Mage_Core_Controller_Varien_Router_Standard(); 
$controllerFileName=$router->getControllerFileName("Mage_Catalog", "product_compare");
include($controllerFileName);
$controllerClassName =$router->getControllerClassName("Mage_Catalog", "product_compare");
//get an instance of whichever cms controller we are using
$controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $frontController->getResponse());
$controllerInstance->clearAction();

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*