protected function insert() { $this->product->get()->updateCategoryCounters($this->product->get()->getCountUpdateFilter(), $this->category->get()); $this->product->get()->registerAdditionalCategory($this->category->get()); $insertResult = parent::insert(); Category::updateCategoryIntervals($this->product->get()); return $insertResult; }
protected function insert() { $str = ''; for ($k = 0; $k < 20; $k++) { $str .= chr(rand(0, 255)); } $this->confirmationCode->set(substr(md5($str), 0, 12)); return parent::insert(); }
protected function insert() { $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('SearchLog', 'keywords'), $this->keywords->get())); $f->mergeCondition(new EqualsCond(new ARFieldHandle('SearchLog', 'ip'), $this->ip->get())); if (!ActiveRecordModel::getRecordCount(__CLASS__, $f)) { parent::insert(); $update = new ARUpdateFilter(); $update->addModifier('time', new ARExpressionHandle('NOW()')); $update->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'ID'), $this->getID())); ActiveRecordModel::updateRecordSet(__CLASS__, $update); } }
protected function insert() { self::beginTransaction(); $this->dateCreated->set(new ARSerializableDateTime()); parent::insert(); $summary = ProductRatingSummary::getInstance($this->product->get(), $this->ratingType->get()); $summary->save(); $f = new ARUpdateFilter(); $f->addModifier('ratingSum', new ARExpressionHandle('ratingSum+' . $this->rating->get())); $f->addModifier('ratingCount', new ARExpressionHandle('ratingCount+1')); $f->addModifier('rating', new ARExpressionHandle('ratingSum/ratingCount')); $this->updateRatings($f); self::commit(); }
protected function insert() { $res = parent::insert(); if ($subscriber = NewsletterSubscriber::getInstanceByEmail($this->email->get())) { $subscriber->user->set($this); } else { $subscriber = NewsletterSubscriber::getNewInstanceByUser($this); $subscriber->isEnabled->set(false); $subscriber->save(); } $subscriber->confirmationCode->set(''); $subscriber->save(); return $res; }
protected function insert() { parent::insert(); $this->parent->save(); }
protected function insert() { if (self::TYPE_CAPTURE == $this->type->get() || self::TYPE_SALE == $this->type->get()) { $this->order->get()->addCapturedAmount($this->amount->get()); } else { if (self::TYPE_VOID == $this->type->get()) { $parentType = $this->parentTransaction->get()->type->get(); if (self::TYPE_CAPTURE == $parentType || self::TYPE_SALE == $parentType) { $this->order->get()->addCapturedAmount(-1 * $this->parentTransaction->get()->amount->get()); } } } $this->order->get()->save(); if ($this->handler instanceof CreditCardPayment) { $this->setAsCreditCard(); $this->ccExpiryMonth->set($this->handler->getExpirationMonth()); $this->ccExpiryYear->set($this->handler->getExpirationYear()); $this->ccType->set($this->handler->getCardType()); $this->ccName->set($this->handler->getDetails()->getName()); $this->ccLastDigits->set($this->handler->getCardNumber()); // only the last 5 digits of credit card number are normally stored if (!$this->handler->isCardNumberStored()) { $this->truncateCcNumber(); } else { $this->ccCVV->set(self::encrypt($this->handler->getCardCode())); } $this->ccLastDigits->set(self::encrypt($this->ccLastDigits->get())); } if ($this->handler) { $this->method->set(get_class($this->handler)); } return parent::insert(); }
protected function insert() { $this->deleteInstancesByOrder($this->order->get()); return parent::insert(); }
protected function insert() { parent::insert(); $this->updateConditionRecordCount(); }
protected function insert() { $this->setLastPosition('category'); return parent::insert(); }
protected function insert() { $this->updateProductCounter(); $this->dateCreated->set(new ARSerializableDateTime()); return parent::insert(); }
protected function insert() { $this->setLastPosition(); parent::insert(); }
protected function insert() { if (!$this->shipment->get()->isExistingRecord()) { return false; } return parent::insert(); }
protected function insert() { $this->setLastPosition('productList'); return parent::insert(); }
protected function insert() { // the shipment objects are often restored from serialized state, so we must mark all fields as modified foreach ($this->data as $field) { if (!$field->isNull()) { $field->setAsModified(); } } // Save updated order status if ($this->order->get()->isFinalized->get()) { $this->order->get()->save(); } if (!$this->status->get()) { $this->status->set(self::STATUS_NEW); } return parent::insert(); }
protected function insert() { $this->updatePriceDiff(); return parent::insert(); }
/** * Save ActiveTreeNode data in database * * @return bool * * @throws Exception If failed to commit the transaction */ protected function insert() { ActiveRecordModel::beginTransaction(); try { $className = get_class($this); // Inserting new node $parentNode = $this->getField(self::PARENT_NODE_FIELD_NAME)->get(); if ($parentNode) { if (!$parentNode->isLoaded()) { $parentNode->load(); } } else { $parentNode = $this; } $parentRightValue = $parentNode->getFieldValue(self::RIGHT_NODE_FIELD_NAME); $nodeLeftValue = $parentRightValue; $nodeRightValue = $nodeLeftValue + 1; $tableName = self::getSchemaInstance(get_class($this))->getName(); $db = self::getDBConnection(); $updates[] = "UPDATE {$className} SET " . self::RIGHT_NODE_FIELD_NAME . " = " . self::RIGHT_NODE_FIELD_NAME . " + 2 WHERE " . self::RIGHT_NODE_FIELD_NAME . " >= {$parentRightValue}"; $updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . " = " . self::LEFT_NODE_FIELD_NAME . " + 2 WHERE " . self::LEFT_NODE_FIELD_NAME . " >= {$parentRightValue}"; foreach ($updates as $update) { self::getLogger()->logQuery($update); $db->executeUpdate($update); } $this->getField(self::RIGHT_NODE_FIELD_NAME)->set($nodeRightValue); $this->getField(self::LEFT_NODE_FIELD_NAME)->set($nodeLeftValue); ActiveRecordModel::commit(); foreach (ActiveRecord::retrieveFromPool(get_class($this)) as $instance) { if ($instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) >= $parentRightValue) { $instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, $instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) + 2); } if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) >= $parentRightValue) { $instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, $instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) + 2); } } } catch (Exception $e) { ActiveRecordModel::rollback(); throw $e; } return parent::insert(); }
protected function insert() { // get max position $f = new ARSelectFilter(self::getFilter($this->product->get())->getCondition()); $f->setOrder(new ARFieldHandle(__CLASS__, "position"), 'DESC'); $f->setLimit(1); $rec = ActiveRecord::getRecordSetArray(__CLASS__, $f); $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 0; $this->position->set($position); return parent::insert(); }
protected function insert() { $this->time->set(new ARSerializableDateTime()); return parent::insert(); }
protected function insert() { // check currency symbol if (!$this->pricePrefix->get() && !$this->priceSuffix->get()) { $prefixes = (include ClassLoader::getRealPath('installdata.currency.signs') . '.php'); if (isset($prefixes[$this->getID()])) { $signs = $prefixes[$this->getID()]; $this->pricePrefix->set($signs[0]); if (isset($signs[1])) { $this->priceSuffix->set($signs[1]); } } } // check if default currency exists if (!ActiveRecord::getRecordSet('Currency', select(eq('Currency.isDefault', 1)))->getTotalRecordCount()) { $this->isDefault->set(true); $this->isEnabled->set(true); } $this->setLastPosition(); return parent::insert(); }
protected function insert() { // get max position $f = self::getRelatedProductsSetFilter($this->product->get(), $this->type->get()); $f->setLimit(1); $rec = ActiveRecord::getRecordSetArray('ProductRelationship', $f); $position = is_array($rec) && count($rec) > 0 ? $rec[0]['position'] + 1 : 0; $this->position->set($position); return parent::insert(); }