点击Magneto中的付款方式时出错

时间:2016-02-11 18:23:57

标签: mysql magento payment

点击配置页面上的付款方式时,我收到此错误。

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'photocha_magento64.sales_order_status' doesn't exist

查询是:

SELECT `main_table`.*, `state_table`.`state`, `state_table`.`is_default` FROM `sales_order_status` AS `main_table`
 LEFT JOIN `sales_order_status_state` AS `state_table` ON main_table.status=state_table.status WHERE (state_table.state='new') ORDER BY `main_table`.`label` ASC

跟踪:

#0 /home/photocharms/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/photocharms/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/photocharms/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/photocharms/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `main_ta...', Array)
#4 /home/photocharms/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `main_ta...', Array)
#5 /home/photocharms/public_html/lib/Zend/Db/Adapter/Abstract.php(737): Varien_Db_Adapter_Pdo_Mysql->query('SELECT `main_ta...', Array)
#6 /home/photocharms/public_html/lib/Varien/Data/Collection/Db.php(740): Zend_Db_Adapter_Abstract->fetchAll('SELECT `main_ta...', Array)
#7 /home/photocharms/public_html/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT `main_ta...', Array)
#8 /home/photocharms/public_html/lib/Varien/Data/Collection/Db.php(572): Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
#9 /home/photocharms/public_html/lib/Varien/Data/Collection.php(741): Varien_Data_Collection_Db->load()
#10 /home/photocharms/public_html/app/code/core/Mage/Sales/Model/Order/Config.php(173): Varien_Data_Collection->getIterator()
#11 /home/photocharms/public_html/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Order/Status.php(46): Mage_Sales_Model_Order_Config->getStateStatuses('new')
#12 /home/photocharms/public_html/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(463): Mage_Adminhtml_Model_System_Config_Source_Order_Status->toOptionArray(false)
#13 /home/photocharms/public_html/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(229): Mage_Adminhtml_Block_System_Config_Form->initFields(Object(Varien_Data_Form_Element_Fieldset), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#14 /home/photocharms/public_html/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(164): Mage_Adminhtml_Block_System_Config_Form->_initGroup(Object(Varien_Data_Form), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#15 /home/photocharms/public_html/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php(92): Mage_Adminhtml_Block_System_Config_Form->initForm()
#16 /home/photocharms/public_html/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php(107): Mage_Adminhtml_Block_System_Config_Edit->initForm()
#17 /home/photocharms/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_System_ConfigController->editAction()
#18 /home/photocharms/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('edit')
#19 /home/photocharms/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#20 /home/photocharms/public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#21 /home/photocharms/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#22 /home/photocharms/public_html/index.php(83): Mage::run('', 'store')
#23 {main}
I have only 250 tables, the last table being 'persistent_session'

我以前重新安装了数据库,但仍然只能获得250个表,重新安装并不理想,因为我们从其他商店导入了客户数据。理想情况下,我们想写新的标签。

任何帮助都会很棒

3 个答案:

答案 0 :(得分:1)

如果您有可用的备份文件,请恢复表格:

sales_order_status
sales_order_status_label
sales_order_status_state

如果您没有备份,则可以只重新安装缺少的表

只需使用1个安装文件创建一个简单的扩展程序。使用sales_order模块(Mage_Sales_Model_Resource_Setup)的安装程序:

https://gyazo.com/ac50353c9facfd1c1fff3f87b3e97428

为您的扩展程序创建安装文件: https://gyazo.com/7dde13062355e792b15b39731f5ae117

复制以下代码(这是销售/订单安装程序的副本,但有一些更改)

/* @var $installer Mage_Sales_Model_Entity_Setup */
$installer = $this;

$statusTable        = $installer->getTable('sales/order_status');
$statusStateTable   = $installer->getTable('sales/order_status_state');
$statusLabelTable   = $installer->getTable('sales/order_status_label');

