public function create(UploadRecord $record) { $this->_transaction->add("\n\t\t\tINSERT INTO\n\t\t\t\tproduct_page_upload_record\n\t\t\t\t(\n\t\t\t\t\tpage_id,\n\t\t\t\t\tproduct_id,\n\t\t\t\t\tunit_id,\n\t\t\t\t\tconfirmed_at,\n\t\t\t\t\tconfirmed_by\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t:pageID?i,\n\t\t\t\t\t:productID?in,\n\t\t\t\t\t:unitID?in,\n\t\t\t\t\t:confirmedAt?dn,\n\t\t\t\t\t:confirmedBy?in\n\t\t\t\t)\n\t\t", ['pageID' => $record->getPageID(), 'productID' => $record->getProductID(), 'unitID' => $record->getUnitID(), 'confirmedAt' => $record->getConfirmedAt(), 'confirmedBy' => $record->getConfirmedBy()]); if (!$this->_transOverride) { $this->_transaction->commit(); } }
/** * Update the prices for the product * * @param Product $product Product object to update * * @return Product Saved Product object */ public function savePrices(Product $product) { $options = array(); $inserts = array(); foreach ($product->getPrices() as $type => $price) { foreach ($price->getCurrencies() as $currency) { $options[] = $product->id; $options[] = $type; $options[] = $product->getPrices()[$type]->getPrice($currency, $this->_locale); $options[] = $currency; $options[] = $this->_locale->getID(); $inserts[] = '(?i,?s,?s,?s,?s)'; } } $this->_trans->add('REPLACE INTO product_price ( product_id, type, price, currency_id, locale ) VALUES ' . implode(',', $inserts) . ' ', $options); if (!$this->_transOverridden) { $this->_trans->commit(); } return $product; }
/** * Commits transaction and (if successful) fires stock movement event * @return bool true if commit was successful */ public function commit() { $commit = $this->_transaction->commit(); if ($commit) { $this->_eventDispatcher->dispatch(Events::STOCK_MOVEMENT, new Movement\MovementEvent($this->_movement)); return true; } return false; }
/** * Commit the database transaction if the transaction has not been overridden */ private function _commitTransaction() { if (false === $this->_transOverride) { $this->_transaction->commit(); } }