public function save($forceOperation = false) { if (!$this->isExistingRecord()) { $this->setNextPosition(); } parent::save($forceOperation); }
public function save($forceOperation = false) { parent::save($forceOperation); if ($this->newFileUploaded) { $this->moveFile(); } }
public function save($forceOperation = null) { $this->loadFile(); if (!$this->handle->get()) { $this->handle->set(createHandleString($this->getValueByLang('title'))); } parent::save($forceOperation); $this->saveFile(); }
/** * @todo move the SKU checking to insert() - otherwise seems to break some tests for now */ public function save($forceOperation = null) { self::beginTransaction(); if ($this->manufacturer->get()) { $this->manufacturer->get()->save(); } // update parent inventory counter if ($this->stockCount->isModified() && $this->parent->get()) { $stockDifference = $this->stockCount->get() - $this->stockCount->getInitialValue(); $this->parent->get()->stockCount->set($this->parent->get()->stockCount->get() + $stockDifference); $this->parent->get()->save(); } parent::save($forceOperation); // generate SKU automatically if not set if (!$this->sku->get()) { ClassLoader::import('application.helper.check.IsUniqueSkuCheck'); if (!$this->parent->get()) { $sku = $this->getID(); do { $check = new IsUniqueSkuCheck('', $this); $exists = $check->isValid('SKU' . $sku); if (!$exists) { $sku = '0' . $sku; } } while (!$exists); $sku = 'SKU' . $sku; } else { $sku = $this->parent->get()->sku->get() . '-'; $k = 0; do { $k++; $check = new IsUniqueSkuCheck('', $this); $exists = $check->isValid($sku . $k); } while (!$exists); $sku .= $k; } $this->sku->set($sku); parent::save(); } $this->getSpecification()->save(); $this->getPricingHandler()->save(); $this->saveRelationships(); Category::updateCategoryIntervals($this->getID()); self::commit(); }
public function save($forceOperation = null) { if ($this->deliveryZone->get() && 0 == $this->deliveryZone->get()->getID()) { $this->deliveryZone->set(null); } return parent::save($forceOperation); }
public function save($forceOperation = false) { parent::save($forceOperation); $this->mergeFields(); }
public function save() { parent::save(); // set as main image if it's the first image being uploaded if ($this->position->get() == 0) { $owner = $this->getOwner(); $owner->defaultImage->set($this); $owner->save(); } }
public function save($forceOperation = null) { // update inventory $shipment = $this->shipment->get(); if (!$shipment && $this->parent->get()) { $shipment = $this->parent->get()->shipment->get(); } $order = $this->customerOrder->get(); if ($shipment && $order->isFinalized->get() && !$order->isCancelled->get() && self::getApplication()->isInventoryTracking()) { $product = $this->getProduct(); // changed product (usually a different variation) if ($this->product->isModified()) { // unreserve original item if ($orig = $this->product->getInitialValue()) { if (is_string($orig)) { $orig = Product::getInstanceById($orig, true); } $this->reserve(true, $orig); $orig->save(); } // reserve new item $this->reserve(); } if ($this->reservedProductCount->get() > 0 && $shipment->status->get() == Shipment::STATUS_SHIPPED) { $this->removeFromInventory(); } else { if (0 == $this->reservedProductCount->get()) { if ($shipment->status->get() == Shipment::STATUS_RETURNED) { $this->reservedProductCount->set($this->count->get()); $product->reservedCount->set($product->reservedCount->get() + $this->count->get()); } else { $this->reserve(); } } else { if ($this->count->isModified()) { $delta = $this->count->get() - $this->reservedProductCount->get(); $this->reservedProductCount->set($this->count->get()); $product->reservedCount->set($product->reservedCount->get() + $delta); $product->stockCount->set($product->stockCount->get() - $delta); } } } } $ret = parent::save($forceOperation); // save options foreach ($this->removedChoices as $rem) { $rem->delete(); } foreach ($this->optionChoices as $choice) { $choice->save(); } // save sub-items for bundles if ($this->getProduct()->isBundle()) { foreach ($this->getSubItems() as $item) { $item->save(); } } $this->getProduct()->save(); $this->subItems = null; return $ret; }