Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephdpurcell/baf93992ff2d941d02c946aeccd48853 to your computer and use it in GitHub Desktop.
Save josephdpurcell/baf93992ff2d941d02c946aeccd48853 to your computer and use it in GitHub Desktop.
Namespace store_id filter to avoid query failure (Magento v1)
From 541bb110dd4a495e4e1e801916b10c1cbe23e9f9 Mon Sep 17 00:00:00 2001
From: "Joseph D. Purcell" <josephdpurcell@gmail.com>
Date: Mon, 12 Sep 2016 16:44:32 -0500
Subject: [PATCH] Namespace store_id filter to avoid query failure
---
.../core/Mage/Sales/Model/Resource/Order/Grid/Collection.php | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/www/app/code/core/Mage/Sales/Model/Resource/Order/Grid/Collection.php b/www/app/code/core/Mage/Sales/Model/Resource/Order/Grid/Collection.php
index a233612..e61dd7d 100644
--- a/www/app/code/core/Mage/Sales/Model/Resource/Order/Grid/Collection.php
+++ b/www/app/code/core/Mage/Sales/Model/Resource/Order/Grid/Collection.php
@@ -112,4 +112,15 @@ class Mage_Sales_Model_Resource_Order_Grid_Collection extends Mage_Sales_Model_R
{
return $this->_customerModeFlag;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function addAttributeToFilter($attribute, $condition = null)
+ {
+ if (is_string($attribute) && 'store_id' == $attribute) {
+ $attribute = 'main_table.' . $attribute;
+ }
+ return parent::addFieldToFilter($attribute, $condition);
+ }
}
--
2.7.4
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'store_id' in where clause is ambiguous, query was: SELECT `main_table`.*, `order_table`.`admin_user_id` FROM `sales_flat_order_grid` AS `main_table`
LEFT JOIN `sales_flat_order` AS `order_table` ON order_table.entity_id=main_table.entity_id WHERE (`store_id` IN('1', '5', '7')) ORDER BY main_table.created_at DESC LIMIT 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment