2

I'm aiming to override the class Mage_Checkout_Block_Onepage in order to begin a rework of the onepage checkout. Unfortunately, i fail to success at overriding it, while the onePageController override works fine. My package name is Ohwee, my extension name is ThirdStepsCheckout.

Files in my extension:

Checkout/ Block/ Onepage.php controllers/ OnepageController.php etc/ config.xml 

Here's my config.xml file :

<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Ohwee_ThirdStepsCheckout> <version>0.1.0</version> </Ohwee_ThirdStepsCheckout> </modules> <global> <blocks> <checkout> <rewrite> <onepage> Ohwee_ThirdStepsCheckout_Block_Onepage </onepage> </rewrite> </checkout> </blocks> </global> <frontend> <routers> <checkout> <args> <modules> <ohwee_thirdstepscheckout before="Mage_Checkout">Ohwee_ThirdStepsCheckout</ohwee_thirdstepscheckout> </modules> </args> </checkout> </routers> </frontend> </config> 

at the time, the block class Onepage.php is just a test to see if the override is working :

<?php require_once 'Mage/Checkout/Block/Onepage.php'; class Ohwee_ThirdStepsCheckout_Block_Onepage extends Mage_Checkout_Block_Onepage { public function getSteps() { exit('custom steps'); } } ?> 

The problem is I don't see the exit on front, but the layout is now empty, so it seems the original Mage controller isn't called either. If i delete the config.xml part about overriding the block, checkout is functional again. I can't see from where the issue come from,any ideas ?

I'm on Magento CE 1.8.0.1

2 Answers 2

2

Change this:

 <onepage> Ohwee_ThirdStepsCheckout_Block_Onepage </onepage> 

Into this:

<onepage>Ohwee_ThirdStepsCheckout_Block_Onepage</onepage> 

Magento does not trim the spaces.
And you don't need

require_once 'Mage/Checkout/Block/Onepage.php'; 

the blocks, helpers and models are autoloaded. the require is only needed for controllers.

3
  • Thanks. I edited my config.xml as you suggested, i still got an empty layout in front, but this was for sure a part of the issue. removed the require_once too since it's useless. Commented Nov 12, 2014 at 15:37
  • there are basic issue with space at confog.xml Commented Nov 12, 2014 at 15:53
  • I tried a few more things on the config file, making new file and re-save it, suppress indent, putting all in one line, none of these solved the empty layout i got in front. Still, it looks a lot like an issue on config.xml Commented Nov 12, 2014 at 16:00
2

Solved by naming the class Ohwee_ThirdStepsCheckout_Checkout_Block_Onepage instead of Ohwee_ThirdStepsCheckout_Block_Onepage

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.