【问题标题】:Magento upgrade 1.7 caused following errorMagento 升级 1.7 导致以下错误
【发布时间】:2023-12-12 12:42:01
【问题描述】:

管理面板工作正常,但在前端出现以下错误。

SQLSTATE[23000]:违反完整性约束:1052 列“位置”在 order 子句中不明确

知道这是什么吗?

【问题讨论】:

  • 这意味着在 JOIN 中,列位置正在使用但存在于 2 个表中,例如 TABLE_A.position 和 TABLE_B.position 并且连接使用位置但未指定使用位置的表. *.com/questions/8509798/…
  • 感谢您的帮助,但我在这方面完全是个菜鸟,如果您能给我提示如何解决此问题,我将不胜感激。
  • 我需要的比你给我的要多得多。这个错误非常模糊。您是否使用自定义扩展程序?我可以说它是一条 SQL 语句,但它可能来自许多变量。
  • 嗯,是的,我在升级过程之前禁用了一些扩展,这也是一个自定义主题,其中集成了 wordpress,我知道 :) 你可能在想哦,我在一个很深的麻烦,但是是的,这就是我正在处理的问题。不知道如何显示整个错误,我应该复制粘贴吗?我不知道我对此很坚持,但是非常感谢您尝试帮助我,非常感谢 Vern。
  • 您可以从检查堆栈跟踪的异常开始,该堆栈跟踪应该引导您找到应该吐出错误的文件。

标签: sql magento upgrade


【解决方案1】:

这是我想出的解决方案,非常感谢 Vern Burton。

  1. 在phpmyadmin中定位表eav_attribute,与catalog_eav_attribute相关。
  2. 在表 eav_attribute 中定位列位置并将其删除。
  3. 清除所有缓存并重新索引所有数据,访问首页并得到一个新错误:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'main_table.include_in_menu' in 'where Clause'

  4. 定位并打开文件app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php

  5. 注释掉以下行:在我的情况下为 267 ----

        ->where('main_table.is_active = ?', '1')
       // ->where('main_table.include_in_menu = ?', '1') 
        ->order('main_table.position');
    

我不太确定这种方法解决这个问题有多美观,但现在肯定对我有用,如果有人有更好的方法来解决这个问题,如果你能发布你的解决方案,我将不胜感激。

希望这能帮助别人,干杯。

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'position' in order clause is ambiguous' in /chroot/home/user/my_domain.com/magento_root/lib/Zend/Db/Statement/Pdo.php:234

堆栈跟踪:
0 /chroot/home/user/my_domain.com/magento_root/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(数组)
1 /chroot/home/user/my_domain.com/magento_root/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
2 /chroot/home/user/my_domain.com/magento_root/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
3 /chroot/home/user/my_domain.com/magento_root/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT main_ta...', Array) <br>4 /chroot/home/user/my_domain.com/magento_root/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECTmain_ta...',大批)
5 /chroot/home/user/my_domain.com/magento_root/lib/Zend/Db/Adapter/Abstract.php(734): Varien_Db_Adapter_Pdo_Mysql->query('SELECT main_ta...', Array) <br>6 /chroot/home/user/my_domain.com/magento_root/lib/Varien/Data/Collection/Db.php(734): Zend_Db_Adapter_Abstract->fetchAll('SELECTmain_ta...', 数组)
7 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(521): Varien_Data_Collection_Db->_fetchAll('SELECT ` main_ta...',数组)
8 /chroot/home/user/my_domain.com/magento_root/lib/Varien/Data/Collection/Db.php(566):Mage_Core_Model_Resource_Db_Collection_Abstract->getData()
9 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Catalog/Model/Layer.php(232): Varien_Data_Collection_Db->load()
10 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Catalog/Block/Layer/View.php(163):Mage_Catalog_Model_Layer->getFilterableAttributes()
11 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Catalog/Block/Layer/View.php(122):Mage_Catalog_Block_Layer_View->_getFilterableAttributes()
12 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Block/Abstract.php(238):Mage_Catalog_Block_Layer_View->_prepareLayout()
13 /chroot/home/user/my_domain.com/magento_root/app/code/local/Mage/Core/Model/Layout.php(430): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
14 /chroot/home/user/my_domain.com/magento_root/app/code/local/Mage/Core/Model/Layout.php(446): Mage_Core_Model_Layout->createBlock('catalog/layer_v...', 'catalog.leftnav')
15 /chroot/home/user/my_domain.com/magento_root/app/code/local/Mage/Core/Model/Layout.php(238): Mage_Core_Model_Layout->addBlock('catalog/layer_v...', 'catalog.leftnav')
16 /chroot/home/user/my_domain.com/magento_root/app/code/local/Mage/Core/Model/Layout.php(204): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element) )
17 /chroot/home/user/my_domain.com/magento_root/app/code/local/Mage/Core/Model/Layout.php(209): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
18 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Controller/Varien/Action.php(344):Mage_Core_Model_Layout->generateBlocks()
19 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Catalog/Helper/Product/View.php(73):Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
20 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Catalog/Helper/Product/View.php(144): Mage_Catalog_Helper_Product_View->initProductLayout(Object(Mage_Catalog_Model_Product), Object( Mage_Catalog_ProductController))
21 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Catalog/controllers/ProductController.php(132):Mage_Catalog_Helper_Product_View->prepareAndRender(28491, Object(Mage_Catalog_ProductController), Object( Varien_Object))
22 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Controller/Varien/Action.php(419):Mage_Catalog_ProductController->viewAction()
23 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250):Mage_Core_Controller_Varien_Action->dispatch('view')
24 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Controller/Varien/Front.php(176):Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
25 /chroot/home/user/my_domain.com/magento_root/app/code/core/Mage/Core/Model/App.php(354):Mage_Core_Controller_Varien_Front->dispatch()
26 /chroot/home/user/my_domain.com/magento_root/app/Mage.php(683): Mage_Core_Model_App->run(Array)
27 /chroot/home/user/my_domain.com/magento_root/index.php(87): Mage::run('', 'store')
28 {主要}

【讨论】:

    【解决方案2】:

    您是否尝试过重建索引?我有一个类似的问题,并且解决了它。

    【讨论】:

      最近更新 更多