-
-
Save reillo/4f9d7c0583c7b97a3a898d2914d9b837 to your computer and use it in GitHub Desktop.
Copy a Magento collection
This file contains hidden or 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
$originalCollection = Mage::getModel('catalog/product') | |
->getCollection(); | |
$newCollection = Mage::getModel('catalog/product') | |
->getCollection(); | |
$selectParts = array( | |
Varien_Db_Select::DISTINCT, | |
Varien_Db_Select::COLUMNS, | |
Varien_Db_Select::UNION, | |
Varien_Db_Select::FROM, | |
Varien_Db_Select::WHERE, | |
Varien_Db_Select::GROUP, | |
Varien_Db_Select::HAVING, | |
Varien_Db_Select::ORDER, | |
Varien_Db_Select::LIMIT_COUNT, | |
Varien_Db_Select::LIMIT_OFFSET, | |
Varien_Db_Select::FOR_UPDATE, | |
); | |
$originalSelect = $originalCollection->getSelect(); | |
$newSelect = $newCollection->getSelect(); | |
foreach ($selectParts as $part) { | |
$newSelect->setPart( | |
$part, | |
$originalSelect->getPart($part) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment