Skip to content

Instantly share code, notes, and snippets.

@mrkhoa99
Created March 12, 2017 15:41
Show Gist options
  • Save mrkhoa99/904e21aed68cbff0b10a607aecc94c1c to your computer and use it in GitHub Desktop.
Save mrkhoa99/904e21aed68cbff0b10a607aecc94c1c to your computer and use it in GitHub Desktop.
Magento 2 strick
1) Using an expression as a join: new Zend_Db_Expr
$query = 'SELECT author_id, SUM(amount) AS author_debit_amount FROM author_debits GROUP BY author_debits.author_id';
$collection->getSelect()->joinLeft(
new Zend_Db_Expr('('.$query.')'),
'main_table.author_id = t.author_id',
array('author_debit_amount')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment