How To Make A Custom Page Not Found Page for Opencart

Making a custom “Page Not Found” page for Opencart is actually fairly simple once you figure it out. The only real tricky part to this is that you have to modify three files to make it work instead of just two files like you might use in osCommerce.

It’s fairly straightforward that you would modify your language page which is here:


What we did was under the line:

// Text

$_['text_error'] = ‘The work truck hardware and equipment page you requested cannot be found.’;

we added a line like this one:

// Text Page

$_['text_page'] = ‘The page you requested cannot be found. WorkTruck Outfitters was completely rebuilt on October 14th, 2012. If you are seeing this page, you may have been brought here by a search engine or one of your bookmarks. We apologize for the inconvenience! That exact url does not exist.<br><b>There are quite a few options to find the work truck product you were looking for.</b><br>First off, you can call us. 877-360-7278.<br> You can try using our search box in the top left area of our web page.<br>You may find our sitemap very helpful. <li><a href=”index.php?route=information/sitemap”><b>Work Truck Outfitters Sitemap</b></a></li><br> Or, you may want to try one of these popular links:<br><br><li><a href=”backup-cameras-trucks”><b>Backup Cameras For Trucks</b></a></li><li><a href=”air-compressors-trucks”><b>Air Compressors For Trucks</b></a></li><li><a href=”crane-pallet-forks”><b>Crane Pallet Forks</b></a></li><li><a href=”jump-start-equipment/goodall-startalls”><b>Goodall StartAlls</b></a></li><li><a href=”hardware-work-trucks”><b>Hardware For Work Trucks</b></a></li><li><a href=”outrigger-pads”><b>Outrigger Pads For Crane Trucks</b></a></li><li><a href=”power-inverters-for-trucks”><b>Power Inverters For Trucks</b></a></li><li><a href=”utility-body-bed-covers”><b>Utlity Body Bed Covers</b></a></li><li><a href=”warn-winches”><b>Warn Winches and Hoists</b></a></li><li><a href=”wheel-chocks”><b>Wheel Chocks</b></a></li>’;

That adds the text and links in the “Page Not Found” page. But to call that line into action, you have to call it in the template page found here:


So, under this line:

<div class=”content”><?php echo $text_error; ?></div>

We added this line:

<div class=”content”><?php echo $text_page; ?></div>

In osCommerce, that’s all it would have taken. But in Opencart, we have to do one more edit to make this work. If not, you’re going to get an “Undefined variable” error message that looks like this:

Notice: Undefined variable: text_page in / on line 10

So, we now need to modify one more line:

In /catalog/controller/error/not_found.php

Find the line that reads:

$this->data['text_error'] = $this->language->get(’text_error’);

and add under that this:

$this->data['text_page'] = $this->language->get(’text_page’);

That’s it. Now when a visitor get’s your “Page Not Found” page on your Opencart site, they’ll be able to get the full message you want to get accross so they can find the product they were looking for.

// Text
$_['text_error']    = ‘The work truck hardware and equipment page you requested cannot be found.’;

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded try restarting transaction

Today we ran into this error message using Magento: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

We searched around a bit and found this solution that seems to work.

In lib/Zend/Db/Statement/Pdo.php find the public function _execute and replace the function with this code:

public function _execute(array $params = null)


// begin changes

$tries = 0;

do {

$retry = false;

try {

if ($params !== null) {

return $this->_stmt->execute($params);

} else {

return $this->_stmt->execute();


} catch (PDOException $e) {

#require_once ‘Zend/Db/Statement/Exception.php’;

if ($tries < 10 and $e->getMessage()==’SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction’) {

$retry = true;

} else {

throw new Zend_Db_Statement_Exception($e->getMessage());




} while ($retry);

// end changes


Then in lib/Varien/Db/Adapter/Mysqli.php find the raw_query with:

$tries = 0;

do {

$retry = false;

try {


$result = $this->getConnection()->query($sql);



catch (Exception $e) {

if ($tries < 10 and $e->getMessage()==’SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction’) {

$retry = true;

} else {

throw $e;




} while ($retry);

return $result;


Hopefully, that will take care of the error message “SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction” for you.

Custom Design Layout Update Not Working On Child Elements In Magento

Related to our recent post “How To Use The Custom Layout Update In Magento“, it turns out Magento has a bug that keeps design layouts from working on child elements. So if you did the custom layout update to your category as described, it worked fine in that category, but would not go down to the product level even though that was selected. So if you wanted, you could put in that custom layout update on every product manually, but for us that would be a huge undertaking because of the number of products in the category. Besides, that’s just not the way it should be.

So after wasting tons of time researching the forums, we finally came up with this great fix. It comes from another website out there, called Under, this guy has made a complete package to fix this bug. Problem is (nothing’s easy), the site is in German or Dutch, not sure which. If you speak whatever language it is, I guess it’s not a problem. Unfortunately I only know english and a little bit of spanish “Una mas cervesa, pour some more” (haha).

Anyway, back to the solution. I went ahead and got brave. I clicked on a few of the links and figured I would try the one here:

I’m not going to spend the time explaining from here, but basically, if you’ll drill down through all the links in that section, he has provided all the files you need to fix this bug.

Thanks modman for showing us how to fix the bug, “Custom Design Layout Update Not Working On Child Elements In Magento”

How To Use The Custom Layout Update In Magento

As anyone who uses Magento may know, getting a grasp on how things work with Magento can be pretty mind boggling at times. But along with that, I have to say it’s pretty nice when things work out for you. One of those cases is figuring out how to use custom layout updates on categories or products in magento. Turns out it can be pretty simple.

Recently, we wanted to do a custom layout update to Real Work that announced an $80 rebate on select Warn Winches. We wanted it to appear on the applicable category as well as all of the products in that category.

First, we went to Magento Admin > CMS > Static Blocks

Select Add New Block

Put in you block title. In this case we named it Warn Rebate

Next enter the identifier. This is what will be used in you actual code. This one for us is warn_rebate

Make status “Enabled”

For content we made it <h1>$80 Mail In Rebate on select Warn Winches. Offer ends 7-31-11</h1>

Save your block.

Next go to your category under Catalog > Mange Categories

Select the category, in this case it was “Warn Winches and Hoists“. Under the “Custom Design” tab, you’ll see the box called “Custom Layout Update”. Put your code in that box to call your CMS Static Block. The code we used looks like this:

<reference name=”left”><block type=”cms/block” name=”warn_rebate” before=”-”><action method=”setBlockId”><block_id>warn_rebate</block_id></action></block></reference>

With the “Apply To” drop down menu, we selected “This category and it’s products only”

Click save category. There you go, you’re all set. Refresh your cache in Magento Admin then go to your website category to see the changes.

That’s it, that’s how you “Use The Custom Layout Update In Magento

That’s how