1

I am working on Multivendor Extension in which i am trying to create multiple order on one checkout if the quote has products from multiple vendor.

Below is the code i am working on rewritten from Mage_Checkout_Model_Type_Onepage, When i click on place order the progress gets terminated in middle. i dont know what is going wrong

public function saveOrder()
{
$quote = $this->getQuote();

// First build an array with the items split by vendor
$sortedItems = array();
foreach ($quote->getAllItems() as $item) {
    $vendor = $item->getProduct()->getVendor(); // <- whatever you need
    if (! isset($sortedItems[$vendor])) {
        $sortedItems[$vendor] = $item;
    }
}
foreach ($sortedItems as $vendor => $items) {
    // Empty quote
    foreach ($quote->getAllItems() as $item) {
        $quote->removeItemByKey($item->getId());
    }
    foreach ($items as $item) {
        $quote->addItem($item);
    }
    // Update totals for vendor
    $quote->setTotalsCollectedFlag(false)->collectTotals();

    // Delegate to parent method to place an order for each vendor
    parent::saveOrder();
}
return $this;
}

if you have any alternative approach please share with me.

Deepak Mallah
  • 1,649
  • 2
  • 18
  • 25

1 Answers1

1

if somebody needs an answer for this:

I think the problem is, that there is the following call in the original function "saveOrder" of Onepage.php:

$this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
        ->setLastSuccessQuoteId($this->getQuote()->getId())
        ->clearHelperData();

the call "clearHelperData()" deletes the Session info and so u cant create further orders.