我正在尝试创建一个Magento网站的本地副本,以便我可以进行一些测试以尝试解决已发生的问题,看起来这是一个重新索引问题,但是当我们尝试重新编制索引时现场网站打破了整个事情。
我已按照此处Copying a Magento site的说明操作,但在尝试查看网站时收到错误消息。我得到的错误是:
SQLSTATE [23000]:完整性约束违规:1062重复条目 关键'PRIMARY'的'1464841'
说实话,它开始让我发疯,看起来这么简单 - 只需复制文件&数据库&然后进行一些简单的配置更改。
编辑以添加完整堆栈跟踪
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1464842' for key 'PRIMARY'
Trace:
#0 Z:\XAMPP\htdocs\sites\Providore\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 Z:\XAMPP\htdocs\sites\Providore\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 Z:\XAMPP\htdocs\sites\Providore\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 Z:\XAMPP\htdocs\sites\Providore\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ma...', Array)
#4 Z:\XAMPP\htdocs\sites\Providore\lib\Varien\Db\Adapter\Pdo\Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ma...', Array)
#5 Z:\XAMPP\htdocs\sites\Providore\lib\Zend\Db\Adapter\Abstract.php(574): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ma...', Array)
#6 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Log\Model\Resource\Visitor.php(174): Zend_Db_Adapter_Abstract->insert('mage_log_visito...', Array)
#7 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Log\Model\Resource\Visitor.php(108): Mage_Log_Model_Resource_Visitor->_saveVisitorInfo(Object(Fooman_Jirafe_Model_Log_Visitor))
#8 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(463): Mage_Log_Model_Resource_Visitor->_afterSave(Object(Fooman_Jirafe_Model_Log_Visitor))
#9 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Model\Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Fooman_Jirafe_Model_Log_Visitor))
#10 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Log\Model\Visitor.php(167): Mage_Core_Model_Abstract->save()
#11 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Model\App.php(1338): Mage_Log_Model_Visitor->initByRequest(Object(Varien_Event_Observer))
#12 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Model\App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Fooman_Jirafe_Model_Log_Visitor), 'initByRequest', Object(Varien_Event_Observer))
#13 Z:\XAMPP\htdocs\sites\Providore\app\Mage.php(447): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#14 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Controller\Varien\Action.php(528): Mage::dispatchEvent('controller_acti...', Array)
#15 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Controller\Front\Action.php(64): Mage_Core_Controller_Varien_Action->preDispatch()
#16 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Controller\Varien\Action.php(408): Mage_Core_Controller_Front_Action->preDispatch()
#17 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#18 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#19 Z:\XAMPP\htdocs\sites\Providore\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#20 Z:\XAMPP\htdocs\sites\Providore\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#21 Z:\XAMPP\htdocs\sites\Providore\index.php(90): Mage::run('', 'store')
#22 {main}
答案 0 :(得分:5)
似乎日志表出错。你有mage_作为所有Magento表的前缀,不是吗?尝试在magento数据库中运行此SQL语句(首先备份数据库):
SET foreign_key_checks = 0;
TRUNCATE mage_log_customer;
TRUNCATE mage_log_quote;
TRUNCATE mage_log_summary;
TRUNCATE mage_log_url;
TRUNCATE mage_log_url_info;
TRUNCATE mage_log_visitor;
TRUNCATE mage_log_visitor_info;
TRUNCATE mage_log_visitor_online;
SET foreign_key_checks = 1;