/**
     * 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);
    }
 /**
  * Save product data assigned to a bundle to the database
  *
  * @param Bundle $bundle   The bundle the product rows are assigned to
  * @param bool $delete     If set to true, existing product rows for the bundle will be deleted. 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_product_row\n\t\t\t\tWHERE\n\t\t\t\t\tbundle_id = :bundleID?i\n\t\t\t", ['bundleID' => $bundle->getID()]);
         $this->_query->run("\n\t\t\t\tDELETE FROM\n\t\t\t\t\tdiscount_bundle_product_option\n\t\t\t\tWHERE\n\t\t\t\t\tbundle_id = :bundleID?i\n\t\t\t", ['bundleID' => $bundle->getID()]);
     }
     foreach ($bundle->getProductRows() as $row) {
         $result = $this->_query->run("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tdiscount_bundle_product_row\n\t\t\t\t\t(\n\t\t\t\t\t\tbundle_id,\n\t\t\t\t\t\tproduct_id,\n\t\t\t\t\t\tquantity\n\t\t\t\t\t)\n\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t:bundleID?i,\n\t\t\t\t\t\t:productID?i,\n\t\t\t\t\t\t:quantity?i\n\t\t\t\t\t)\n\t\t\t", ['bundleID' => $bundle->getID(), 'productID' => $row->getProductID(), 'quantity' => $row->getQuantity()]);
         $statements = [];
         if (count($row->getOptions()) > 0) {
             foreach ($row->getOptions() as $name => $value) {
                 $statement = "\n\t\t\t\t\t(\n\t\t\t\t\t\t:rowID?i,\n\t\t\t\t\t\t:bundleID?i,\n\t\t\t\t\t\t:name?s,\n\t\t\t\t\t\t:value?s\n\t\t\t\t\t)";
                 $params = ['rowID' => $result->id(), 'bundleID' => $bundle->getID(), 'name' => $name, 'value' => $value];
                 $statements[] = $this->_queryParser->parse($statement, $params);
             }
             $statements = implode(',' . PHP_EOL, $statements);
             $this->_query->run("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tdiscount_bundle_product_option\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tproduct_row_id,\n\t\t\t\t\t\t\tbundle_id,\n\t\t\t\t\t\t\toption_name,\n\t\t\t\t\t\t\toption_value\n\t\t\t\t\t\t)\n\t\t\t\t\tVALUES\n\t\t\t\t" . $statements);
         }
     }
 }