/** * BulkEditProductsStep2 * Save the changes made on the bulk editing page * * @return Void */ public function BulkEditProductsStep2() { if (isset($_POST["product_ids"])) { $product_ids = explode(",", $_POST["product_ids"]); // Only fetch products this user can actually edit $vendorRestriction = ''; if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { $vendorRestriction = " AND prodvendorid='" . (int) $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() . "'"; } // Load the existing products $existingProducts = array(); $query = "SELECT * FROM [|PREFIX|]products WHERE productid IN (" . implode(",", $GLOBALS['ISC_CLASS_DB']->Quote($product_ids)) . ") " . $vendorRestriction; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $existingProducts[$product['productid']] = $product; } foreach ($product_ids as $product_id) { $prodname = $_POST["prodname_" . $product_id]; $prodprice = DefaultPriceFormat($_POST["prodprice_" . $product_id]); $prodbrand = $_POST["prodbrand_" . $product_id]; $prodbrandold = $_POST["existing_brand_" . $product_id]; $prodbrandid = $_POST["existing_brand_id_" . $product_id]; $prodcats = $_POST["category_" . $product_id]; $prodcatsold = $_POST["existing_categories_" . $product_id]; $prodfeatured = 0; if (isset($_POST['prodfeatured_' . $product_id])) { $prodfeatured = 1; } $prodvisible = 0; if (isset($_POST['prodvisible_' . $product_id])) { $prodvisible = 1; } $prodfreeshipping = 0; if (isset($_POST['prodfreeshipping_' . $product_id])) { $prodfreeshipping = 1; } $prodCatsCSV = implode(",", $prodcats); // Calculate the new price of the product $existingProduct = $existingProducts[$product_id]; $prodcalculatedprice = CalcRealPrice($prodprice, $existingProduct['prodretailprice'], $existingProduct['prodsaleprice'], $existingProduct['prodistaxable']); // Do we need to update the categories? if ($prodCatsCSV != $prodcatsold) { $GLOBALS["ISC_CLASS_DB"]->DeleteQuery("categoryassociations", sprintf("WHERE productid='%d'", $product_id)); // Add the new category associations foreach ($prodcats as $cat_id) { $ca = array("productid" => $product_id, "categoryid" => $cat_id); $GLOBALS['ISC_CLASS_DB']->InsertQuery("categoryassociations", $ca); } } // Do we need to update the brand? if ($prodbrand != $prodbrandold) { if ($prodbrand != "") { // Is it an existing brand? $bquery = sprintf("SELECT brandid FROM [|PREFIX|]brands WHERE lower(brandname)='%s'", strtolower($prodbrand)); $bresult = $GLOBALS["ISC_CLASS_DB"]->Query($bquery); if ($brow = $GLOBALS["ISC_CLASS_DB"]->Fetch($bresult)) { // It's an existing brand $brand_id = $brow['brandid']; } else { // It's a new brand, let's add it $ba = array("brandname" => $prodbrand); $GLOBALS['ISC_CLASS_DB']->InsertQuery("brands", $ba); $brand_id = $GLOBALS["ISC_CLASS_DB"]->LastId(); } } else { // Delete the brand $brand_id = 0; } } else { // The brand hasn't been changed $brand_id = $prodbrandid; } if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() > 0) { $featuredColumn = 'prodvendorfeatured'; } else { $featuredColumn = 'prodfeatured'; } // Update the product details $pa = array("productid" => $product_id, "prodname" => $prodname, "prodprice" => $prodprice, "prodcalculatedprice" => $prodcalculatedprice, $featuredColumn => $prodfeatured, "prodvisible" => $prodvisible, "prodfreeshipping" => $prodfreeshipping, "prodbrandid" => $brand_id, "prodcatids" => $prodCatsCSV); $entity = new ISC_ENTITY_PRODUCT(); $entity->bulkEdit($pa); // Save the words to the product_words table for search spelling suggestions $this->SaveProductWords($prodname, $product_id, "editing"); } // Update product pricing $GLOBALS['ISC_CLASS_ADMIN_SETTINGS'] = GetClass('ISC_ADMIN_SETTINGS'); $GLOBALS['ISC_CLASS_ADMIN_SETTINGS']->_UpdateProductPrices(); // Do we want to keep editing or return to the products list? if (isset($_POST['keepediting'])) { $_POST['products'] = $product_ids; $this->BulkEditProductsStep1(GetLang("BulkEditUpdatedSuccessfully"), MSG_SUCCESS); } else { $this->ManageProducts(GetLang("BulkEditUpdatedSuccessfully"), MSG_SUCCESS); } } else { $this->ManageProducts(); } }
/** * Get the order record * * Method will return the order record * * @access public * @param int $orderId The order ID * @return array The order array on success, NULL if no record could be found, FALSE on error */ public function get($orderId) { if (!isId($orderId)) { return false; } $entity = array(); $result = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]orders WHERE orderid=" . (int) $orderId); if (!($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result))) { return null; } $entity = $row; $customer = new ISC_ENTITY_CUSTOMER(); $entity['customer'] = $customer->get($entity['ordcustid']); $product = new ISC_ENTITY_PRODUCT(); $entity['products'] = array(); $result = $GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]order_products WHERE orderorderid=" . (int) $orderId); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $entity['products'][] = $product->get($row['ordprodid']); $key = count($entity['products']) - 1; $entity['products'][$key]['prodorderquantity'] = $row['ordprodqty']; $entity['products'][$key]['prodorderamount'] = $row['ordprodcost']; } return $entity; }