Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Ambigious select statement" error resulting from join #7

Open
gebrial opened this issue Jun 10, 2016 · 3 comments
Open

"Ambigious select statement" error resulting from join #7

gebrial opened this issue Jun 10, 2016 · 3 comments

Comments

@gebrial
Copy link

gebrial commented Jun 10, 2016

In the admin panel, when opening the page at reports->products->"low stock", we get an error page. The report says (among other things):

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'qty' in where clause is ambiguous

A quick fix for this is to go to the class Etailer_Backorders_Model_Observer_Adminhtml and comment out the lines in the function joinFieldsToCollection. I've seen other solutions to this problem where they define a 'filter_index' when joining, but I'm not sure how to implement that here.

@rjocoleman
Copy link
Member

@gebrial I'm happy to take a PR for this, but I don't use this report myself so I won't get to it soon due to other pressing commitments.

@gebrial
Copy link
Author

gebrial commented Jun 10, 2016

@rjocoleman no problem. I'll try to find a better solution but I thought it was important to make a note of this in case others came across the same problem.

@captainyoung
Copy link
Contributor

Problem is in /app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php
Line 239
$this->getSelect()->where('qty < ?', $notifyStockExpr);

Should be:
$where = $this->_inventoryItemTableAlias . '.qty < ?';
$this->getSelect()->where($where, $notifyStockExpr);

So you have to extend Mage_Reports_Model_Resource_Product_Lowstock_Collection
and override:
public function useNotifyStockQtyFilter

I will put in a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants