Magento Error: You cannot define a correlation name … more than once.
This will be a short post about an error I ran into when messing around with the Magento “Toolbar” that is displayed for search results and on category pages. I decided that i needed to extend the toolbar block in-order to achieve some custom functionality that a client needed. Then I noticed that when I sorted by price I got the following error “You cannot define a correlation name ‘_price_order_table’ more than once“. In my case I had extended the setCollection function.
My problem(Error) began because I was calling the parent method then was setting the order on the collection again, and Magento did not like it.
public function setCollection($collection)
{
parent::setCollection($collection);
//The next three lines were what were causing the problem.
//Because setOrder was called in the parent function it threw the error when it was called again.
#if ($this->getCurrentOrder()) {
# $this->getCollection()->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
#}
//Custom code went here
return $this;
}

13 Responses to “ Magento Error: You cannot define a correlation name … more than once. ”
September 15th, 2010 at 7:26 am
Thanks Mike for your posts, they’re all really useful!!
I just wanted to say I am getting really sick and tired of these Magento errors…. Errors in places you’d expect it works… Like calculating taxes in admin or time admin is logged in. …
Cheers and best of luck!
April 14th, 2011 at 4:20 am
Great help.
Thank you Mike..
September 8th, 2011 at 8:47 pm
I got this error in my new installation of magento, but it only happens when I try to add a item to the cart..
You cannot define a correlation name ‘link_attribute_position_int’ more than once
any idea?
September 9th, 2011 at 7:11 am
@nei: I am not sure why it would be throwing this error in the cart. Where in the file is the error thrown?
October 26th, 2011 at 6:23 am
Hi Mike,
What file is this data in?
Im getting the same error expect instead of when i list by price it does it for listing by manufacturer and all other “sort by” options.
Cheers,
Hamish
October 26th, 2011 at 7:21 am
@Hamish: It depends on when/where this error is thrown.
October 31st, 2011 at 5:01 pm
Maybe i’m in over my head.
In the error file it references multiple files, does that mean i have to fix them all or find where the source problem is?
Cheers,
Hamish
November 1st, 2011 at 5:56 pm
You need to find the source. Which should be one of the first few lines. What you are looking at is the last few lines that were executed prior to the error being thrown.
November 14th, 2011 at 8:29 am
Hi Mike, I had the same problem, so I tried your tip, changing the php-file, but something went completely wrong. I tried to restore the original php-file, but still my front-end and admin are both down.
This was my error:
a:5:{i:0;s:68:”You cannot define a correlation name ‘kleur_glas_idx’ more than once”;i:1;s:3664:”#0 /home/lyppenss/public_html/trollbeadsweb.nl/lib/Varien/Db/Select.php(281): Zend_Db_Select->_join(‘inner join’, Array, ‘kleur_glas_idx….’, Array, NULL)
#1 /home/lyppenss/public_html/trollbeadsweb.nl/lib/Zend/Db/Select.php(336): Varien_Db_Select->_join(‘inner join’, Array, ‘kleur_glas_idx….’, Array, NULL)
So I went to Zend/Db/select.php and changed line 336 into: return $this;
I couldn’t open shop frontend anymore, so I restored the original php-file. But I still get the error message:
a:5:{i:0;s:88:”SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘link.store_id’ in ‘where clause’”;i:1;s:3000:”#0 /home/lyppenss/public_html/trollbeadsweb.nl/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
Sorry I’m bothering you with my error, but I thought you might be able to help me out.
Thanks a lot,
Desiree
November 16th, 2011 at 8:13 am
@Desiree: First off make sure that you have disabled caching, otherwise you may not see your changes right away.
Next, do you have an attribute code similar to this “kleur_glas”?
If so it seems like you may be sorting by it twice.
November 16th, 2011 at 9:24 am
@Mike D, thanks for your reply. I did turn off cache and the layered navigation block with attribute kleur_glas somehow was called twice on the category page.
After trying many things and a blocked home and admin, I decided I should reinstall the whole thing, since this is an initial shop set-up and it was time to do a fresh start.
The problem started when I decided I wanted the attributes to be shown on the right column on a 2-column layout. The attributes were shown, but the filter didn’t work properly. I will try to set it up again and be more carefull this time.
Thanks for your reply.
Desiree
December 2nd, 2011 at 4:25 am
To fix this problem just make sure there is only 1 line with in your catalog.xml(in your theme directory) file and that line should be only shown by and no where else.
December 2nd, 2011 at 4:26 am
To fix this problem just make sure there is only 1 line with in your catalog.xml(in your theme directory) file and that line should be only shown by –
Category layered navigation layout
– and no where else.