Пример #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;
 }
Пример #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;
 }
Пример #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;
 }
Пример #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;
 }
Пример #5
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     $newProduct->setSales(0);
     return $newProduct;
 }
Пример #6
0
 /**
  * {@inheritDoc}
  */
 public function cloneEntity()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'cloneEntity', array());
     return parent::cloneEntity();
 }
Пример #7
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newProduct = parent::cloneEntity();
     $this->cloneQuantity($newProduct);
     $this->cloneMembership($newProduct);
     return $newProduct;
 }