簡體   English   中英

Magento-加載管理面板頁面時出現MySQL錯誤

[英]Magento - MySQL error while loading an admin panel page

我收到以下錯誤:

a:5:{i:0;s:2328:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sales_flat_order.web4pro_abandonedcart_flag' in 'where clause', query was: SELECT COUNT(*) FROM (SELECT `main_table`.*, `sales_flat_order`.`web4pro_abandonedcart_flag`, GROUP_CONCAT(order_item_tbl.`name` SEPARATOR '\n') AS `product_names`, GROUP_CONCAT(order_item_tbl.`sku` SEPARATOR '\n') AS `skus`, GROUP_CONCAT(order_item_tbl.`product_id` SEPARATOR '\n') AS `product_ids`, GROUP_CONCAT(order_item_tbl.`product_options` SEPARATOR '^') AS `product_options`, `order_address_billing_tbl`.`company` AS `billing_company`, `order_address_billing_tbl`.`street` AS `billing_street`, `order_address_billing_tbl`.`city` AS `billing_city`, `order_address_billing_tbl`.`region` AS `billing_region`, `order_address_billing_tbl`.`country_id` AS `billing_country_id`, `order_address_billing_tbl`.`postcode` AS `billing_postcode`, `order_address_billing_tbl`.`telephone` AS `billing_telephone`, `order_address_shipping_tbl`.`company` AS `shipping_company`, `order_address_shipping_tbl`.`street` AS `shipping_street`, `order_address_shipping_tbl`.`city` AS `shipping_city`, `order_address_shipping_tbl`.`region` AS `shipping_region`, `order_address_shipping_tbl`.`country_id` AS `shipping_country_id`, `order_address_shipping_tbl`.`postcode` AS `shipping_postcode`, `order_address_shipping_tbl`.`telephone` AS `shipping_telephone`, `order_payment_tbl`.`method` FROM `sales_flat_order_grid` AS `main_table`
 INNER JOIN `sales_flat_order` ON main_table.increment_id = sales_flat_order.increment_id
 LEFT JOIN `sales_flat_order_item` AS `order_item_tbl` ON `order_item_tbl`.`order_id` = `main_table`.`entity_id` AND `order_item_tbl`.`parent_item_id` IS NULL
 LEFT JOIN `sales_flat_order_address` AS `order_address_billing_tbl` ON order_address_billing_tbl.parent_id = main_table.entity_id AND order_address_billing_tbl.`address_type` = "billing"
 LEFT JOIN `sales_flat_order_address` AS `order_address_shipping_tbl` ON order_address_shipping_tbl.parent_id = main_table.entity_id AND order_address_shipping_tbl.`address_type` = "shipping"
 LEFT JOIN `sales_flat_order_payment` AS `order_payment_tbl` ON order_payment_tbl.parent_id = main_table.entity_id GROUP BY `main_table`.`entity_id`) AS `main_table` WHERE (`sales_flat_order`.`web4pro_abandonedcart_flag` = 1) AND (order_group_id = '0')";i:1;s:5789:"#0 /home/*********/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

如果我做對了,那不是在sales_flat_order表中找到web4pro_abandonedcart_flag列嗎?

但是,我已經檢查過,並且我100%確保該表中有這樣的列。

這是造成此故障的功能:

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel('sales/order_grid_collection');
    $this->setCollection($collection);
    $sales_flat_order_table = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
    $collection->getSelect()->join($sales_flat_order_table , 'main_table.increment_id = '.$sales_flat_order_table.'.increment_id', 'web4pro_abandonedcart_flag');
    $collection->addFieldToFilter($sales_flat_order_table.'.web4pro_abandonedcart_flag',array('eq' => 1));
    return parent::_prepareCollection();
}

您能建議問題出在哪里嗎?

是的,給定字段可能存在於給定表中,但是,外部查詢的from子句中未引用sales_flat_order表,但您正在引用該表中字段的where條件中也未引用該表。

您的查詢以簡化方式如下所示:

SELECT COUNT(*)
FROM (...) AS `main_table`
WHERE (`sales_flat_order`.`web4pro_abandonedcart_flag` = 1) AND (order_group_id = '0')

在外部查詢中,從字段名稱中刪除sales_flat_order ,或將其替換為main_table 但是最好的解決方案是完全擺脫子查詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM