Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

I have correlation name error.How to solve it? 
 
Wallace Goh
Jr. Member
 
Total Posts:  11
Joined:  2008-11-05
 

I got error for block layer(shop by blocks).I am not sure how i get this error.

You cannot define a correlation name 'attr_index_456' more than once
Trace
:
#0 /home/webapps/magento/magento-1.2.1.2/site/lib/Zend/Db/Select.php(225): Zend_Db_Select->_join('inner join', Array, 'attr_index_456....', Array, NULL)
#1 /home/webapps/magento/magento-1.2.1.2/site/lib/Zend/Db/Select.php(204): Zend_Db_Select->joinInner(Array, 'attr_index_456....', Array, NULL)
#2 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/CatalogIndex/Model/Mysql4/Attribute.php(89): Zend_Db_Select->join(Array, 'attr_index_456....', Array)
#3 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/CatalogIndex/Model/Attribute.php(58): Mage_CatalogIndex_Model_Mysql4_Attribute->applyFilterToCollection(Object(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection), Object(Mage_Catalog_Model_Resource_Eav_Attribute), '14')
#4 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php(71): Mage_CatalogIndex_Model_Attribute->applyFilterToCollection(Object(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection), Object(Mage_Catalog_Model_Resource_Eav_Attribute), '14')
#5 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Catalog/Block/Layer/Filter/Abstract.php(64): Mage_Catalog_Model_Layer_Filter_Attribute->apply(Object(Mage_Core_Controller_Request_Http), Object(Mage_Catalog_Block_Layer_Filter_Attribute))
#6 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Catalog/Block/Layer/Filter/Abstract.php(47): Mage_Catalog_Block_Layer_Filter_Abstract->_initFilter()
#7 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Catalog/Block/Layer/View.php(57): Mage_Catalog_Block_Layer_Filter_Abstract->init()
#8 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Block/Abstract.php(199): Mage_Catalog_Block_Layer_View->_prepareLayout()
#9 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Model/Layout.php(444): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#10 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Model/Layout.php(229): Mage_Core_Model_Layout->addBlock('Mage_Catalog_Bl...', 'catalog.leftnav')
#11 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Model/Layout.php(195): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#12 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Model/Layout.php(200): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#13 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Controller/Varien/Action.php(285): Mage_Core_Model_Layout->generateBlocks()
#14 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Cms/Helper/Page.php(82): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#15 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Cms/controllers/IndexController.php(32): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
#16 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Controller/Varien/Action.php(349): Mage_Cms_IndexController->indexAction()
#17 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(163): Mage_Core_Controller_Varien_Action->dispatch('index')
#18 /home/webapps/magento/magento-1.2.1.2/site/app/code/core/Mage/Core/Controller/Varien/Front.php(174): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#19 /home/webapps/magento/magento-1.2.1.2/site/app/Mage.php(447): Mage_Core_Controller_Varien_Front->dispatch()
#20 /home/webapps/magento/magento-1.2.1.2/site/malaysiaflowers/index.php(67): Mage::run('mf', 'store')
#21 {main}

Please advice

Regards,

Wallace

 
Magento Community Magento Community
Magento Community
Magento Community
 
DouglasIanitsky
Jr. Member
 
Total Posts:  3
Joined:  2010-08-30
 

Hello friends.

I have self problem and I resolve this using singleton: http://www.htmlstaff.org/ver.php?id=4505

/**
 * Catalog Layer Attribute Filter Resource Model
 *
 * @category    Mage
 * @package     Mage_Catalog
 * @author      Magento Core Team <core@magentocommerce.com>
 */

include_once("FilterSingleton.php");

class 
Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute extends Mage_Core_Model_Mysql4_Abstract
{
    
/**
     * Initialize connection and define main table name
     *
     */
    
protected function _construct()
    
{
        $this
->_init('catalog/product_index_eav''entity_id');
    
}

    
/**
     * Apply attribute filter to product collection
     *
     * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
     * @param int $value
     * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute
     */
    
public function applyFilterToCollection($filter$value)
    
{
        
        $filterSingleton 
FilterSingleton::singleton();
        
        if (!isset(
$filterSingleton->return)) {
        
            $collection 
$filter->getLayer()->getProductCollection();
            
$attribute  $filter->getAttributeModel();
            
$connection $this->_getReadAdapter();
            
$tableAlias $attribute->getAttributeCode() . '_idx';
            
$conditions = array(
                
"{$tableAlias}.entity_id = e.entity_id",
                
$connection->quoteInto("{$tableAlias}.attribute_id = ?"$attribute->getAttributeId()),
                
$connection->quoteInto("{$tableAlias}.store_id = ?"$collection->getStoreId()),
                
$connection->quoteInto("{$tableAlias}.value = ?"$value)
            );
    
            
$collection->getSelect()->join(
                array(
$tableAlias => $this->getMainTable()),
                
join(' AND '$conditions),
                array()
            );
            
            
$filterSingleton->return $this;
    
            return 
$this;
            
        
else {
            
return $filterSingleton->return;
        
}
    }

    
/**
     * Retrieve array with products counts per attribute option
     *
     * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
     * @return array
     */
    
public function getCount($filter)
    
{
        
// clone select from collection with filters
        
$select = clone $filter->getLayer()->getProductCollection()->getSelect();
        
// reset columns, order and limitation conditions
        
$select->reset(Zend_Db_Select::COLUMNS);
        
$select->reset(Zend_Db_Select::ORDER);
        
$select->reset(Zend_Db_Select::LIMIT_COUNT);
        
$select->reset(Zend_Db_Select::LIMIT_OFFSET);

        
$connection $this->_getReadAdapter();
        
$attribute  $filter->getAttributeModel();
        
$tableAlias $attribute->getAttributeCode() . '_idx';
        
$conditions = array(
            
"{$tableAlias}.entity_id = e.entity_id",
            
$connection->quoteInto("{$tableAlias}.attribute_id = ?"$attribute->getAttributeId()),
            
$connection->quoteInto("{$tableAlias}.store_id = ?"$filter->getStoreId()),
        );

        
$select
            
->join(
                array(
$tableAlias => $this->getMainTable()),
                
join(' AND '$conditions),
                array(
'value''count' => "COUNT({$tableAlias}.entity_id)"))
            ->
group("{$tableAlias}.value");

        return 
$connection->fetchPairs($select);
    
}
}

class FilterSingleton {
    
    
static private $instance;
    
    public 
$return null;
    
    private function 
__construct() {
        
    }

    
static public function singleton() {
         
if (!isset(self::$instance)) {
            $c 
__CLASS__;
            
self::$instance = new $c;
        
}

        
return self::$instance;
    
}
}

I create a singleton class that save the self instance with the value that magento need and include a condition that verify if the value exist or not, in applyFilterToCollection method.

Work’s fine wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
miked2004
Sr. Member
 
Avatar
Total Posts:  214
Joined:  2007-12-13
Atlanta, Georgia
 

I know this is a slightly old post, but here is a little more info:Extra Info Link

 
Magento Community Magento Community
Magento Community
Magento Community
 
JeanDaPaul
Jr. Member
 
Total Posts:  29
Joined:  2009-02-20
 

To fix this problem just make sure there is only 1 line with <block type="catalog/layer_view" name="catalog.leftnav".......> 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.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rista86
Jr. Member
 
Total Posts:  1
Joined:  2012-02-24
 
JeanDaPaul - 02 December 2011 02:23 AM

To fix this problem just make sure there is only 1 line with <block type="catalog/layer_view" name="catalog.leftnav".......> 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.

Thanx, this saved my day!

 
Magento Community Magento Community
Magento Community
Magento Community
 
ketaki
Jr. Member
 
Total Posts:  8
Joined:  2012-02-28
 

I have same issue…
it is accrue when u define a layer block in both left and right side bar in catalog.xml or local.xml......

<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
/compare/sidebar.phtml"/>
</reference>

<reference name="right">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
so ...plz remove one of them.... grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
ketaki
Jr. Member
 
Total Posts:  8
Joined:  2012-02-28
 

http://justonestepsolution.blogspot.in/2013/01/you-cannot-define-a-correlation-name-coloridx-more-than-once-error-in-magento.html

Or you can refer the above link....very help full…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top