$installer->run(" 
CREATE TABLE IF NOT EXISTS `{$statusTable}` (
  `status` varchar(32) NOT NULL,
  `label` varchar(128) NOT NULL,
  PRIMARY KEY (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
");

$statuses = Mage::getConfig()->getNode('global/sales/order/statuses')->asArray();
$data = array();
foreach ($statuses as $code => $info) {
    $data[] = array(
        'status'    => $code,
        'label'     => $info['label']
    );
}

try {
    $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data);
} catch (Exception $e) {

}

$installer->run(" 
CREATE TABLE IF NOT EXISTS `{$statusStateTable}` (
  `status` varchar(32) NOT NULL,
  `state` varchar(32) NOT NULL,
  `is_default` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`status`,`state`),
  CONSTRAINT `FK_SALES_ORDER_STATUS_STATE_STATUS` FOREIGN KEY (`status`)
    REFERENCES `{$statusTable}` (`status`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
");
$states     = Mage::getConfig()->getNode('global/sales/order/states')->asArray();
$data = array();
foreach ($states as $code => $info) {
    if (isset($info['statuses'])) {
        foreach ($info['statuses'] as $status => $statusInfo) {
            $data[] = array(
                'status'    => $status,
                'state'     => $code,
                'is_default'=> is_array($statusInfo) && isset($statusInfo['@']['default']) ? 1 : 0
            );
        }
    }
}

try {
    $installer->getConnection()->insertArray(
        $statusStateTable,
        array('status', 'state', 'is_default'),
        $data
    );
} catch (Exception $e) {

}

$installer->run(" 
CREATE TABLE IF NOT EXISTS `{$statusLabelTable}` (
  `status` varchar(32) NOT NULL,
  `store_id` smallint(5) unsigned NOT NULL,
  `label` varchar(128) NOT NULL,
  PRIMARY KEY (`status`,`store_id`),
  KEY `FK_SALES_ORDER_STATUS_LABEL_STORE` (`store_id`),
  CONSTRAINT `FK_SALES_ORDER_STATUS_LABEL_STATUS` FOREIGN KEY (`status`)
    REFERENCES `{$statusTable}` (`status`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_SALES_ORDER_STATUS_LABEL_STORE` FOREIGN KEY (`store_id`)
    REFERENCES `{$installer->getTable('core/store')}` (`store_id`)ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
");

执行此操作后,应显示缺失的表格,并填写标准信息。

答案 1 :(得分:0)

这并不困难,特别是考虑到您不需要其大部分功能。

创建文件夹app / code / local / MageWorx / Fix 和子文件夹: 等等 帮手 SQL

https://www.gyazo.com/cf571d50e90ce7cd5068f0f723de5103

在etc文件夹中创建文件:config.xml

https://www.gyazo.com/f024cbea6ae596d30f1da4715229df3b

具有以下内容:

<?xml version="1.0"?>
<config>
    <modules>
        <MageWorx_Fix>
            <version>1.0.0</version>
        </MageWorx_Fix>
    </modules>
    <global>
        <helpers>
            <mageworx_fix>
                <class>MageWorx_Fix_Helper</class>
            </mageworx_fix>
        </helpers>
        <resources>
            <mageworx_fix_setup>
                <setup>
                    <module>MageWorx_Fix</module>
                    <class>Mage_Sales_Model_Resource_Setup</class>
                </setup>
            </mageworx_fix_setup>
        </resources>
    </global>
</config>

在Helper文件夹中,使用以下内容创建Data.php文件(https://www.gyazo.com/e5a71e283c387887da4582f04f8bf546):

<?php

class MageWorx_Fix_Helper_Data extends Mage_Core_Helper_Abstract
{

}

在sql文件夹中创建子文件夹mageworx_fix_setup:

https://www.gyazo.com/bd013b1fb638db1d943441eec7252baf

在此内部,使用原始帖子中的内容创建install-1.0.0.php文件(https://www.gyazo.com/cea0e9c2feedf83e3157ffcb2a85aa3f)(短语后面的代码“并复制以下代码(这是副本)销售/订单安装程序有一些更改)“):

внутринеесоздайтефайлinstall-1.0.0.php(https://www.gyazo.com/cea0e9c2feedf83e3157ffcb2a85aa3f)ссодержаниемизоригинальногопоста(кодпослефразы“并复制以下代码(这是销售/订单安装程序的副本,带有一些更改)“):

因此,您应该获得以下结构:

https://www.gyazo.com/b85a58a0f207ed48a774ff502e15d9b6

最后一步是 - 扩展公告。在目录app / etc / modules /中创建文件MageWorx_Fix.xml,其中包含以下内容:

<?xml version="1.0"?>
<config>
    <modules>
        <MageWorx_Fix>
            <active>true</active>
            <codePool>local</codePool>
        </MageWorx_Fix>
    </modules>
</config>

接下来,打开管理面板,刷新缓存。扩展将安装在create table中。错误应该消失。 完成后,您可以删除它。

答案 2 :(得分:0)

是的,安装文件应以<?php开头。

接下来,您应确保已正确安装扩展程序。如果相应的记录没有出现在表core_resource中,则表示安装过程由于某种原因失败。

检查是否所有文件都已到位,尤其是app / etc / modules文件夹中的扩展文件。如果包含“state”和“label”的表,则可以将安装程序代码快捷方式设置为:

/* @var $installer Mage_Sales_Model_Entity_Setup */
$installer = $this;

$statusTable        = $installer->getTable('sales/order_status');

$installer->run(" 
CREATE TABLE IF NOT EXISTS `{$statusTable}` (
  `status` varchar(32) NOT NULL,
  `label` varchar(128) NOT NULL,
  PRIMARY KEY (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
");

$statuses = Mage::getConfig()->getNode('global/sales/order/statuses')->asArray();
$data = array();
foreach ($statuses as $code => $info) {
    $data[] = array(
        'status'    => $code,
        'label'     => $info['label']
    );
}

try {
    $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data);
} catch (Exception $e) {

}