Example #1
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     foreach ($this->getAttachments() as $attachment) {
         $attachment->cloneEntityForProduct($newProduct);
     }
     $newProduct->update(true);
     return $newProduct;
 }
Example #2
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     if ($this->getUpsellingProducts()) {
         $this->cloneUpsellingLinks($newProduct, false);
     }
     if ($this->getUpsellingParentProducts()) {
         $this->cloneUpsellingLinks($newProduct, true);
     }
     return $newProduct;
 }
Example #3
0
 /**
  * Clone product
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     if ($this->getTabs()) {
         foreach ($this->getTabs() as $tab) {
             $newTab = $tab->cloneEntity();
             $newTab->setProduct($newProduct);
             $newProduct->addTabs($newTab);
             \XLite\Core\Database::getEM()->persist($newTab);
         }
     }
     return $newProduct;
 }
Example #4
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     if ($this->mustHaveVariants()) {
         $attrs = array();
         foreach ($this->getVariantsAttributes() as $a) {
             if ($a->getProduct()) {
                 $cnd = new \XLite\Core\CommonCell();
                 $cnd->product = $newProduct;
                 $cnd->name = $a->getName();
                 $cnd->type = $a->getType();
                 $attribute = array_pop(\XLite\Core\Database::getRepo('\\XLite\\Model\\Attribute')->search($cnd));
             } else {
                 $attribute = $a;
             }
             $attrs[$a->getId()] = $attribute;
             $newProduct->addVariantsAttributes($attribute);
             $attribute->addVariantsProduct($newProduct);
         }
         foreach ($this->getVariants() as $variant) {
             $newVariant = $variant->cloneEntity();
             $newVariant->setProduct($newProduct);
             $newProduct->addVariants($newVariant);
             \XLite\Core\Database::getEM()->persist($newVariant);
             foreach ($variant->getValues() as $av) {
                 $attribute = $attrs[$av->getAttribute()->getId()];
                 foreach ($attribute->getAttributeValue($newProduct) as $v) {
                     if ($v->asString() === $av->asString()) {
                         $method = 'addAttributeValue' . $attribute->getType();
                         $newVariant->{$method}($v);
                         $v->addVariants($newVariant);
                     }
                 }
             }
         }
         $newProduct->update(true);
     }
     return $newProduct;
 }
Example #5
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     $newProduct->setSales(0);
     return $newProduct;
 }
 /**
  * {@inheritDoc}
  */
 public function cloneEntity()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'cloneEntity', array());
     return parent::cloneEntity();
 }
Example #7
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     $this->cloneQuantity($newProduct);
     $this->cloneMembership($newProduct);
     return $newProduct;
 }