Skip to main content
edited tags
Link
Fabian Schmengler
  • 66.1k
  • 25
  • 188
  • 422
More details added
Source Link
Akhil Gupta
  • 2k
  • 1
  • 17
  • 30

I am trying to use a join query in Magento Abandoned Grid this way:

 $collection->getSelect()->joinLeft(
                        'abandoned_comment_history', 'main_table.customer_id=abandoned_comment_history.customer_id', array('admin_comment', 'comment_datetime', 'status'))
                ->group('main_table.customer_id');

In my custom table abandoned_comment_history there are multiple matches with main table.customer_id & i am getting the first one but i need last one.

Is there any way to get the last match from my custom table. I searched a lot but couldn't find the solution. Hope will get here.

Description: In my table abandoned_comment_history have some data as

id customer_id admin_comment
1     2082      Test 1
2     2082      Test 2
3     2091      Hello

In main_table customer_id column is unique.

  customer_id 
     2082      
     2084      
     2091      

Now if i try to join & get admin_comment value i get "Test 1" but i need "Test 2"

I am trying to use a join query in Magento Abandoned Grid this way:

 $collection->getSelect()->joinLeft(
                        'abandoned_comment_history', 'main_table.customer_id=abandoned_comment_history.customer_id', array('admin_comment', 'comment_datetime', 'status'))
                ->group('main_table.customer_id');

In my custom table abandoned_comment_history there are multiple matches with main table.customer_id & i am getting the first one but i need last one.

Is there any way to get the last match from my custom table. I searched a lot but couldn't find the solution. Hope will get here.

I am trying to use a join query in Magento Abandoned Grid this way:

 $collection->getSelect()->joinLeft(
                        'abandoned_comment_history', 'main_table.customer_id=abandoned_comment_history.customer_id', array('admin_comment', 'comment_datetime', 'status'))
                ->group('main_table.customer_id');

In my custom table abandoned_comment_history there are multiple matches with main table.customer_id & i am getting the first one but i need last one.

Is there any way to get the last match from my custom table. I searched a lot but couldn't find the solution. Hope will get here.

Description: In my table abandoned_comment_history have some data as

id customer_id admin_comment
1     2082      Test 1
2     2082      Test 2
3     2091      Hello

In main_table customer_id column is unique.

  customer_id 
     2082      
     2084      
     2091      

Now if i try to join & get admin_comment value i get "Test 1" but i need "Test 2"

Source Link
Akhil Gupta
  • 2k
  • 1
  • 17
  • 30

How to sort the order of Magento joinLeft

I am trying to use a join query in Magento Abandoned Grid this way:

 $collection->getSelect()->joinLeft(
                        'abandoned_comment_history', 'main_table.customer_id=abandoned_comment_history.customer_id', array('admin_comment', 'comment_datetime', 'status'))
                ->group('main_table.customer_id');

In my custom table abandoned_comment_history there are multiple matches with main table.customer_id & i am getting the first one but i need last one.

Is there any way to get the last match from my custom table. I searched a lot but couldn't find the solution. Hope will get here.