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());

}

$tries++;

}

} while ($retry);

// end changes

}

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

$tries = 0;

do {

$retry = false;

try {

$this->clear_result();

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

$this->clear_result();

}

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;

}

$tries++;

}

} 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 Exanto.de. Under Exanto.de/magento-module-und-hacks.html, 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:

http://www.exanto.de/svn/magento-free/trunk/modules/mod_reclayup/

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 Trucks.com 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

Categories Don’t Show Up In Layered Navigation in Magento

If you want to make sure layered navigation shows all your categories and sub categories in your search results in Magento, make sure you select the parent category as an anchor. This will cause the category where a product resides to show up in the “Shopping Options” box.