Magento2 无法创建发票问题

Posted

技术标签:

【中文标题】Magento2 无法创建发票问题【英文标题】:Magento2 Can not create Invoice Issue 【发布时间】:2016-10-14 23:50:33 【问题描述】:

我已经更新到最新的 Magento2 版本。 2.1.0-rc2 从 Magento 的 GIT 分支安装:2.1

当我尝试从管理员创建发票时,它会抛出错误:

[2016-06-14 09:53:16] main.CRITICAL:异常 'PDOException' 带有消息 'SQLSTATE[42S22]:找不到列:1054 '字段列表'中的未知列 'base_grand_total' 在 /var /www/magento2/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228

下一个异常 'Zend_Db_Statement_Exception' 带有消息 'SQLSTATE[42S22]:找不到列:1054 '字段列表'中的未知列 'base_grand_total',查询是:INSERT INTO sales_invoice_grid (entity_id, increment_id, statestore_idstore_nameorder_idorder_increment_idorder_created_atcustomer_namecustomer_emailcustomer_group_idpayment_methodstore_currency_codeorder_currency_codebase_currency_code , global_currency_code, billing_name, billing_address, shipping_address, shipping_information, subtotal, shipping_and_handling, base_grand_total, grand_total, updated_at, created_at, created_at, @987654346 entity_id, sales_invoice.increment_id AS increment_id, sales_invoice.state AS state, sales_invoice.store_id AS store_id, sales_order.store_name AS store_name, sales_invoice.order_id AS order_id, sales_order.increment_id AS @8754345 @, sales_order.created_at AS order_created_at, TRIM(CONCAT_WS(' ', IF(sales_order.customer_firstname '', sales_order.customer_firstname, NULL), IF(sales_order.@987654361 @ '', sales_order.customer_lastname, NULL) )) AS customer_name, sales_order.customer_email AS customer_email, sales_order.customer_group_id AS customer_group_id, sales_order_payment.method AS payment_method, sales_invoice.store_currency_code AS store_currency_code, sales_invoice.order_currency_code AS @9876_54366 AS base_currency_code, sales_invoice.global_currency_code AS global_currency_code, TRIM(CONCAT_WS(' ', IF(sales_billing_address.firstname '', sales_billing_address.firstname, NULL), IF(sales_billing_address .lastname '', sales_billing_address.lastname, NULL))) AS billing_name, TRIM(CONCAT_WS(' ', IF(sales_billing_address.street '', sales_billing_address .street, NULL), IF(sales_billing_address.city '', sales_billing_address.city, NULL), IF(sales_billing_address.region '', sales_billing_address .region, NULL), IF(sales_billing_address.postcode '', sales_billing_address.postcode, NULL))) AS billing_address, TRIM(CONCAT_WS(' ', IF(@987654398 @.street '', sales_shipping_address.street, NULL), IF(sales_shipping_address.city '', sales_shipping_address.city, NULL), IF(@987654406 @.region '', sales_shipping_address.region, NULL), IF(sales_shipping_address.postcode '', sales_shipping_address.postcode, NULL))) AS shipping_address, sales_order.shipping_description AS shipping_information, sales_order.base_subtotal AS subtotal, sales_order.base_shipping_amount AS shipping_and_handling, sales_invoice.base_grand_total AS base_grand_total, sales_invoice.grand_total AS grand_total, sales_invoice.created_at AS @987654444 销售987654421@ FROM sales_invoice 左加入 sales_order on sales_invoice.order_id = sales_order.entity_id 左加入 sales_order_address AS sales_shipping_address on sales_invoice.shipping_address_id = sales_shipping_address.entity_id 左加入 sales_order_address AS sales_billing_address on sales_invoice.billing_address_id = sales_billing_address.entity_id 左连接 sales_order_payment on sales_invoice.order_id = sales_order_payment.parent_id WHERE (sales_invoice.entity_id = '8') ON DUPLICATE KEY UPDATE entity_id = VALUES(entity_id), increment_id = VALUES(increment_id), @ 987654433@ = 值(state),store_id = 值(store_id),store_name = 值(store_name),order_id = 值(order_id),@UEVAL(@56) 987654442@), order_created_at = VALUES(order_created_at), customer_name = VALUES(customer_name), customer_email = VALUES(customer_email), customer_group_id = VALUES(@987654), @987654), @ = 值(payment_method),store_currency_code = 值(store_currency_code),order_currency_code = 值(order_currency_code),base_currency_code = 值(base_currency_code),global_currency_code = 值(store_currency_code) @), billing_name = 值(billing_name), billing_address = 值(billing_address), shipping_address = 值(shipping_address), shipping_information = 值(subtotal), @987 = 值(subtotal),shipping_and_handling = 值(shipping_and_handling),base_grand_total = 值(base_grand_total),grand_total = 值(grand_total),created_at = 值ES(created_at), updated_at = VALUES(updated_at)' 在 /var/www/magento2/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235

【问题讨论】:

运行此 SQL 后:ALTER TABLE sales_invoice_grid ADD base_grand_total DECIMAL(12, 4) NOT NULL AFTER grand_total ; 它有效,但这是正确的方法解决这个问题? 我今天从 2.0.1 升级后遇到了同样的问题,这也为我解决了。但是,这是在下订单时,而不是在手动创建发票时。在上面的 SQL 命令命令之后可能是地方,但我现在严重怀疑数据库的完整性。 【参考方案1】:

这是一个在 2.1.0 发布后修复的 magento 核心问题(MAGETWO-54787 票证)。见https://github.com/magento/magento2/issues/5546和https://github.com/magento/magento2/issues/4785

【讨论】:

以上是关于Magento2 无法创建发票问题的主要内容,如果未能解决你的问题,请参考以下文章

Magento2 常见错误 ----- 定期更新

Magento2 - 使用 Paypal 计费协议创建自定义订单(“强制参数缺少 referenceId 错误”)

从不同的文件 [MAGENTO2] 将变量添加到registration.php

Magento2 主题迷你购物车 KO 模板问题

Magento 2.3 在本地主机中无法正常工作

Magento2开发教程 - 如何向数据库添加新表