/** * {@inheritDoc} */ public function getPrices() { if (!parent::getPrices()) { $this->_loadPrices(); } return parent::getPrices(); }
/** * Save bundle prices to the database. * * @param Bundle $bundle The bundle the prices are assigned to * @param bool $delete If set to true, will delete prices currently assigned to database. True by default. */ public function save(Bundle $bundle, $delete = true) { if ($delete) { $this->_query->run("\n\t\t\t\tDELETE FROM\n\t\t\t\t\tdiscount_bundle_price\n\t\t\t\tWHERE\n\t\t\t\t\tbundle_id = :bundleID?i\n\t\t\t", ['bundleID' => $bundle->getID()]); } $statements = []; foreach ($bundle->getPrices() as $currency => $price) { $statement = '( :bundleID?i, :currency?s, :price?f )'; $params = ['bundleID' => $bundle->getID(), 'currency' => $currency, 'price' => $price]; $statements[] = $this->_queryParser->parse($statement, $params); } $statements = implode(',' . PHP_EOL, $statements); $this->_query->run("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tdiscount_bundle_price\n\t\t\t\t\t(\n\t\t\t\t\t\tbundle_id,\n\t\t\t\t\t\tcurrency,\n\t\t\t\t\t\tprice\n\t\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t" . $statements); }