This tutorial is the 10th in this series, if you have not already done it, i suggest you to read the tutorials starting with summary of this series .
Now how to make a rewrite of a controller ? Because your module will not know where to search for your extended class…you have to make a require in your controller.
Now how to make a rewrite of a controller ? Because your module will not know where to search for your extended class…you have to make a require in your controller.
require_once
"Mage/Checkout/controllers/CartController.php"
;
This give you something like:
require_once
"Mage/Checkout/controllers/CartController.php"
;
class
Easylife_Checkout_CartController
extends
Mage_Checkout_CartController
{
# Rewrite of indexAction
public
function
indexAction() {
die
(
'your method has been rewrited !!'
);
}
}
the require_once is important if your extends not work (because magento can not autoload that class)
Then your class is taken into account instead of the « classic » CartController of magento, set in the config.xml of your module:
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
config
>
...
<
frontend
>
<
routers
>
<
checkout
>
<
args
>
<
modules
>
<Easylife
_Checkout
before
=
"Mage_Checkout"
>Easylife
_Checkout</Easylife
_Checkout
>
</
modules
>
</
args
>
</
checkout
>
</
routers
>
</
frontend
>
</
config
>
Yes just it and it works! In fact « just take the controller Easylife_Checkout in my module before Mage_Checkout like that it loads my class, then this class extends the previous require_once class … and now it works.
Well this article was not so long to do it … in fact I hope it will help someone and it will be useful for you. Sometimes you just have to take the time but after a day of work and training we are tired and we think about thing differently ! All this to say that I would post more often and I thank you for reading this blog
It is you who motivate me to write and all your messages and comments make me very happy.
Thank you again
Find the summery of this tutorial
No comments:
Post a Comment