Skip to main content
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help

Edit 1 The my_views_table consists of 3 columns, namely:

  1. id (primary key)
  2. entity_id
  3. count

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help

Edit 1 The my_views_table consists of 3 columns, namely:

  1. id (primary key)
  2. entity_id
  3. count

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help

Edit 1 The my_views_table consists of 3 columns, namely:

  1. id (primary key)
  2. entity_id
  3. count
added 113 characters in body
Source Link
Moose
  • 7.5k
  • 7
  • 49
  • 92

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help

Edit 1 The my_views_table consists of 3 columns, namely:

  1. id (primary key)
  2. entity_id
  3. count

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help

Edit 1 The my_views_table consists of 3 columns, namely:

  1. id (primary key)
  2. entity_id
  3. count
Source Link
Moose
  • 7.5k
  • 7
  • 49
  • 92

Magento Custom Grid Left Join ID Conflict with Custom Table

I've got the following left join in my _prepareCollection(); method:

$collection->getSelect()->joinLeft(
        array('views_index' => "my_views_table"),
        'views_index.entity_id = main_table.entity_id',
        array('views'=>'count')
);

And then in my _prepareColumns() method I have:

$this->addColumn('views',
        array(
            'header'=> $this->__('Views'),
            'index' => 'views',
            'width' => '5%',
            'filter_index'  => 'views_index.count'
        )
);

When I load this page though, I get an error:

Item (Namespace_Module_Model_Mymodel) with the same id "{ID}" already exist

How is this conflict occurring?

Some background: Magento Custom Grid Redirect Error (On Join Attributes ONLY)

Would appreciate any help