Esempio n. 1
0
 /**
  * Insert single entity
  *
  * @param \XLite\Model\AEntity|array $entity Data to insert OPTIONAL
  *
  * @return \XLite\Model\AEntity|array
  */
 protected function performInsert($entity = null)
 {
     $entity = parent::performInsert($entity);
     if ($entity && !$this->getBlockQuickDataFlag()) {
         $entity->updateQuickData();
     }
     return $entity;
 }
Esempio n. 2
0
 /**
  * Insert single entity
  *
  * @param \XLite\Model\AEntity|array $entity Data to insert OPTIONAL
  *
  * @return void
  */
 protected function performInsert($entity = null)
 {
     $entity = parent::performInsert($entity);
     $parentID = $entity->getParentId();
     if (empty($parentID)) {
         // Insert root category
         $this->prepareNewCategoryData($entity);
     } else {
         // Get parent for non-root category
         $parent = $this->getCategory($parentID);
         if ($parent) {
             // Update indexes in the nested set
             $this->defineUpdateIndexQuery('lpos', $parent->getLpos())->execute();
             $this->defineUpdateIndexQuery('rpos', $parent->getLpos())->execute();
             // Create record in DB
             $this->prepareNewCategoryData($entity, $parent);
         } else {
             \Includes\ErrorHandler::fireError(__METHOD__ . ': category #' . $parentID . ' not found');
         }
     }
     // Update quick flags
     if (isset($parent)) {
         $this->updateQuickFlags($parent, $this->prepareQuickFlags(1, $entity->getEnabled() ? 1 : -1));
     }
     return $entity;
 }
Esempio n. 3
0
 /**
  * Insert single entity
  *
  * @param \XLite\Model\Category|array $entity Data to insert OPTIONAL
  *
  * @return \XLite\Model\Category
  */
 protected function performInsert($entity = null)
 {
     /** @var \XLite\Model\Category $entity */
     $entity = parent::performInsert($entity);
     $parentID = $entity->getParentId();
     if (empty($parentID)) {
         // Insert root category
         $this->prepareNewCategoryData($entity);
     } else {
         // Get parent for non-root category
         $parent = $this->getCategory($parentID);
         if ($parent) {
             // Reload parent category from database to get correct value of indexes
             // after batch update in previous call of performInsert on import
             \XLite\Core\Database::getEM()->refresh($parent);
             // Update indexes in the nested set
             $this->defineUpdateIndexQuery('lpos', $parent->getLpos())->execute();
             $this->defineUpdateIndexQuery('rpos', $parent->getLpos())->execute();
             // Create record in DB
             $this->prepareNewCategoryData($entity, $parent);
         } else {
             \Includes\ErrorHandler::fireError(__METHOD__ . ': category #' . $parentID . ' not found');
         }
     }
     // Update quick flags
     if (isset($parent) && null == $entity->getCategoryId()) {
         $this->updateQuickFlags($parent, $this->prepareQuickFlags(1, $entity->getEnabled() ? 1 : -1));
     }
     return $entity;
 }
Esempio n. 4
0
 /**
  * Insert single entity
  *
  * @param \XLite\Model\AEntity|array $entity Data to insert OPTIONAL
  *
  * @return void
  */
 protected function performInsert($entity = null)
 {
     $entity = parent::performInsert($entity);
     if ($entity && !\XLite\Core\Database::getRepo('XLite\\Model\\Product')->getBlockQuickDataFlag()) {
         \XLite\Core\QuickData::getInstance()->updateMembershipData($entity);
     }
     return $entity;
 }