/** * Clone * * @return \XLite\Model\Profile */ public function cloneEntity() { $newProfile = parent::cloneEntity(); if (!$newProfile->update(true) || !$newProfile->getProfileId()) { // TODO - add throw exception \XLite::getInstance()->doGlobalDie('Can not clone profile'); } $newProfile->setMembership($this->getMembership()); $newProfile->setPendingMembership($this->getPendingMembership()); $newProfile->setPassword(''); $billingAddress = $this->getBillingAddress(); if (null !== $billingAddress) { $newBillingAddress = $billingAddress->cloneEntity(); $newBillingAddress->setProfile($newProfile); $newProfile->addAddresses($newBillingAddress); $newBillingAddress->update(); } $shippingAddress = $this->getShippingAddress(); if ($shippingAddress && (!$billingAddress || $billingAddress->getAddressId() != $shippingAddress->getAddressId())) { $newShippingAddress = $shippingAddress->cloneEntity(); $newShippingAddress->setProfile($newProfile); $newProfile->addAddresses($newShippingAddress); $newShippingAddress->update(); } $newProfile->update(true); return $newProfile; }
/** * Clone * * @return \XLite\Model\AEntity */ public function cloneEntity() { $newEntity = parent::cloneEntity(); if ($this->getSku()) { $newEntity->setSku(\XLite\Core\Database::getRepo('XLite\\Module\\XC\\ProductVariants\\Model\\ProductVariant')->assembleUniqueSKU($this->getSku())); } return $newEntity; }
/** * Clone * * @return \XLite\Model\AEntity */ public function cloneEntity() { $entity = parent::cloneEntity(); if ($this->getCountry()) { $entity->setCountry($this->getCountry()); } if ($this->getState()) { $entity->setState($this->getState()); } return $entity; }
/** * Clone * * @return \XLite\Model\AEntity */ public function cloneEntity() { $entity = parent::cloneEntity(); foreach ($entity->getSoftTranslation()->getRepository()->findBy(array('owner' => $entity)) as $translation) { $newTranslation = $translation->cloneEntity(); $newTranslation->setOwner($entity); $entity->addTranslations($newTranslation); \XLite\Core\Database::getEM()->persist($newTranslation); } return $entity; }
/** * Clone attribute value of order item * * @return \XLite\Model\OrderItem\AttributeValue */ public function cloneEntity() { $new = parent::cloneEntity(); if ($this->getAttributeValue()) { $new->setAttributeValue($this->getAttributeValue()); } return $new; }
/** * Clone payment transaction * * @return \XLite\Model\Payment\Transaction */ public function cloneEntity() { $newTransaction = parent::cloneEntity(); $newTransaction->setCurrency($this->getCurrency()); $newTransaction->setOrder($this->getOrder()); $newTransaction->setPaymentMethod($this->getPaymentMethod()); return $newTransaction; }
/** * Clone * * @return \XLite\Model\AEntity */ public function cloneEntity() { $newProfile = parent::cloneEntity(); if (!$newProfile->update(true) || !$newProfile->getProfileId()) { // TODO - add throw exception \XLite::getInstance()->doGlobalDie('Can not clone profile'); } $newProfile->setMembership($this->getMembership()); $newProfile->setPendingMembership($this->getPendingMembership()); $billingAddress = $this->getBillingAddress(); if (isset($billingAddress)) { $newBillingAddress = $billingAddress->cloneEntity(); $newBillingAddress->setProfile($newProfile); $newProfile->addAddresses($newBillingAddress); $newBillingAddress->update(); } if (!$this->isSameAddress() && $this->getShippingAddress()) { $newShippingAddress = $this->getShippingAddress()->cloneEntity(); $newShippingAddress->setProfile($newProfile); $newProfile->addAddresses($newShippingAddress); $newShippingAddress->update(); } $newProfile->update(true); return $newProfile; }
/** * Clone object * * @param boolean $cloneItems Clone parcel items * * @return \XLite\Model\AEntity */ public function cloneEntity($cloneItems = true) { $newParcel = parent::cloneEntity(); if ($this->getOrder()) { $newParcel->setOrder($this->getOrder()); } if ($cloneItems && $this->hasItems()) { foreach ($this->getItems() as $item) { $newParcel->addItem($item); } } return $newParcel; }
/** * Clone order item option object * * @return \XLite\Model\AEntity */ public function cloneEntity() { $entity = parent::cloneEntity(); if ($this->getOption()) { $entity->setOption($this->getOption()); } if ($this->getGroup()) { $entity->setGroup($this->getGroup()); } return $entity; }