Esempio n. 1
0
 /**
  * Clone order item object. The product only is set additionally
  * since the order could be different and should be set manually
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newItem = parent::cloneEntity();
     if ($this->getObject()) {
         $newItem->setObject($this->getObject());
     }
     if ($this->hasAttributeValues()) {
         foreach ($this->getAttributeValues() as $av) {
             $cloned = $av->cloneEntity();
             $cloned->setOrderItem($newItem);
             $newItem->addAttributeValues($cloned);
         }
     }
     return $newItem;
 }
Esempio n. 2
0
 /**
  * Clone order and all related data
  * TODO: Decompose this method into several methods
  *
  * @return \XLite\Model\Order
  */
 public function cloneEntity()
 {
     // Clone order
     $newOrder = parent::cloneEntity();
     // Clone profile
     $newOrder->setOrigProfile($this->getOrigProfile());
     if ($this->getProfile()) {
         $clonedProfile = $this->getProfile()->cloneEntity();
         $newOrder->setProfile($clonedProfile);
         $clonedProfile->setOrder($newOrder);
     }
     // Clone order statuses
     $newOrder->setPaymentStatus($this->getPaymentStatus());
     $newOrder->setShippingStatus($this->getShippingStatus());
     // Clone currency
     $newOrder->setCurrency($this->getCurrency());
     // Clone order items
     foreach ($this->getItems() as $item) {
         $clonedItem = $item->cloneEntity();
         $clonedItem->setOrder($newOrder);
         $newOrder->addItems($clonedItem);
     }
     // Clone order details
     foreach ($this->getDetails() as $detail) {
         $clonedDetails = $detail->cloneEntity();
         $newOrder->addDetails($clonedDetails);
     }
     // Clone tracking numbers
     foreach ($this->getTrackingNumbers() as $tn) {
         $clonedTN = $tn->cloneEntity();
         $newOrder->addTrackingNumbers($clonedTN);
     }
     // Clone events
     foreach ($this->getEvents() as $event) {
         $cloned = $event->cloneEntity();
         $newOrder->addEvents($cloned);
         $cloned->setOrder($newOrder);
         $cloned->setAuthor($event->getAuthor());
     }
     // Clone surcharges
     foreach ($this->getSurcharges() as $surcharge) {
         $cloned = $surcharge->cloneEntity();
         $newOrder->addSurcharges($cloned);
         $cloned->setOwner($newOrder);
     }
     // Clone payment transactions
     foreach ($this->getPaymentTransactions() as $pt) {
         $cloned = $pt->cloneEntity();
         $newOrder->addPaymentTransactions($cloned);
         $cloned->setOrder($newOrder);
     }
     return $newOrder;
 }
Esempio n. 3
0
 /**
  * Clone order item object. The product only is set additionally
  * since the order could be different and should be set manually
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newItem = parent::cloneEntity();
     if ($this->getObject()) {
         $newItem->setObject($this->getObject());
     }
     return $newItem;
 }