Last active
January 11, 2021 14:51
-
-
Save Luxato/a5c9b8f9adb3518d4dac39f2b9bb2bdf to your computer and use it in GitHub Desktop.
Magento 1 join collection with table created by subquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$productCollection->getSelect()->join( | |
new Zend_Db_Expr("(SELECT product_id, SUM(impressions) as impressions, SUM(clicks) as clicks, SUM(cart) as cart, SUM(conversions) as conversions, round(SUM(profit), 2) as profit, round(SUM(profit)/SUM(impressions), 3) as rpi | |
FROM evermart_crosssells_statistics_daily" . | |
($dateFilter ? " WHERE $dateFilter" : "") | |
. " GROUP BY product_id)"), | |
't.product_id = e.entity_id', | |
array('t.impressions','t.clicks', 't.cart', 't.conversions', 't.profit', 't.rpi') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment