0

I have two different collection one is of order payment transaction and other one is of sales order as show below:

$transactionData=Mage::getModel('sales/order_payment_transaction')->getCollection();
$orderData=Mage::getModel('sales/order')->getCollection();

I want to combine them into single collection. Also where can I find payment method cause I don`t see it under orderData or transactionData collection.

0

You can not merge two different collection in one

you can merge two same collection in one same as below example

$collection1 = Mage::getModel('catalog/category')->load(148)->getProductCollection();
$collection2 = Mage::getModel('catalog/category')->load(149)->getProductCollection();

$merged_ids = array_merge($collection1->getAllIds(), $collection2->getAllIds());
// can sometimes use "getLoadedIds()" as well

$merged_collection = Mage::getResourceModel('catalog/product_collection')
    ->addFieldToFilter('entity_id', array('in' => $merged_ids))
    ->addAttributeToSelect('*');

You can try one work around for your solution, you can create required field array from both collection and use it.

0

you can try below code to merge two collection in Magento Query


$transactionData=Mage::getModel('sales/order_payment_transaction')->getCollection()->getSelect();
$orderData=Mage::getModel('sales/order')->getCollection()->getSelect();
$mergeCollection = $transactionData->union(array($orderData));

you can use unionall to prevent duplicate records.

  • Your solution did`nt work for me! – Darshan Jethwa Jun 25 '18 at 16:55
  • is it showing any error ?? or you can not get result. – MR.R DNATH Jun 25 '18 at 17:59
  • Nope it is not showing any error but I cannot see any output when I var_dump it! – Darshan Jethwa Jun 25 '18 at 18:13
  • try echo $mergeCollection->getSelect() – MR.R DNATH Jun 25 '18 at 19:18
  • Still the same! – Darshan Jethwa Jun 25 '18 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.