⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies
Showing posts with label Magento Core Hacks. Show all posts
Showing posts with label Magento Core Hacks. Show all posts

Monday, July 8, 2013

Disable state/province option in the Magento

Sometime your Magento site doesn’t need the region/state for customer address and you don’t know how to turn it off without touching in many places in the complex Magento source code. Please try to run following SQL statements to try
1
2
update core_config_data set `value`=0 where path = 'general/region/display_all';
update core_config_data set `value`='' where path = 'general/region/state_required';
Checked on: Magento 1.7.0.2

Sunday, June 23, 2013

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

When developing on some customer site, we have met this error in the report file “SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction“. We have researched about this issue and we have found people suggests to run this statement via phpMyAdmin “SET innodb_lock_wait_timeout = 120;” or restart mysql service. But sometime, we don’t have permission to run this statement and have hosting admin done it.
 We have found other quick solution to do by modifying the file <Magento root folder>/lib/Zend/Db/Statement/Pdo.php at public function _execute(array &params = null)
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public function _execute(array $params = null)
{
   /*try {
      if ($params !== null) {
         return $this->_stmt->execute($params);
      } else {
         return $this->_stmt->execute();
      }
   } catch (PDOException $e) {
      #require_once 'Zend/Db/Statement/Exception.php';
      throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
   }*/
    
   $timeoutMessage = 'SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction';
   $tries = 0;
   do {
      $retry = false;
      try {
         if ($params !== null) {
            return $this->_stmt->execute($params);
         } else {
            return $this->_stmt->execute();
         }
      } catch (PDOException $e) {
         if ($tries < 10 and $e->getMessage()==$timeoutMessage) {
            $retry = true;
         } else {
            throw new Zend_Db_Statement_Exception($e->getMessage());
         }
         $tries++;
      }
   } while ($retry);
}