public function SetPanelSettings() { $count = 0; $GLOBALS['SNIPPETS']['HomeSaleProducts'] = ''; if (GetConfig('HomeNewProducts') == 0) { $this->DontDisplay = true; return; } if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE p.prodsaleprice != 0 AND p.prodsaleprice < p.prodprice AND p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY RAND()\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeNewProducts')); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); // Determine the price of this product $originalPrice = CalcRealPrice(CalcProdCustomerGroupPrice($row, $row['prodprice']), 0, 0, $row['prodistaxable']); $GLOBALS['OriginalProductPrice'] = CurrencyConvertFormatPrice($originalPrice); $GLOBALS['ProductPrice'] = CalculateProductPrice($row); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Workout the product description $desc = strip_tags($row['proddesc']); if (isc_strlen($desc) < 120) { $GLOBALS['ProductSummary'] = $desc; } else { $GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "..."; } $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); $GLOBALS['SNIPPETS']['HomeSaleProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeSaleProductsItem"); if (!$GLOBALS['SNIPPETS']['HomeSaleProducts']) { $this->DontDisplay = true; return; } } }
public function SetPanelSettings() { if ($GLOBALS['ISC_CLASS_PRODUCT']->GetRelatedProducts() != "") { $output = ""; if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\t\t\tSELECT p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, i.imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid)\n\t\t\t\t\tWHERE p.prodvisible='1' AND p.productid IN (" . $GLOBALS['ISC_CLASS_PRODUCT']->GetRelatedProducts() . ") AND i.imageisthumb=1\n\t\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\t\tORDER BY prodsortorder ASC\n\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = (int) $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice($row); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; $thumb = $GLOBALS['ShopPath'] . "/" . GetConfig('ImageDirectory') . "/" . isc_html_escape($row['imagefile']); $GLOBALS['ProductThumb'] = '<img src="' . $thumb . '" alt="" />'; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideRelatedProducts"); } $GLOBALS['SNIPPETS']['SideProductsRelated'] = $output; } else { // No related products, hide the panel $GLOBALS['HideRelatedProductsPanel'] = "none"; $this->DontDisplay = true; } } else { // No related products, hide the panel $GLOBALS['HideRelatedProductsPanel'] = "none"; $this->DontDisplay = true; } }
public function SetPanelSettings() { $GLOBALS['AlsoBoughtProductListing'] = ''; $query = "\n\t\t\tSELECT ordprodid\n\t\t\tFROM [|PREFIX|]order_products\n\t\t\tWHERE orderorderid IN (SELECT orderorderid FROM [|PREFIX|]order_products WHERE ordprodid='" . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "') AND ordprodid != " . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "\n\t\t\tGROUP BY ordprodid\n\t\t\tORDER BY COUNT(ordprodid) DESC\n\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 10); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $productIds = array(); while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $productIds[] = $product['ordprodid']; } if (empty($productIds)) { $this->DontDisplay = true; return; } if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\tSELECT p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, i.imagefile, i.imageisthumb, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\tFROM [|PREFIX|]products p\n\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid AND i.imageisthumb=1)\n\t\t\tWHERE p.prodvisible='1' AND p.productid IN (" . implode(',', $productIds) . ")\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = (int) $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice($row); $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); $GLOBALS['AlsoBoughtProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideProductAlsoBoughtItem"); } if (!$GLOBALS['AlsoBoughtProductListing']) { $this->DontDisplay = true; } }
public function SetPanelSettings() { $output = ""; // If product ratings aren't enabled then we don't even need to load anything here if (GetConfig('EnableProductReviews') == 0) { $this->DontDisplay = true; return; } $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1)\n\t\t\t\tWHERE prodvisible='1' AND prodratingtotal > 0\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY prodavgrating DESC\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice($row); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SidePopularProducts"); } // Showing the syndication option? if (GetConfig('RSSPopularProducts') != 0 && GetConfig('RSSSyndicationIcons') != 0) { $GLOBALS['SNIPPETS']['SidePopularProductsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SidePopularProductsFeed"); } } else { $GLOBALS['HideSidePopularProductsPanel'] = "none"; $this->DontDisplay = true; } $GLOBALS['SNIPPETS']['SidePopularProducts'] = $output; }
/** * Load a list of products in the current tag that we're viewing. */ private function LoadProductsForTag() { if (!is_array($this->tag)) { return false; } $query = "\n\t\t\tSELECT COUNT(p.productid) AS numproducts\n\t\t\tFROM [|PREFIX|]products p\n\t\t\tINNER JOIN [|PREFIX|]product_tagassociations ta ON (ta.productid=p.productid AND ta.tagid='" . (int) $this->tag['tagid'] . "')\n\t\t\tWHERE prodvisible='1'\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t"; $this->numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $this->pageCount = ceil($this->numProducts / GetConfig('CategoryProductsPerPage')); // For some reason the tag could has become out of sync for this tag, we need to reset it if ($this->numProducts != $this->tag['tagcount']) { $updatedTag = array('tagcount' => $this->numProducts); $GLOBALS['ISC_CLASS_DB']->UpdateQuery('product_tags', $updatedTag, "tagid='" . (int) $this->tag['tagid'] . "'"); } // Now load the actual products for this tag $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND imageisthumb=1)\n\t\t\t\tINNER JOIN [|PREFIX|]product_tagassociations ta ON (ta.productid=p.productid AND ta.tagid='" . (int) $this->tag['tagid'] . "')\n\t\t\t\tWHERE prodvisible='1'\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY " . $this->sortField . ", prodname ASC\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($this->productStart, GetConfig('CategoryProductsPerPage')); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $row['prodavgrating'] = (int) $row['prodavgrating']; $this->products[] = $row; } }
private function SearchProducts() { if (!isset($_REQUEST['searchQuery']) || $_REQUEST['searchQuery'] == '') { exit; } $groupId = 0; if (isset($_REQUEST['ordcustid']) && $_REQUEST['ordcustid'] != 0) { $customerClass = GetClass('ISC_CUSTOMER'); $customer = $customerClass->GetCustomerInfo($_REQUEST['ordcustid']); if (isset($customer['custgroupid'])) { $groupId = $customer['custgroupid']; } } else { if (isset($_REQUEST['custgroupid']) && $_REQUEST['custgroupid'] != 0) { $groupId = (int) $_REQUEST['custgroupid']; } } $numProducts = 0; $products = GetClass('ISC_ADMIN_PRODUCT'); $result = $products->_GetProductList(0, 'p.prodname', 'asc', $numProducts, 'DISTINCT p.*, ' . GetProdCustomerGroupPriceSQL($groupId), true); if ($numProducts == 0) { $searchQuery = isc_html_escape($_REQUEST['searchQuery']); $GLOBALS['OrderProductSearchNone'] = sprintf(GetLang('OrderProductSearchNone'), $searchQuery); echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchNoResults'); exit; } while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['ProductId'] = $product['productid']; $GLOBALS['ProductName'] = isc_html_escape($product['prodname']); $GLOBALS['ProductLink'] = ProdLink($product['prodname']); $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']); $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice, $groupId); $GLOBALS['ProductPrice'] = FormatPrice($actualPrice); $GLOBALS['RawProductPrice'] = FormatPrice($actualPrice, false, false, true); $GLOBALS['ProductCode'] = isc_html_escape($product['prodcode']); $isConfigurable = false; if ($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) { $isConfigurable = true; } $GLOBALS['ProductConfigurable'] = (int) $isConfigurable; echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResult'); } }
public function _SetProductData($productid = 0) { //alandy_2012-2-29 add. $this->_search_prefix = $GLOBALS['ShopPathNormal'] . '/'; $GLOBALS['ISC_CLASS_REMOTE'] = GetClass('ISC_REMOTE'); if ($productid == 0) { // Retrieve the query string variables. Can't use the $_GET array // because of SEO friendly links in the URL SetPGQVariablesManually(); if (isset($_REQUEST['product'])) { $product = $_REQUEST['product']; //alandy_2012-2-20 modify.add vendorprefix#sku if (stristr($product, '_')) { list($productVendorprefix, $productSKU) = explode('_', $product); $productSKU = decode_sku($productSKU); $productSQL = sprintf("p.prodvendorprefix='%s' and p.prodcode = '%s'", $productVendorprefix, $productSKU); } else { $product = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($product)); $productSQL = sprintf("p.prodname='%s'", $product); } } else { if (isset($GLOBALS['PathInfo'][1])) { //alandy_2012-2-20 modify.add vendorprefix#sku $htmlUrl = preg_replace('#\\.html$#i', '', $GLOBALS['PathInfo'][1]); if (stristr($htmlUrl, '_')) { $product = $htmlUrl; list($productVendorprefix, $productSKU) = explode('_', $product); $productSKU = decode_sku($productSKU); $productSQL = sprintf("p.prodvendorprefix='%s' and p.prodcode = '%s'", $productVendorprefix, $productSKU); } else { $product = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($htmlUrl)); $productSQL = sprintf("p.prodname='%s'", $product); } } else { $product = ''; $product = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($product)); $productSQL = sprintf("p.prodname='%s'", $product); } } //$product = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($product)); //$productSQL = sprintf("p.prodname='%s'", $product); } else { $productSQL = sprintf("p.productid='%s'", (int) $productid); } $query = "\n\t\t\t\tSELECT p.*, prodratingtotal/prodnumratings AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . ", infl.instructionfile, infl.systeminstructionfile, artfl.articlefile, artfl.systemarticlefile,\n\t\t\t\t(SELECT COUNT(fieldid) FROM [|PREFIX|]product_customfields WHERE fieldprodid=p.productid) AS numcustomfields,\n\t\t\t\t(SELECT COUNT(reviewid) FROM [|PREFIX|]reviews WHERE revstatus='1' AND revproductid=p.productid AND revstatus='1') AS numreviews,\n\t\t\t\t(SELECT brandname FROM [|PREFIX|]brands WHERE brandid=p.prodbrandid) AS prodbrandname,\n (SELECT brandimagefile FROM [|PREFIX|]brands WHERE brandid=p.prodbrandid) AS prodbrandimagefile,\n (SELECT proddesc FROM [|PREFIX|]brand_series where seriesid = p.brandseriesid and brandid = p.prodbrandid) AS prodseriesdesc,\n\t\t\t\t(SELECT COUNT(imageid) FROM [|PREFIX|]product_images pi WHERE pi.imageprodid=p.productid AND imageisthumb=0) AS numimages, \n (SELECT COUNT(imageid) FROM [|PREFIX|]install_images ti WHERE ti.imageprodid=p.productid AND imageisthumb=0) AS numinsimages, \n (SELECT COUNT(videoid) FROM [|PREFIX|]product_videos pv WHERE pv.videoprodid=p.productid AND (pv.videofile LIKE '%.flv' || pv.systemvideofile LIKE '%.flv' || pv.videofile LIKE '%.swf' || pv.systemvideofile LIKE '%.swf')) AS numvideos, \n (SELECT COUNT(videoid) FROM [|PREFIX|]install_videos iv WHERE iv.videoprodid=p.productid AND (iv.videofile LIKE '%.flv' || iv.systemvideofile LIKE '%.flv' || iv.videofile LIKE '%.swf' || iv.systemvideofile LIKE '%.swf')) AS numinsvideos, \n (SELECT COUNT(audioid) FROM [|PREFIX|]audio_clips ac WHERE ac.audioprodid=p.productid AND (ac.audiofile LIKE '%.flv' || ac.systemaudiofile LIKE '%.flv' || ac.audiofile LIKE '%.swf' || ac.systemaudiofile LIKE '%.swf')) AS numaudios,\n\t\t\t\t(SELECT COUNT(discountid) FROM [|PREFIX|]product_discounts WHERE discountprodid=p.productid) AS numbulkdiscounts\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (pi.imageisthumb=1 AND p.productid=pi.imageprodid)\n LEFT JOIN [|PREFIX|]instruction_files infl ON p.productid = infl.instructionprodid\n LEFT JOIN [|PREFIX|]article_files artfl ON p.productid = artfl.articleprodid \n\t\t\t\tWHERE " . $productSQL . " AND p.prodvisible='1'\n\t\t\t"; // Query for ins images, videos, ins videos added by Simha $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $this->_product = $row; $this->_prodid = $row['productid']; $this->_prodname = $row['prodname']; $this->_prodsku = $row['prodcode']; $this->_prodthumb = $row['imagefile']; $proddescription = ''; /*if($row['prodseriesdesc'] != '' and !empty($row['prodseriesdesc'])) { # Baskaran $proddescription = $row['prodseriesdesc']; } else { $proddescription = $row['proddesc']; } */ $proddescription = $row['prodseriesdesc'] . " " . $row['proddesc']; $this->_proddesc = $proddescription; $this->_proddescfeature = $row['proddescfeature']; //Added by Simha $this->_prodinsimages = $row['numinsimages']; //Added by Simha $this->_prodmfg = $row['prodmfg']; /*--- added by vikas-clarion-- */ $this->_prodimages = $row['numimages']; //Added by Simha $this->_prodvideos = $row['numvideos']; //Added by Simha $this->_prodaudios = $row['numaudios']; //Added by Simha $this->_prodtestdata = $row['testdata']; //Added by Simha $this->_prodinsvideos = $row['numinsvideos']; $this->_prodbrandimagefile = $row['prodbrandimagefile']; # Baskaran $this->_prodcompitem = $row['complementaryitems']; # Baskaran $this->_comptype = $row['comp_type']; $this->_prodprice = $row['prodprice']; $this->_prodretailprice = $row['prodretailprice']; $this->_prodsaleprice = $row['prodsaleprice']; $this->_prodfixedshippingcost = $row['prodfixedshippingcost']; $this->_prodbrandname = $row['prodbrandname']; $this->_prodweight = $row['prodweight']; $this->_prodavgrating = $this->getRoundValue((double) $row['prodavgrating']); $this->_prodcalculatedprice = $row['prodcalculatedprice']; $this->_prodoptionsrequired = $row['prodoptionsrequired']; $this->_prodnumreviews = $row['numreviews']; $this->_prodavailability = $row['prodavailability']; $this->_prodnumcustomfields = $row['numcustomfields']; $this->_prodnumbulkdiscounts = $row['numbulkdiscounts']; $this->_prodeventdatelimited = $row['prodeventdatelimited']; $this->_prodeventdaterequired = $row['prodeventdaterequired']; $this->_prodeventdatefieldname = $row['prodeventdatefieldname']; $this->_prodeventdatelimitedtype = $row['prodeventdatelimitedtype']; $this->_prodeventdatelimitedstartdate = $row['prodeventdatelimitedstartdate']; $this->_prodeventdatelimitedenddate = $row['prodeventdatelimitedenddate']; $this->_offer = $row['offer']; $this->_prodbrandid = $row['prodbrandid']; $this->_prodbrandseriesid = $row['brandseriesid']; $this->_prodrelatedproducts = $row['prodrelatedproducts']; if ($row['prodlayoutfile'] != '') { $File = str_replace(array(".html", ".htm"), "", $row['prodlayoutfile']); if (!file_exists(ISC_BASE_PATH . "/templates/" . GetConfig('template') . "/" . $row['prodlayoutfile'])) { $this->_prodlayoutfile = 'product'; } else { $this->_prodlayoutfile = $File; } } else { $this->_prodlayoutfile = 'product'; } $this->_prodpagetitle = $row['prodpagetitle']; $this->_prodmetakeywords = $row['prodmetakeywords']; $this->_prodmetadesc = $row['prodmetadesc']; $this->_prodinvtrack = $row['prodinvtrack']; $this->_prodcurrentinv = $row['prodcurrentinv']; if ($row['prodtype'] == 1) { $this->_prodtype = PT_PHYSICAL; } else { $this->_prodtype = PT_DIGITAL; } if ($row['prodfreeshipping'] == 0) { $this->_prodfreeshipping = false; } else { $this->_prodfreeshipping = true; } $this->_prodallowpurchases = $row['prodallowpurchases']; $this->_prodhideprice = $row['prodhideprice']; $this->_prodcallforpricinglabel = $row['prodcallforpricinglabel']; // If there are product variations, set them up if ($row['prodvariationid'] > 0) { $this->SetupProductVariations(); } $GLOBALS['CurrentProductLink'] = ProdLink($this->_prodname); //alandy_2012-2-28 modify. $categorylink = $GLOBALS['ISC_CLASS_REMOTE']->getCategorySearchLinkByProductid($this->_prodid); if (!empty($categorylink)) { $this->_search_prefix .= $categorylink; } } //alandy_2012-2-29 add for search dialog. $catname_link = $GLOBALS['ShopPathNormal']; $catname = $GLOBALS['ISC_CLASS_REMOTE']->getCategoryNameByProductid($this->_prodid); $GLOBALS['searchBrandname'] = $this->_prodbrandname; $GLOBALS['searchSeriesname'] = $this->getSeriesnameById($this->_prodbrandid, $this->_prodbrandseriesid); $GLOBALS['searchCatname'] = $catname; $GLOBALS['searchCatnameLink'] = $catname_link . '/' . MakeURLSafe($catname); $GLOBALS['searchPrefix'] = $this->_search_prefix; /* Added to check whether we need to display the Offer button -- Baskaran */ $seriesquery = "SELECT p.*,s.offer FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]brand_series s ON (s.seriesid = p.brandseriesid) where " . $productSQL . " AND p.prodvisible='1'"; $seriesresult = $GLOBALS['ISC_CLASS_DB']->Query($seriesquery); if ($srow = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesresult)) { $this->_prodseries = $srow['offer']; } $categoryquery = "SELECT c.categoryid, c.catparentid, c.offer FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]categoryassociations ca ON ( ca.productid = p.productid ) LEFT JOIN [|PREFIX|]categories c ON ( c.categoryid = ca.categoryid ) WHERE " . $productSQL . " AND p.prodvisible = '1' AND c.catparentid != 0"; $categoryresult = $GLOBALS['ISC_CLASS_DB']->Query($categoryquery); if ($crow = $GLOBALS['ISC_CLASS_DB']->Fetch($categoryresult)) { $this->_product['catparentid'] = $crow['catparentid']; $this->_prodcategory = $crow['offer']; } $allseriesquery = "SELECT count( s.offer ) as cntoffer FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]brand_series s ON ( s.brandid = p.prodbrandid ) WHERE " . $productSQL . " AND p.prodvisible = '1' AND s.offer = 'yes'"; $allseriesresult = $GLOBALS['ISC_CLASS_DB']->Query($allseriesquery); if ($allrow = $GLOBALS['ISC_CLASS_DB']->Fetch($allseriesresult)) { $this->_cntoffer = $allrow['cntoffer']; } $brandquery = "SELECT b.offer FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]brands b ON (b.brandid = p.prodbrandid) WHERE " . $productSQL . " AND p.prodvisible = '1'"; $brandresult = $GLOBALS['ISC_CLASS_DB']->Query($brandquery); if ($brow = $GLOBALS['ISC_CLASS_DB']->Fetch($brandresult)) { $this->_prodbrandoffer = $brow['offer']; } $subcategoryquery = "SELECT count( c.offer ) as cntoffer FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]categories c ON ( c.categoryid = p.prodcatids ) WHERE " . $productSQL . " AND p.prodvisible = '1' AND c.offer = 'yes'"; $subcategoryresult = $GLOBALS['ISC_CLASS_DB']->Query($subcategoryquery); if ($subrow = $GLOBALS['ISC_CLASS_DB']->Fetch($subcategoryresult)) { $this->_prodsubcategorycnt = $subrow['cntoffer']; } $catofferquery = "SELECT c.offer FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]categories c ON (c.categoryid = p.prodcatids) WHERE " . $productSQL . " AND p.prodvisible = '1' AND c.catparentid = 0"; $catofferresult = $GLOBALS['ISC_CLASS_DB']->Query($catofferquery); if ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catofferresult)) { $this->_prodcatoffer = $catrow['offer']; } /* Ends here */ /* Reassigning the rating as the rating calculation changed as per client requirements - vikas */ //wirror_20110330 $ratingquery = "select IFNULL(SUM(p.prodnumratings),0) as total_reviews , IFNULL(SUM(p.prodratingtotal)/SUM(p.prodnumratings),0) as rating from [|PREFIX|]products p where p.prodvisible = 1 and p.productid={$row['productid']} and"; if ($this->_prodbrandseriesid != 0) { $ratingquery .= " p.brandseriesid = " . $this->_prodbrandseriesid; } else { if ($this->_prodbrandid != 0) { $ratingquery .= " p.prodbrandid = " . $this->_prodbrandid; } } $ratingresult = $GLOBALS['ISC_CLASS_DB']->Query($ratingquery); $ratingrow = $GLOBALS['ISC_CLASS_DB']->Fetch($ratingresult); if (isset($ratingrow['rating'])) { $this->_prodavgrating = $this->getRoundValue((double) $ratingrow['rating']); } else { $this->_prodavgrating = 0; } if (isset($ratingrow['total_reviews'])) { $this->_prodnumreviews = $ratingrow['total_reviews']; } else { $this->_prodnumreviews = 0; } }
private function SearchProducts() { if (!isset($_REQUEST['searchQuery']) || $_REQUEST['searchQuery'] == '') { exit; } $groupId = 0; if (isset($_REQUEST['ordcustid']) && $_REQUEST['ordcustid'] != 0) { $customerClass = GetClass('ISC_CUSTOMER'); $customer = $customerClass->GetCustomerInfo($_REQUEST['ordcustid']); if (isset($customer['custgroupid'])) { $groupId = $customer['custgroupid']; } } else { if (isset($_REQUEST['custgroupid']) && $_REQUEST['custgroupid'] != 0) { $groupId = (int) $_REQUEST['custgroupid']; } } $numProducts = 0; $products = GetClass('ISC_ADMIN_PRODUCT'); /*********************************************************************** Altered By Mayank Jaitly 12 July 2010 Original Code is in the else /***********************************************************************/ if (isset($_REQUEST['w']) && $_REQUEST['w'] == 'orderSearchProducts') { $result = $products->_GetProductList(0, 'ct.catuniversal,p.prodname', 'asc', $numProducts, 'DISTINCT p.*, ' . GetProdCustomerGroupPriceSQL($groupId), true); } else { $result = $products->_GetProductList(0, 'p.prodname', 'asc', $numProducts, 'DISTINCT p.*, ' . GetProdCustomerGroupPriceSQL($groupId), true); } if ($numProducts == 0) { $searchQuery = isc_html_escape($_REQUEST['searchQuery']); $GLOBALS['OrderProductSearchNone'] = sprintf(GetLang('OrderProductSearchNone'), $searchQuery); echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchNoResults'); exit; } while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $GLOBALS['ProductId'] = $product['productid']; $GLOBALS['ProductName'] = isc_html_escape($product['prodname']); $GLOBALS['ProductLink'] = ProdLink($product['prodname']); $actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']); $actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice, $groupId); $GLOBALS['ProductPrice'] = FormatPrice($actualPrice); $GLOBALS['RawProductPrice'] = FormatPrice($actualPrice, false, false, true); $GLOBALS['ProductCode'] = isc_html_escape($product['prodcode']); $isConfigurable = false; if ($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) { $isConfigurable = true; } $GLOBALS['ProductConfigurable'] = (int) $isConfigurable; /************************************************************************ Code Altered by Mayank Jaitly on 01 July 2010 Original code is with comment area echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResult'); /***************************************************************************/ /// Start of alteration if (isset($_REQUEST['ajaxsearchtype']) && $_REQUEST['ajaxsearchtype'] == '2') { $GLOBALS['SKU'] = isc_html_escape($product['prodvendorprefix']); echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResultSKU'); } else { echo $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrdersProductSearchResult'); } //// End of alteration } }
public function SetPanelSettings() { $count = 0; $output = ""; $GLOBALS['SNIPPETS']['HomeNewProducts'] = ''; if (GetConfig('HomeNewProducts') > 0) { if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\t\tWHERE p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\t\tORDER BY proddateadded DESC\n\t\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeNewProducts')); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row); // Workout the product description $desc = strip_tags($row['proddesc']); if (strlen($desc) < 120) { $GLOBALS['ProductSummary'] = $desc; } else { $GLOBALS['ProductSummary'] = substr($desc, 0, 120) . "..."; } $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { //$GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductURL'] = ProdLink($row['prodname']); //blessen if (intval($row['prodretailprice']) <= 0) { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } else { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); } //blessen // original$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['HideProductVendorName'] = 'display: none'; $GLOBALS['ProductVendor'] = ''; if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) { $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors'); if (isset($vendorCache[$row['prodvendorid']])) { $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>'; $GLOBALS['HideProductVendorName'] = ''; } } $GLOBALS['SNIPPETS']['HomeNewProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeNewProductsItem"); } // Showing the syndication option? if (GetConfig('RSSNewProducts') != 0 && GetConfig('RSSSyndicationIcons') != 0) { $GLOBALS['SNIPPETS']['HomeNewProductsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeNewProductsFeed"); } } else { $this->DontDisplay = true; $GLOBALS['HideHomeNewProductsPanel'] = "none"; } } else { $this->DontDisplay = true; $GLOBALS['HideHomeNewProductsPanel'] = "none"; } }
public function LoadProductsForBrand() { $taxJoin = $this->getTaxPricingJoin(); $query = " SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL()." FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1) ".$taxJoin." WHERE prodbrandid='".(int)$this->GetId()."' AND prodvisible='1' ".GetProdCustomerGroupPermissionsSQL()." ORDER BY ".$this->GetSortField().", prodname ASC "; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($this->GetStart(), GetConfig('CategoryProductsPerPage')); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $row['prodavgrating'] = (int)$row['prodavgrating']; $this->_brandproducts[] = $row; } }
public function LoadProductsForPage() { $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tp.*,\n\t\t\t\t\tFLOOR(prodratingtotal / prodnumratings) AS prodavgrating,\n\t\t\t\t\timageisthumb,\n\t\t\t\t\timagefile,\n\t\t\t\t\t" . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tDISTINCT ca.productid,\n\t\t\t\t\t\t\tFLOOR(prodratingtotal / prodnumratings) AS prodavgrating\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t[|PREFIX|]categoryassociations ca\n\t\t\t\t\t\t\tINNER JOIN [|PREFIX|]products p ON p.productid = ca.productid\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tp.prodvisible = 1 AND\n\t\t\t\t\t\t\tca.categoryid IN (" . $this->GetProductCategoryIds() . ")\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t" . $this->GetSortField() . ", p.prodname ASC\n\t\t\t\t\t\t" . $GLOBALS['ISC_CLASS_DB']->AddLimit($this->GetStart(), GetConfig('CategoryProductsPerPage')) . "\n\t\t\t\t\t) AS ca\n\t\t\t\t\tINNER JOIN [|PREFIX|]products p ON p.productid = ca.productid\n\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (pi.imageisthumb = 1 AND p.productid = pi.imageprodid)\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $row['prodavgrating'] = (int) $row['prodavgrating']; $this->_catproducts[] = $row; } }
public function SetPanelSettings() { $output = ""; // If product ratings aren't enabled then we don't even need to load anything here if (GetConfig('EnableProductReviews') == 0) { $this->DontDisplay = true; return; } if (isset($GLOBALS['ISC_CLASS_CATEGORY'])) { $categorySql = $GLOBALS['ISC_CLASS_CATEGORY']->GetCategoryAssociationSQL(); } else { if (isset($GLOBALS['ISC_CLASS_PRICE'])) { $categorySql = $GLOBALS['ISC_CLASS_PRICE']->GetCategoryAssociationSQL(); } } $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tWHERE p.prodvisible='1' AND prodratingtotal > '0' " . $categorySql . "\n\t\t\t\tORDER BY prodavgrating DESC\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { //$GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductURL'] = ProdLink($row['prodname']); //blessen if (intval($row['prodretailprice']) <= 0) { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } else { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); } //blessen //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['HideProductVendorName'] = 'display: none'; $GLOBALS['ProductVendor'] = ''; if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) { $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors'); if (isset($vendorCache[$row['prodvendorid']])) { $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>'; $GLOBALS['HideProductVendorName'] = ''; } } $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryPopularProducts"); } // Showing the syndication option? if (GetConfig('RSSPopularProducts') != 0 && GetConfig('RSSCategories') != 0 && GetConfig('RSSSyndicationIcons') != 0) { $GLOBALS['ISC_LANG']['CategoryPopularProductsFeed'] = sprintf(GetLang('CategoryPopularProductsFeed'), isc_html_escape($GLOBALS['CatName'])); $GLOBALS['SNIPPETS']['SideCategoryPopularProductsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideCategoryPopularProductsFeed"); } } else { $GLOBALS['HideSideCategoryPopularProductsPanel'] = "none"; $this->DontDisplay = true; } $GLOBALS['SNIPPETS']['SideCategoryPopularProducts'] = $output; }
/** * Get a list of items in this customer's wishlist by wish list token */ private function _GetWishListItemsByToken($wishlisttoken="") { $items = array(); $query = " SELECT wi.wishlistitemid, p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL()." FROM [|PREFIX|]wishlists w LEFT JOIN [|PREFIX|]wishlist_items wi ON (w.wishlistid=wi.wishlistid) INNER JOIN [|PREFIX|]products p ON (wi.productid=p.productid) LEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1) WHERE w.wishlisttoken='".$GLOBALS['ISC_CLASS_DB']->Quote($wishlisttoken)."' ".GetProdCustomerGroupPermissionsSQL()." "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { array_push($items, $row); } return $items; }
private function AddToCart() { if (!isset($_REQUEST['product_id'])) { ob_end_clean(); header(sprintf("Location: %s/makeaoffer.php", GetConfig('ShopPath'))); die; } // First get the list of existing products in the cart $product_id = (int) $_REQUEST['product_id']; $GLOBALS['ProductJustAdded'] = $product_id; $query = "\n\t\t\t\tSELECT p.*, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tWHERE p.productid='" . (int) $product_id . "'\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $product = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $GLOBALS['Product'] =& $product; // Check that the customer has permisison to view this product $canView = false; $productCategories = explode(',', $product['prodcatids']); foreach ($productCategories as $categoryId) { // Do we have permission to access this category? if (CustomerGroupHasAccessToCategory($categoryId)) { $canView = true; } } if ($canView == false) { $noPermissionsPage = GetClass('ISC_403'); $noPermissionsPage->HandlePage(); exit; } $variation = 0; if (isset($_REQUEST['variation_id']) && $_REQUEST['variation_id'] != 0) { $variation = (int) $_REQUEST['variation_id']; } else { if (isset($_REQUEST['variation']) && is_array($_REQUEST['variation']) && $_REQUEST['variation'][1] != 0) { $variation = $_REQUEST['variation']; } } $qty = 1; if (isset($_REQUEST['qty'])) { if (is_array($_REQUEST['qty'])) { $qty = (int) array_pop($_REQUEST['qty']); } else { if ($_REQUEST['qty'] > 0) { $qty = (int) $_REQUEST['qty']; } } } $configurableFields = null; if (isset($_REQUEST['ProductFields']) || isset($_FILES['ProductFields'])) { $configurableFields = $this->BuildProductConfigurableFieldData(); } $options = array(); if (isset($_REQUEST['EventDate']['Day'])) { $result = true; $eventDate = isc_gmmktime(0, 0, 0, $_REQUEST['EventDate']['Mth'], $_REQUEST['EventDate']['Day'], $_REQUEST['EventDate']['Yr']); $eventName = $product['prodeventdatefieldname']; if ($product['prodeventdatelimitedtype'] == 1) { if ($eventDate < $product['prodeventdatelimitedstartdate'] || $eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } else { if ($product['prodeventdatelimitedtype'] == 2) { if ($eventDate < $product['prodeventdatelimitedstartdate']) { $result = false; } } else { if ($product['prodeventdatelimitedtype'] == 3) { if ($eventDate > $product['prodeventdatelimitedenddate']) { $result = false; } } } } if ($result == false) { $this->ShowRegularCart(); return; } $options['EventDate'] = $eventDate; $options['EventName'] = $eventName; } // Actually add the product to the cart $cartItemId = $this->api->AddItem($product_id, $qty, $variation, $configurableFields, null, $options); $this->newCartItem = $cartItemId; if ($cartItemId === false) { $this->cartErrorMessage = implode('<br />', $this->api->GetErrors()); if (!$this->cartErrorMessage) { $this->cartErrorMessage = GetLang('ProductUnavailableForPruchase'); } if ($this->api->productLevelError == true) { $query = "\n\t\t\t\t\t\tSELECT prodname\n\t\t\t\t\t\tFROM [|PREFIX|]products\n\t\t\t\t\t\tWHERE productid='" . (int) $product_id . "'\n\t\t\t\t\t"; $productName = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $_SESSION['ProductErrorMessage'] = $this->cartErrorMessage; ob_end_clean(); header("Location: " . ProdLink($productName)); exit; } $this->ShowRegularCart(); return; } $this->api->ReapplyCouponsFromCart(); //Added by Simha temp fix to avoid having multiple times coupon for same item $GLOBALS['ISC_CLASS_MAKEAOFFER']->api->UpdateCartInformation(); $_SESSION['JustAddedProduct'] = $product_id; // Are we redirecting to a specific location? if (isset($_REQUEST['returnUrl'])) { $redirectLocation = urldecode($_REQUEST['returnUrl']); $urlPieces = @parse_url($redirectLocation); $storeUrlPieces = @parse_url(GetConfig('ShopPath')); if (is_array($urlPieces) && isset($urlPieces['host'])) { $urlHost = str_replace('www.', '', isc_strtolower($urlPieces['host'])); $storeHost = str_replace('www.', '', isc_strtolower($storeUrlPieces['host'])); if ($urlHost == $storeHost) { if (strpos($redirectLocation, '?') === false) { $redirectLocation .= '?'; } else { $redirectLocation .= '&'; } $redirectLocation .= 'justAddedProduct=' . $product_id; ob_end_clean(); header("Location: " . $redirectLocation); exit; } } } // Redirect the user to the regular cart page ob_end_clean(); header(sprintf("Location: %s/makeaoffer.php", $GLOBALS['ShopPath'])); die; }
public function LoadProductsForBrand() { $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE prodbrandid='" . (int) $this->GetId() . "' AND prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY " . $this->GetSortField() . ", prodname ASC\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($this->GetStart(), GetConfig('CategoryProductsPerPage')); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $row['prodavgrating'] = (int) $row['prodavgrating']; $this->_brandproducts[] = $row; } }
/** * Build an SQL query for the specified search terms. * * @param array Array of search terms * @param string String of fields to match * @param string The field to sort by * @param string The order to sort results by * @return array An array containing the query to count the number of results and a query to perform the search */ function BuildProductSearchQuery($searchTerms, $fields="", $sortField=array("score", "proddateadded"), $sortOrder="desc") { $queryWhere = array(); $joinQuery = ''; // Construct the full text search part of the query $fulltext_fields = array("ps.prodname", "ps.prodcode", "ps.proddesc", "ps.prodsearchkeywords"); if (!$fields) { $fields = "p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, ".GetProdCustomerGroupPriceSQL().", "; $fields .= "pi.* "; if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { $fields .= ', '.$GLOBALS['ISC_CLASS_DB']->FullText($fulltext_fields, $searchTerms['search_query'], false) . " as score "; } } if(isset($searchTerms['categoryid'])) { $searchTerms['category'] = array($searchTerms['categoryid']); } // If we're searching by category, we need to completely // restructure the search query - so do that first $categorySearch = false; $categoryIds = array(); $nestedset = new ISC_NESTEDSET_CATEGORIES; if(isset($searchTerms['category']) && is_array($searchTerms['category'])) { foreach($searchTerms['category'] as $categoryId) { $categoryId = (int)$categoryId; // All categories were selected, so don't continue if($categoryId == 0) { $categorySearch = false; break; } $categoryIds[] = $categoryId; // If searching sub categories automatically, fetch & tack them on if(isset($searchTerms['searchsubs']) && $searchTerms['searchsubs'] == 'ON') { foreach ($nestedset->getTree(array('categoryid'), $categoryId) as $childCategory) { $categoryIds[] = (int)$childCategory['categoryid']; } unset($childCategory); } } $categoryIds = array_unique($categoryIds); if(!empty($categoryIds)) { $categorySearch = true; } } if($categorySearch == true) { $fromTable = '[|PREFIX|]categoryassociations a, [|PREFIX|]products p'; $queryWhere[] = 'a.productid=p.productid AND a.categoryid IN ('.implode(',', $categoryIds).')'; } else { $fromTable = '[|PREFIX|]products p'; } if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { // Only need the product search table if we have a search query $joinQuery .= "INNER JOIN [|PREFIX|]product_search ps ON (p.productid=ps.productid) "; } else if ($sortField == "score") { // If we don't, we better make sure we're not sorting by score $sortField = "p.prodname"; $sortOrder = "ASC"; } $joinQuery .= "LEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1) "; $queryWhere[] = "p.prodvisible='1'"; // Add in the group category restrictions $permissionSql = GetProdCustomerGroupPermissionsSQL(null, false); if($permissionSql) { $queryWhere[] = $permissionSql; } // Do we need to filter on brand? if (isset($searchTerms['brand']) && $searchTerms['brand'] != "") { $brand_id = (int)$searchTerms['brand']; $queryWhere[] = "p.prodbrandid='" . $GLOBALS['ISC_CLASS_DB']->Quote($brand_id) . "'"; } // Do we need to filter on price? if (isset($searchTerms['price'])) { $queryWhere[] = "p.prodcalculatedprice='".$GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['price'])."'"; } else { if (isset($searchTerms['price_from']) && is_numeric($searchTerms['price_from'])) { $queryWhere[] = "p.prodcalculatedprice >= '".$GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['price_from'])."'"; } if (isset($searchTerms['price_to']) && is_numeric($searchTerms['price_to'])) { $queryWhere[] = "p.prodcalculatedprice <= '".$GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['price_to'])."'"; } } // Do we need to filter on rating? if (isset($searchTerms['rating'])) { $queryWhere[] = "FLOOR(p.prodratingtotal/p.prodnumratings) = '".(int)$searchTerms['rating']."'"; } else { if (isset($searchTerms['rating_from']) && is_numeric($searchTerms['rating_from'])) { $queryWhere[] = "FLOOR(p.prodratingtotal/p.prodnumratings) >= '".(int)$searchTerms['rating_from']."'"; } if (isset($searchTerms['rating_to']) && is_numeric($searchTerms['rating_to'])) { $queryWhere[] = "FLOOR(p.prodratingtotal/p.prodnumratings) <= '".(int)$searchTerms['rating_to']."'"; } } // Do we need to filter on featured? if (isset($searchTerms['featured']) && $searchTerms['featured'] != "") { $featured = (int)$searchTerms['featured']; if ($featured == 1) { $queryWhere[] = "p.prodfeatured=1"; } else { $queryWhere[] = "p.prodfeatured=0"; } } // Do we need to filter on free shipping? if (isset($searchTerms['shipping']) && $searchTerms['shipping'] != "") { $shipping = (int)$searchTerms['shipping']; if ($shipping == 1) { $queryWhere[] = "p.prodfreeshipping='1' "; } else { $queryWhere[] = "p.prodfreeshipping='0' "; } } // Do we need to filter only products we have in stock? if (isset($searchTerms['instock']) && $searchTerms['instock'] != "") { $stock = (int)$searchTerms['instock']; if ($stock == 1) { $queryWhere[] = "(p.prodcurrentinv>0 or p.prodinvtrack=0) "; } } if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { $termQuery = "(" . $GLOBALS['ISC_CLASS_DB']->FullText($fulltext_fields, $searchTerms['search_query'], true); $termQuery .= "OR ps.prodname like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.proddesc like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodsearchkeywords like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodcode = '" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "') "; $queryWhere[] = $termQuery; } if (!is_array($sortField)) { $sortField = array($sortField); } if (!is_array($sortOrder)) { $sortOrder = array($sortOrder); } $sortField = array_filter($sortField); $sortOrder = array_filter($sortOrder); if (count($sortOrder) < count($sortField)) { $missing = count($sortField) - count($sortOrder); $sortOrder += array_fill(count($sortOrder), $missing, 'desc'); } else if (count($sortOrder) > count($sortField)) { $sortOrder = array_slice($sortOrder, 0, count($sortField)); } if (!empty($sortField)) { $orderBy = array(); $sortField = array_values($sortField); $sortOrder = array_values($sortOrder); foreach ($sortField as $key => $field) { $orderBy[] = $field . ' ' . $sortOrder[$key]; } $orderBy = ' ORDER BY ' . implode(',', $orderBy); } else { $orderBy = ''; } $query = " SELECT ".$fields." FROM ".$fromTable." ".$joinQuery." WHERE 1=1 AND ".implode(' AND ', $queryWhere).$orderBy; $countQuery = " SELECT COUNT(p.productid) FROM ".$fromTable." ".$joinQuery." WHERE 1=1 AND ".implode(' AND ', $queryWhere); return array( 'query' => $query, 'countQuery' => $countQuery ); }
/** * Search for products * * Method will search for all the products and return an array of product records records * * @access public * @param array $searchQuery The search query array. Currently will only understand the 'search_query' option * @param int &$totalAmount The referenced variable to store in the total amount of the result * @param int $start The optional start position of the result total. Default is 0 * @param int $limit The optional limit position of the result total. Default is -1 (no limit) * @param string $sortBy The optional order by. Default is GetConfig("SearchDefaultProductSort") * @return array The array result set on success, FALSE on error */ static public function searchForItems($searchQuery, &$totalAmount, $start=0, $limit=-1, $sortBy="") { if (trim($sortBy) == "") { $sortBy = GetConfig("SearchDefaultProductSort"); } if (!is_array($searchQuery)) { return false; } $totalAmount = 0; if (!is_array($searchQuery) || empty($searchQuery)) { return false; } $fullTextFields = array("ps.prodname", "ps.prodcode", "ps.proddesc", "ps.prodsearchkeywords"); $products = array(); $query = "SELECT SQL_CALC_FOUND_ROWS p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, " . GetProdCustomerGroupPriceSQL() . ", pi.* "; if (isset($searchQuery["search_query"]) && trim($searchQuery["search_query"]) !== "") { $query .= ", (IF(p.prodname='" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["search_query"]) . "', 10000, 0) + IF(p.prodcode='" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["search_query"]) . "', 10000, 0) + ((" . $GLOBALS["ISC_CLASS_DB"]->FullText(array("ps.prodname"), $searchQuery["search_query"], false) . ") * 10) + " . $GLOBALS["ISC_CLASS_DB"]->FullText($fullTextFields, $searchQuery["search_query"], false) . ") AS score "; } $query .= " FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images pi ON (p.productid = pi.imageprodid AND pi.imageisthumb = 1) "; // Sorting or filtering by price. Need to join the tax pricing table if(!empty($searchQuery['price']) || !empty($searchQuery['price_from']) || !empty($searchQuery['price_to']) || $sortBy == 'priceasc' || $sortBy == 'pricedesc') { $priceColumn = 'tp.calculated_price'; // Showing prices ex tax, so the tax zone ID = 0 if(getConfig('taxDefaultTaxDisplayCatalog') == TAX_PRICES_DISPLAY_EXCLUSIVE) { $taxZone = 0; } // Showing prices inc tax, so we need to fetch the applicable tax zone else { $taxZone = getClass('ISC_TAX')->determineTaxZone(); } $query .= ' JOIN [|PREFIX|]product_tax_pricing tp ON ( tp.price_reference=p.prodcalculatedprice AND tp.tax_zone_id='.$taxZone.' AND tp.tax_class_id=p.tax_class_id ) '; } else { $priceColumn = 'p.prodcalculatedprice'; } if (isset($searchQuery["categoryid"])) { $searchQuery["category"] = array($searchQuery["categoryid"]); } $searchTerms = $GLOBALS['ISC_CLASS_SEARCH']->readSearchSession(); $categorySearch = false; $categoryIds = array(); $nestedset = new ISC_NESTEDSET_CATEGORIES; if (isset($searchQuery["category"]) && is_array($searchQuery["category"])) { foreach ($searchQuery["category"] as $categoryId) { // All categories were selected, so don"t continue if (!isId($categoryId)) { $categorySearch = false; break; } $categoryIds[] = (int)$categoryId; // If searching sub categories automatically, fetch & tack them on if (isset($searchQuery["searchsubs"]) && $searchQuery["searchsubs"] == "ON") { foreach ($nestedset->getTree(array('categoryid'), $categoryId) as $childCategory) { $categoryIds[] = (int)$childCategory['categoryid']; } unset($childCategory); } } $categoryIds = array_unique($categoryIds); if (!empty($categoryIds)) { $categorySearch = true; } } if ($categorySearch == true) { $query .= " INNER JOIN [|PREFIX|]categoryassociations a ON a.productid = p.productid AND a.categoryid IN (" . implode(",", $categoryIds) . ") "; } if (isset($searchQuery["search_query"]) && trim($searchQuery["search_query"]) !== "") { $query .= " INNER JOIN [|PREFIX|]product_search ps ON p.productid = ps.productid "; } $query .= " WHERE p.prodvisible = 1 " . GetProdCustomerGroupPermissionsSQL(); // Do we need to filter on brand? if (isset($searchQuery["brand"]) && isId($searchQuery["brand"])) { $query .= " AND p.prodbrandid = " . (int)$searchQuery["brand"]; } // Do we need to filter on price? if (isset($searchQuery["price"]) && is_numeric($searchQuery["price"])) { $query .= " AND ".$priceColumn." ='" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchTerms["price"]) . "'"; } else { if (isset($searchQuery["price_from"]) && is_numeric($searchQuery["price_from"])) { $query .= " AND ".$priceColumn." >= '" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["price_from"]) . "'"; } if (isset($searchQuery["price_to"]) && is_numeric($searchQuery["price_to"])) { $query .= " AND ".$priceColumn." <= '" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["price_to"]) . "'"; } } // Do we need to filter on rating? if (isset($searchQuery["rating"])) { $query .= " AND FLOOR(p.prodratingtotal/p.prodnumratings) = " . (int)$searchQuery["rating"]; } else { if (isset($searchQuery["rating_from"]) && is_numeric($searchQuery["rating_from"])) { $query .= " AND FLOOR(p.prodratingtotal/p.prodnumratings) >= " . (int)$searchQuery["rating_from"]; } if (isset($searchQuery["rating_to"]) && is_numeric($searchQuery["rating_to"])) { $query .= " AND FLOOR(p.prodratingtotal/p.prodnumratings) <= " . (int)$searchQuery["rating_to"]; } } // Do we need to filter on featured? if (isset($searchQuery["featured"]) && is_numeric($searchQuery["featured"])) { if ((int)$searchQuery["featured"] == 1) { $query .= " AND p.prodfeatured = 1 "; } else { $query .= " AND p.prodfeatured = 0 "; } } // Do we need to filter on free shipping? if (isset($searchQuery["shipping"]) && is_numeric($searchQuery["shipping"])) { if ((int)$searchQuery["shipping"] == 1) { $query .= " AND p.prodfreeshipping = 1 "; } else { $query .= " AND p.prodfreeshipping = 0 "; } } // Do we need to filter only products we have in stock? if (isset($searchQuery["instock"]) && is_numeric($searchQuery["instock"])) { if ((int)$searchQuery["instock"] == 1) { $query .= " AND (p.prodcurrentinv > 0 OR p.prodinvtrack = 0) "; } } if (isset($searchQuery["search_query"]) && trim($searchQuery["search_query"]) !== "") { $searchPart = array(); if (GetConfig("SearchOptimisation") == "fulltext" || GetConfig("SearchOptimisation") == "both") { $searchPart[] = $GLOBALS["ISC_CLASS_DB"]->FullText($fullTextFields, $searchQuery["search_query"], true); } if (GetConfig("SearchOptimisation") == "like" || GetConfig("SearchOptimisation") == "both") { $searchPart[] = "p.prodname LIKE '%" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["search_query"]) . "%'"; $searchPart[] = "p.proddesc LIKE '%" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["search_query"]) . "%'"; $searchPart[] = "p.prodsearchkeywords LIKE '%" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["search_query"]) . "%'"; } $query .= " AND (ps.prodcode = '" . $GLOBALS["ISC_CLASS_DB"]->Quote($searchQuery["search_query"]) . "' OR TRUE) "; $query .= " AND (" . implode(" OR ", $searchPart) . ") "; } $orderBy = ""; switch (isc_strtolower($sortBy)) { case "relevance": if (isset($searchQuery["search_query"]) && trim($searchQuery["search_query"]) !== "") { $orderBy = "score DESC"; } break; case "featured": $orderBy = "p.prodfeatured DESC"; break; case "newest": $orderBy = "p.productid DESC"; break; case "bestselling": $orderBy = "p.prodnumsold DESC"; break; case "alphaasc": $orderBy = "p.prodname ASC"; break; case "alphadesc": $orderBy = "p.prodname DESC"; break; case "avgcustomerreview": $orderBy = "prodavgrating DESC"; break; case "priceasc": $orderBy = $priceColumn.' ASC'; break; case "pricedesc": $orderBy = $priceColumn.' DESC'; break; } if (trim($orderBy) !== "") { $query .= " ORDER BY " . $orderBy; } else { $query .= " ORDER BY p.productid DESC"; } if (is_numeric($limit) && $limit > 0) { if (is_numeric($start) && $start > 0) { $query .= " LIMIT " . (int)$start . "," . (int)$limit; } else { $query .= " LIMIT " . (int)$limit; } } $result = $GLOBALS["ISC_CLASS_DB"]->Query($query); $row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result); if (!$row) { return array(); } $totalAmount = $GLOBALS["ISC_CLASS_DB"]->FetchOne("SELECT FOUND_ROWS()"); $products[$row["productid"]] = $row; while ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) { $products[$row["productid"]] = $row; } return $products; }
/** * Returns a list of products, most popular first, related to the provided product id on the basis of similar viewing habits * * @param int $productId * @param int $limit Number of related products to return, or 0 to not limit * @param bool $returnResult If true, will return mysql result resource, otherwise returns array of ids with highest-cross-viewed product first * @return array */ public static function getRelatedProducts($productId, $limit = 0, $returnResult = false) { $db = $GLOBALS['ISC_CLASS_DB']; $sql = " SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, " . GetProdCustomerGroupPriceSQL() . " FROM `[|PREFIX|]products` p LEFT JOIN `[|PREFIX|]product_images` pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1) INNER JOIN `[|PREFIX|]product_related_byviews` prv ON prv.prodida = " . $productId . " AND prv.prodidb = p.productid WHERE p.prodvisible = 1 " . GetProdCustomerGroupPermissionsSQL() . " ORDER BY prv.relevance DESC"; if ($limit) { $sql .= " LIMIT " . $limit; } $result = $db->Query($sql); if ($returnResult) { // return result for an iterator or something to use return $result; } $products = array(); if ($result) { while ($product = $db->Fetch($result)) { $products[] = $product; } } return $products; }
public function SetPanelSettings() { if (!gzte11(ISC_HUGEPRINT) || $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor() === false) { $this->DontDisplay = true; return false; } $vendor = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVendor(); $GLOBALS['SNIPPETS']['VendorsOtherProducts'] = ''; if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\tSELECT p.*, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, i.imagefile, i.imageisthumb, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\tFROM [|PREFIX|]products p\n\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid AND i.imageisthumb=1)\n\t\t\tWHERE p.prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "' AND p.productid!='" . (int) $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId() . "'\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tORDER BY p.prodvendorfeatured DESC, RAND() DESC\n\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 9); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $productsDone = 0; $hasMore = false; $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { ++$productsDone; if ($productsDone == 9) { $hasMore = true; break; } if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = (int) $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row); $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { //$GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductURL'] = ProdLink($row['prodname']); //blessen if (intval($row['prodretailprice']) <= 0) { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } else { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); } //blessen //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['SNIPPETS']['VendorsOtherProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVendorsOtherProductsItem"); } if (!$GLOBALS['SNIPPETS']['VendorsOtherProducts']) { $this->DontDisplay = true; } $GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor); if ($hasMore == true) { $GLOBALS['HideViewAllLink'] = ''; } else { $GLOBALS['HideViewAllLink'] = 'display: none'; } }
function CalculateCustGroupDiscount($productId, $price, $custGroup=null) { static $products = array(); //apply customer group discount on top of the quantity discount if(!isset($products[$productId])) { $query = " SELECT p.*, ".GetProdCustomerGroupPriceSQL()." FROM [|PREFIX|]products p WHERE p.productid='".(int)$productId."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $products[$productId] = $GLOBALS['ISC_CLASS_DB']->Fetch($result); } $price = CalcProdCustomerGroupPrice($products[$productId], $price, $custGroup); return $price; }
public function AddItem($productId, $quantity = 1, $variationDetails = null, $configurableOptions = array(), $cartItemId = null, $options = array()) { $itemId = parent::AddItem($productId, $quantity, $variationDetails, $configurableOptions, $cartItemId, $options); if ($itemId === false) { return false; } $item =& $this->cartSession['ITEMS'][$itemId]; // load up product data for the new item $query = "\n\t\t\t\tSELECT p.productid, prodcurrentinv, prodinvtrack, prodweight, prodwidth, prodheight, prodvariationid,\n\t\t\t\t\tproddepth, prodname, prodprice, prodretailprice, prodsaleprice, prodcalculatedprice,\n\t\t\t\t\tprodavailability, prodtype, prodcostprice, prodfixedshippingcost, prodfreeshipping, prodoptionsrequired,\n\t\t\t\t\timageisthumb, imagefile, prodistaxable, prodwrapoptions, prodvendorid, prodeventdaterequired, prodeventdatefieldname, " . GetProdCustomerGroupPriceSQL() . ",\n\t\t\t\t\t(SELECT group_concat(ca.categoryid SEPARATOR ',') FROM [|PREFIX|]categoryassociations ca WHERE p.productid=ca.productid) AS categoryids\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1)\n\t\t\t\tWHERE p.productid = " . $GLOBALS['ISC_CLASS_DB']->Quote($productId); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $item['data'] = $GLOBALS['ISC_CLASS_DB']->Fetch($result); // If this item is a variation, load in the weight etc if ($variationDetails) { $query = "SELECT combinationid, vcproductid, vcthumb, vcweight, vcweightdiff, vcstock\n\t\t\t\t\tFROM [|PREFIX|]product_variation_combinations\n\t\t\t\t\tWHERE combinationid = " . $GLOBALS['ISC_CLASS_DB']->Quote($variationDetails); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $variationInfo = $GLOBALS['ISC_CLASS_DB']->Fetch($result); // Override the thumbnail for this item with the variation thumbnail if ($variationInfo['vcthumb']) { $item['data']['imagefile'] = $variationInfo['vcthumb']; } if ($variationInfo['vcweight'] != 0) { $item['data']['prodweight'] = CalcProductVariationWeight($item['data']['prodweight'], $variationInfo['vcweightdiff'], $variationInfo['vcweight']); } // Store the # of this combination we have in stock if ($item['data']['prodinvtrack'] == 2) { $item['data']['prodcurrentinv'] = $variationInfo['vcstock']; } } $this->cartProducts = array(); return $itemId; }
/** * Show a list of items that the customer has recently viewed by browsing our site */ private function ShowRecentItems() { $viewed = ""; if (isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) { $viewed = $_COOKIE['RECENTLY_VIEWED_PRODUCTS']; } else if (isset($_SESSION['RECENTLY_VIEWED_PRODUCTS'])) { $viewed = $_SESSION['RECENTLY_VIEWED_PRODUCTS']; } if ($viewed != "") { $GLOBALS['HideNoRecentItemsMessage'] = "none"; $GLOBALS['SNIPPETS']['AccountRecentItems'] = ""; $viewed_products = array(); $viewed_products = explode(",", $viewed); foreach ($viewed_products as $k => $p) { $viewed_products[$k] = (int) $p; } // Reverse the array so recently viewed products appear up top $viewed_products = array_reverse($viewed_products); // Hide the compare button if there's less than 2 products if (GetConfig('EnableProductComparisons') == 0 || count($viewed_products) < 2) { $GLOBALS['HideCompareItems'] = "none"; } if (!empty($viewed_products)) { if(!getProductReviewsEnabled()) { $GLOBALS['HideProductRating'] = "display: none"; } $query = " SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL()." FROM [|PREFIX|]products p LEFT JOIN [|PREFIX|]product_images pi ON (productid=pi.imageprodid AND imageisthumb=1) WHERE prodvisible='1' AND productid in ('".implode("','", $viewed_products)."') ".GetProdCustomerGroupPermissionsSQL()." "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductId'] = (int) $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int)$row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = ''; if (GetConfig('ShowProductPrice') && !$row['prodhideprice']) { $GLOBALS['ProductPrice'] = formatProductCatalogPrice($row); } $GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname'])); $GLOBALS['SNIPPETS']['AccountRecentItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AccountRecentlyViewedProducts"); } } } else { $GLOBALS['HideRecentItemList'] = "none"; } } else { $GLOBALS['HideRecentItemList'] = "none"; } $GLOBALS['CompareLink'] = CompareLink(); // Show the list of available shipping addresses $GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName') . " - " . GetLang('RecentlyViewedItems')); $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("account_recentitems"); $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(); }
public function LoadProductsForPage() { $taxJoin = $this->getTaxPricingJoin(); $query = " SELECT p.*, FLOOR(prodratingtotal / prodnumratings) AS prodavgrating, pi.*, " . GetProdCustomerGroupPriceSQL() . " FROM ( SELECT DISTINCT ca.productid, FLOOR(prodratingtotal / prodnumratings) AS prodavgrating FROM [|PREFIX|]categoryassociations ca INNER JOIN [|PREFIX|]products p ON p.productid = ca.productid ".$taxJoin." WHERE ".$this->getProductWhereSQLRestriction()." ORDER BY " . $this->GetSortField() . ", p.prodname ASC " . $GLOBALS['ISC_CLASS_DB']->AddLimit($this->GetStart(), GetConfig('CategoryProductsPerPage')) . " ) AS ca INNER JOIN [|PREFIX|]products p ON p.productid = ca.productid LEFT JOIN [|PREFIX|]product_images pi ON (pi.imageisthumb = 1 AND p.productid = pi.imageprodid) "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $row['prodavgrating'] = (int)$row['prodavgrating']; $this->_catproducts[] = $row; } }
public function SetPanelSettings() { $count = 0; $prod_ids = array(); $output = ""; $GLOBALS['SuggestedProductListing'] = ""; // Hide the "compare" checkbox for each product $GLOBALS['HideCompareItems'] = "none"; // Make sure the query doesn't return the product we're adding to // the cart or any other products in the cart for that matter $GLOBALS['ISC_CLASS_CART'] = GetClass('ISC_CART'); $ignore_prod_list = $GLOBALS['ISC_CLASS_CART']->api->GetProductsInCartCSV(); if ($ignore_prod_list == "") { $ignore_prod_list = 0; } $query = "\n\t\t\t\tSELECT ordprodid\n\t\t\t\tFROM [|PREFIX|]order_products\n\t\t\t\tWHERE orderorderid IN (\n\t\t\t\t\tSELECT orderorderid FROM [|PREFIX|]order_products WHERE ordprodid='" . (int) $GLOBALS['ProductJustAdded'] . "'\n\t\t\t\t) AND ordprodid NOT IN (" . $ignore_prod_list . ")\n\t\t\t\tGROUP BY ordprodid\n\t\t\t\tORDER BY COUNT(ordprodid) DESC\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 9); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Get the list of suggested product id's while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $prod_ids[] = $row['ordprodid']; } $suggest_prod_ids = implode(",", $prod_ids); $remaining_places = 9 - count($prod_ids); // If there aren't enough products to suggest, we will get // the popular products (based on reviews) instead // If there aren't enough suggested products, fetch related products for this item if ($remaining_places > 0) { require_once APP_ROOT . "/includes/classes/class.product.php"; $related = GetRelatedProducts($GLOBALS['Product']['productid'], $GLOBALS['Product']['prodname'], $GLOBALS['Product']['prodrelatedproducts']); // Any returned products? add them to the list $relatedProducts = explode(",", $related); // Limit the number of products to the # of empty spaces we have for ($i = 0; $i <= $remaining_places; ++$i) { if (!isset($relatedProducts[$i]) || $relatedProducts[$i] == "") { break; } if (!in_array($relatedProducts[$i], $prod_ids) && !@in_array($relatedProducts[$i], $ignore_prod_list)) { $prod_ids[] = $relatedProducts[$i]; } } $remaining_places = 9 - count($prod_ids); $suggest_prod_ids = implode(",", $prod_ids); } // Still don't have enough? Fetch popular products if ($remaining_places > 0) { if (!$suggest_prod_ids) { $suggest_prod_ids = 0; } $query = sprintf("select productid, floor(prodratingtotal/prodnumratings) as prodavgrating from [|PREFIX|]products where productid not in (%s) and productid not in (%s) and prodvisible='1' order by prodavgrating desc", $suggest_prod_ids, $ignore_prod_list); $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, $remaining_places); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); // Is there at least one product to suggest? while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $prod_ids[] = $row['productid']; } $suggest_prod_ids = implode(",", $prod_ids); } // If there are *still* no products to suggest, just show them // the normal shopping cart view instead if (!empty($prod_ids)) { // Get a list of products that were ordered at the // same time as the product that was just added to the cart if (!$suggest_prod_ids) { $suggest_prod_ids = 0; } if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\t\tWHERE p.productid IN (" . $suggest_prod_ids . ") AND p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\t\tORDER BY prodnumsold DESC, prodratingtotal DESC\n\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = (int) $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row); $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { //$GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductURL'] = ProdLink($row['prodname']); //blessen if (intval($row['prodretailprice']) <= 0) { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } else { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); } //blessen //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['HideProductVendorName'] = 'display: none'; $GLOBALS['ProductVendor'] = ''; if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) { $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors'); if (isset($vendorCache[$row['prodvendorid']])) { $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>'; $GLOBALS['HideProductVendorName'] = ''; } } $GLOBALS['SuggestedProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryProductsItem"); } } if (!$GLOBALS['SuggestedProductListing']) { ob_end_clean(); header("Location:cart.php"); die; } }
private function editOrderItemSearchAction() { if(empty($_REQUEST['q']) || empty($_REQUEST['quoteSession'])) { exit; } $quote = getClass('ISC_ADMIN_ORDERS')->getQuoteSession($_REQUEST['quoteSession']); if(!$quote) { exit; } $customerGroupId = $quote->getCustomerGroupId(); $_REQUEST['searchQuery'] = $_REQUEST['q']; // autocomplete plugin can send a limit which will be at most 11 but internally we limit this to 2-11 and // reduce it by 1 to get 1-10 and append the 'virtual' item result as #11 $limit = 11; if (isset($_REQUEST['limit'])) { $limit = max(2, min(10, (int)$_REQUEST['limit'])); } $limit--; $numProducts = 0; $result = getClass('ISC_ADMIN_PRODUCT')->_getProductList( 0, 'p.prodname', 'asc', $numProducts, 'DISTINCT p.*, '.GetProdCustomerGroupPriceSQL($customerGroupId), 10); $results = array(); while($product = $this->db->fetch($result)) { $isConfigurable = false; if($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) { $isConfigurable = true; } $options = array( 'customerGroup' => $customerGroupId ); $price = calculateFinalProductPrice($product, $product['prodcalculatedprice'], $options); $price = formatPrice($price); $results[] = array( 'id' => $product['productid'], 'name' => $product['prodname'], 'link' => prodLink($product['prodname']), 'sku' => $product['prodcode'], 'isConfigurable' => $isConfigurable, 'price' => $price ); } $results[] = array( 'id' => 'virtual', 'virtualName' => $_REQUEST['q'], 'name' => GetLang('AddManualProduct'), 'className' => 'recordContentManual', 'price' => GetLang('AddManualProductHelp'), ); echo isc_json_encode($results); }
public function SetPanelSettings() { $viewed = ""; if (isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) { $viewed = $_COOKIE['RECENTLY_VIEWED_PRODUCTS']; } else { if (isset($_SESSION['RECENTLY_VIEWED_PRODUCTS'])) { $viewed = $_SESSION['RECENTLY_VIEWED_PRODUCTS']; } } $GLOBALS['CompareLink'] = CompareLink(); if ($viewed != "") { // Hide the top selling products panel from the cart page $GLOBALS['HideSideTopSellersPanel'] = "none"; $output = ""; $viewed_products = array(); $viewed_products = explode(",", $viewed); foreach ($viewed_products as $k => $p) { $viewed_products[$k] = (int) $p; } // Reverse the array so recently viewed products appear up top $viewed_products = array_reverse($viewed_products); // Hide the compare button if there's less than 2 products if (GetConfig('EnableProductComparisons') == 0 || count($viewed_products) < 2) { $GLOBALS['HideSideProductRecentlyViewedCompare'] = "none"; } if (!empty($viewed_products)) { if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $query = "\n\t\t\t\t\t\tSELECT p.*, prodratingtotal/prodnumratings AS prodavgrating, i.imagefile, i.imageisthumb, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images i ON (p.productid = i.imageprodid AND i.imageisthumb=1)\n\t\t\t\t\t\tWHERE prodvisible='1' AND productid IN ('" . implode("','", $viewed_products) . "')\n\t\t\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) { while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $recently_viewed_products[] = $row; } $GLOBALS['AlternateClass'] = ''; foreach ($viewed_products as $product_id) { foreach ($recently_viewed_products as $row) { if ($product_id == $row['productid']) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = (int) $row['productid']; //temp script to shortern the product name if ($row['prodbrandid'] == 37) { $query = "SELECT c.catname, c.catcombine FROM [|PREFIX|]categories \tc left join [|PREFIX|]categoryassociations ca on c.categoryid = ca.categoryid left join [|PREFIX|]products p on ca.productid = p.productid where p.productid = '" . $row['productid'] . "' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $cat = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if ($cat['catcombine'] != "") { $GLOBALS['ProductName'] = $cat['catcombine'] . " Part Number " . isc_html_escape($row['prodcode']); } else { $GLOBALS['ProductName'] = $cat['catname'] . " Part Number " . isc_html_escape($row['prodcode']); } } else { $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); } //temp script to shortern the product name //$GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { //$GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductURL'] = ProdLink($row['prodname']); //blessen if (intval($row['prodretailprice']) <= 0) { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } else { $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); } //blessen //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['HideProductVendorName'] = 'display: none'; $GLOBALS['ProductVendor'] = ''; if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) { $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors'); if (isset($vendorCache[$row['prodvendorid']])) { $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>'; $GLOBALS['HideProductVendorName'] = ''; } } $GLOBALS['ProductRating'] = $this->getRoundValue((double) $row['prodavgrating']); $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideRecentlyViewedProducts"); } } } } else { $GLOBALS['HideRecentlyViewedProductsPanel'] = "none"; $this->DontDisplay = true; } } else { $GLOBALS['HideRecentlyViewedProductsPanel'] = "none"; $this->DontDisplay = true; } $GLOBALS['SNIPPETS']['SideProductRecentlyViewed'] = $output; } else { // Cookies aren't working, hide the panel $GLOBALS['HideRecentlyViewedProductsPanel'] = "none"; $this->DontDisplay = true; } }
/** * Set the panel settings. */ public function SetPanelSettings() { $cVendor = GetClass('ISC_VENDORS'); $vendor = $cVendor->GetVendor(); $GLOBALS['VendorId'] = $vendor['vendorid']; $GLOBALS['VendorName'] = $vendor['vendorname']; // Set the field we're sorting results by if (isset($_REQUEST['sort'])) { $sort = $_REQUEST['sort']; } else { $sort = ''; } switch ($sort) { case 'newest': $sortField = 'p.productid DESC'; $GLOBALS['SortNewestSelected'] = 'selected="selected"'; break; case 'bestselling': $sortField = 'p.prodnumsold DESC'; $GLOBALS['SortBestSellingSelected'] = 'selected="selected"'; break; case 'alphaasc': $sortField = 'p.prodname ASC'; $GLOBALS['SortAlphaAsc'] = 'selected="selected"'; break; case 'alphadesc': $sortField = 'p.prodname DESC'; $GLOBALS['SortAlphaDesc'] = 'selected="selected"'; break; case 'avgcustomerreview': $sortField = 'prodavgrating DESC'; $GLOBALS['SortAvgReview'] = 'selected="selected"'; break; case 'priceasc': $sortField = 'p.prodcalculatedprice ASC'; $GLOBALS['SortPriceAsc'] = 'selected="selected"'; break; case 'pricedesc': $sortField = 'p.prodcalculatedprice DESC'; $GLOBALS['SortPriceDesc'] = 'selected="selected"'; break; default: $sortField = 'p.prodvendorfeatured DESC'; $sort = 'featured'; $GLOBALS['SortFeaturedSelected'] = 'selected="selected"'; break; } // If we're viewing a certain page, fetch our starting position if (isset($_REQUEST['page']) && IsId($_REQUEST['page'])) { $page = (int) $_REQUEST['page']; $start = $page * GetConfig('CategoryProductsPerPage') - GetConfig('CategoryProductsPerPage'); } else { $page = 1; $start = 0; } // Count the number of products that belong in this vendor $query = "\n\t\t\tSELECT COUNT(p.productid) AS numproducts\n\t\t\tFROM [|PREFIX|]products p\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tWHERE p.prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t"; $numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query); $numPages = ceil($numProducts / GetConfig('CategoryProductsPerPage')); // Now load the actual products for this vendor $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND imageisthumb=1)\n\t\t\t\tWHERE prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t\t\tORDER BY " . $sortField . ", prodname ASC\n\t\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit($start, GetConfig('CategoryProductsPerPage')); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['SNIPPETS']['VendorProducts'] = ''; if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } // Should we show the compare button? if (GetConfig('EnableProductComparisons') == 0 || $numProducts < 2) { $GLOBALS['HideCompareItems'] = "none"; } else { $GLOBALS['CompareLink'] = CompareLink(); } $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } $GLOBALS['ProductId'] = (int) $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice($row); $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname'])); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { $GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['HideProductVendorName'] = 'display: none'; $GLOBALS['ProductVendor'] = ''; if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) { $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors'); if (isset($vendorCache[$row['prodvendorid']])) { $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>'; $GLOBALS['HideProductVendorName'] = ''; } } $GLOBALS['SNIPPETS']['VendorProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorProductsItem"); } // Does paging need to be shown? if ($numProducts > GetConfig('CategoryProductsPerPage')) { $GLOBALS['SNIPPETS']['PagingData'] = ""; $numEitherSide = 5; $start = max($page - $numEitherSide, 1); $end = min($page + $numEitherSide, $numPages); for ($i = $start; $i <= $end; $i++) { if ($i == $page) { $snippet = "CategoryPagingItemCurrent"; } else { $snippet = "CategoryPagingItem"; } $pageData = array('page' => $i, 'sort' => $sort); $GLOBALS['PageLink'] = VendorProductsLink($vendor, $pageData); $GLOBALS['PageNumber'] = $i; $GLOBALS['SNIPPETS']['PagingData'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet); } // Do we need to output a "Previous" link? if ($page > 1) { $pageData = array('page' => $page - 1, 'sort' => $sort); $GLOBALS['PrevLink'] = VendorProductsLink($vendor, $pageData); $GLOBALS['SNIPPETS']['CategoryPagingPrevious'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingPrevious"); } // Do we need to output a "Next" link? if ($page < $numPages) { $pageData = array('page' => $page + 1, 'sort' => $sort); $GLOBALS['NextLink'] = VendorProductsLink($vendor, $pageData); $GLOBALS['SNIPPETS']['CategoryPagingNext'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPagingNext"); } $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryPaging"); $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']); $GLOBALS['SNIPPETS']['ProductPaging'] = $output; } // Parse the sort select box snippet if ($numProducts > 1) { // Parse the sort select box snippet if ($GLOBALS['EnableSEOUrls'] == 1 && $vendor['vendorfriendlyname']) { $GLOBALS['URL'] = VendorProductsLink($vendor); } else { $GLOBALS['URL'] = $GLOBALS['ShopPath'] . "/vendors.php"; $GLOBALS['HiddenSortField'] = "<input type=\"hidden\" name=\"vendorid\" value=\"" . (int) $vendor['vendorid'] . "\" />"; $GLOBALS['HiddenSortField'] .= "<input type=\"hidden\" name=\"action\" value=\"products\" />"; } $GLOBALS['SNIPPETS']['CategorySortBox'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategorySortBox"); } }
/** * Set the panel settings */ public function SetPanelSettings() { $count = 1; if (GetConfig('EnableProductReviews') == 0) { $GLOBALS['HideProductRating'] = "display: none"; } $output = ""; $vendorRestriction = ''; // If we're on a vendor page, only show top sellers from this particular vendor if (isset($GLOBALS['ISC_CLASS_VENDORS'])) { $vendor = $GLOBALS['ISC_CLASS_VENDORS']->GetVendor(); $vendorRestriction = " AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'"; } $query = "\n\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\tFROM [|PREFIX|]products p\n\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1)\n\t\t\tWHERE p.prodnumsold > '0' AND p.prodvisible='1' " . $vendorRestriction . "\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tORDER BY p.prodnumsold DESC\n\t\t"; $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $GLOBALS['AlternateClass'] = ''; while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($GLOBALS['AlternateClass'] == 'Odd') { $GLOBALS['AlternateClass'] = 'Even'; } else { $GLOBALS['AlternateClass'] = 'Odd'; } $GLOBALS['ProductCartQuantity'] = ''; if (isset($GLOBALS['CartQuantity' . $row['productid']])) { $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']]; } // Use the SideTopSellersFirst snippet for the first product only if ($count == 1) { $snippet = "SideTopSellersFirst"; } else { $snippet = "SideTopSellers"; } $GLOBALS['ProductThumb'] = ImageThumbNew($row['imagefile'], ProdLink($row['prodname'])); if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) { $GLOBALS['ProductURL'] = ProdLink($row['prodname']); $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink'); } else { $GLOBALS['ProductURL'] = CartLink($row['productid']); $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); } if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) { $GLOBALS['HideActionAdd'] = ''; } else { $GLOBALS['HideActionAdd'] = 'none'; } $GLOBALS['HideProductVendorName'] = 'display: none'; $GLOBALS['ProductVendor'] = ''; if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) { $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors'); if (isset($vendorCache[$row['prodvendorid']])) { $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>'; $GLOBALS['HideProductVendorName'] = ''; } } $GLOBALS['ProductNumber'] = $count++; $GLOBALS['ProductId'] = $row['productid']; $GLOBALS['ProductName'] = isc_html_escape($row['prodname']); // Determine the price of this product $GLOBALS['ProductPrice'] = CalculateProductPrice($row); $GLOBALS['ProductRating'] = (int) $row['prodavgrating']; $GLOBALS['ProductLink'] = ProdLink($row['prodname']); $output .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet($snippet); } $GLOBALS['SNIPPETS']['SideTopSellers'] = $output; if (!$output) { $this->DontDisplay = true; } }
/** * Build an SQL query for the specified search terms. * * @param array Array of search terms * @param string String of fields to match * @param string The field to sort by * @param string The order to sort results by * @return array An array containing the query to count the number of results and a query to perform the search */ function BuildProductSearchQuery($searchTerms, $fields = "", $sortField = array("score", "proddateadded"), $sortOrder = "desc") { $queryWhere = array(); $joinQuery = ''; $queryWhere1 = array(); $joinQuery1 = ''; $qualifier_flag = 0; $qualifier_category = 0; $v_cols = array(); $p_cols = array(); /*$q_qry = "select * from isc_import_variations limit 0,1"; $q_res = $GLOBALS['ISC_CLASS_DB']->Query($q_qry); $q_row = $GLOBALS['ISC_CLASS_DB']->Fetch($q_res); foreach($q_row as $q_key => $q_val) { if(eregi('^(vq)', $q_key)) { $v_cols[] = $q_key; } else if(eregi('^(pq)', $q_key)) { $p_cols[] = $q_key; } }*/ $v_cols = isset($GLOBALS['sidev_cols']) ? $GLOBALS['sidev_cols'] : array(); $p_cols = isset($GLOBALS['sidep_cols']) ? $GLOBALS['sidep_cols'] : array(); $common_fields_product = " b.callbestprice bbestprice, c.callbestprice cbestprice, bs.callbestprice sbestprice,p.prodcode, p.productid , b.brandname , c.categoryid, c.catname , c.catuniversal,csi.icon_file "; $common_fields_variation = " p.prodcode, v.productid, v.prodstartyear, v.prodendyear , v.prodmodel, v.prodsubmodel, v.prodmake "; $new_fields = " p.proddesc , p.prodname , p.proddescfeature , prodwarranty , p.prodvariationid,p.prodconfigfields,p.prodeventdaterequired,p.prodvendorid,p.prodprice,p.prodretailprice,p.prodsaleprice,p.prodistaxable,p.prodcatids,p.prodhideprice,p.prodinvtrack,p.prodcurrentinv,p.prodallowpurchases,p.prodbrandid,p.prodcalculatedprice,prodweight,prodheight "; // Construct the full text search part of the query /*$fulltext_fields = array("ps.prodname", "ps.prodcode", "ps.proddesc", "ps.prodsearchkeywords", "ps.prodalternates", "ps.prodmake", "ps.prodmodel", "ps.prodsubmodel", "ps.prodstartyear", "ps.prodendyear");*/ $fulltext_fields = array("ps.prodname", "ps.prodcode", "ps.proddesc", "ps.prodsearchkeywords"); if (!$fields) { $fields = "{$new_fields}, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, " . GetProdCustomerGroupPriceSQL() . ", "; $fields .= "pi.imageisthumb, pi.imagefile "; if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { //$fields .= ', '.$GLOBALS['ISC_CLASS_DB']->FullText($fulltext_fields, $searchTerms['search_query'], false) . " as score "; } } $fields1 = $fields . " ,v. " . implode(",v.", $v_cols); //$fields .= " ,v. ".implode(",v. ",$v_cols).", group_concat(distinct PQcolor,', ',PQmaterial,', ',PQstyle separator '~') as productoption "; //$fields .= " , group_concat(distinct PQcolor,', ',PQmaterial,', ',PQstyle separator '~') as productoption "; if (isset($searchTerms['categoryid'])) { $searchTerms['category'] = array($searchTerms['categoryid']); } // If we're searching by category, we need to completely // restructure the search query - so do that first $categorySearch = false; $categoryIds = array(); if (isset($searchTerms['category']) && is_array($searchTerms['category'])) { foreach ($searchTerms['category'] as $categoryId) { // All categories were selected, so don't continue if ($categoryId == 0) { $categorySearch = false; break; } $categoryIds[] = (int) $categoryId; // If searching sub categories automatically, fetch & tack them on if (isset($searchTerms['searchsubs']) && $searchTerms['searchsubs'] == 'ON') { $categoryIds = array_merge($categoryIds, GetChildCats($categoryId)); } } $categoryIds = array_unique($categoryIds); if (!empty($categoryIds)) { $categorySearch = true; } } /* this below is condition is used when category is mentioned in search keyword */ if (isset($searchTerms['srch_category'])) { $categorySearch = true; $categoryIds = $searchTerms['srch_category']; } if ($categorySearch == true) { $qualifier_category = 1; $qualifier_flag = 1; /*$fromTable = 'isc_categoryassociations a, isc_products p '; $queryWhere[] = 'a.productid=p.productid AND a.categoryid IN ('.implode(',', $categoryIds).')'; $fromTable1 = 'isc_categoryassociations a, isc_import_variations v '; $queryWhere1[] = 'a.productid=v.productid AND a.categoryid IN ('.implode(',', $categoryIds).')';*/ if ($searchTerms['flag_srch_category'] == 1) { $fromTable = 'isc_products p USE INDEX (PRIMARY) '; } else { $fromTable = 'isc_products p '; } // $fromTable = 'isc_products p USE INDEX (categoryid) '; $queryWhere[] = 'c.categoryid IN (' . implode(',', $categoryIds) . ')'; $fromTable1 = 'isc_import_variations v '; $queryWhere1[] = 'c.categoryid IN (' . implode(',', $categoryIds) . ')'; } else { $fromTable = 'isc_products p'; $fromTable1 = 'isc_import_variations v'; $queryWhere[] = " c.categoryid is not null "; } /* this code is commented as we are no longer checking in search table as the records are split in product and variations table. if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { // Only need the product search table if we have a search query $joinQuery .= "INNER JOIN [|PREFIX|]product_search ps ON (p.productid=ps.productid) "; } else if ($sortField == "score") { // If we don't, we better make sure we're not sorting by score $sortField = "p.prodname"; $sortOrder = "ASC"; } */ /* Below condition has been added if any product detail page is seen directly , need to assign it as array */ if (!isset($searchTerms['dynfilters'])) { $searchTerms['dynfilters'] = array(); } $otherkeys = array_keys($searchTerms['dynfilters'], "others"); $others_factor = ''; /* if ( isset($searchTerms['partnumber']) || ( isset($searchTerms['flag_srch_category']) && $searchTerms['flag_srch_category'] == 1 ) || (isset($searchTerms['flag_srch_brand']) && $searchTerms['flag_srch_brand'] == 1 ) || isset($searchTerms['series']) || isset($searchTerms['subcategory']) ) { // listing page } else { foreach ($otherkeys as $otherkey) { //$others_factor .= " AND (".$otherkey." = '' OR ".$otherkey." IS NULL )"; $others_factor .= " AND (".$otherkey." = '' OR ".$otherkey." IS NULL )"; } } */ $partnumber_condition = ""; if (!isset($searchTerms['partnumber'])) { //$partnumber_condition = "and c.catvisible = 1 "; } $joinQuery .= " LEFT JOIN [|PREFIX|]import_variations AS v ON v.productid = p.productid " . $others_factor . "\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]categoryassociations ca on ca.productid = p.productid \n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]categories c on c.categoryid = ca.categoryid " . $partnumber_condition . " \n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]brands b on prodbrandid = b.brandid \n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]brand_series AS bs ON bs.seriesid = p.brandseriesid \n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1)\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]product_finalprice fp ON p.productid = fp.productid\n\t\t\t\t\t\tLEFT JOIN [|PREFIX|]prodcut_cap_size_images csi ON p.prodcode = csi.productcode and p.prodvendorprefix = csi.vendor_prix "; $joinQuery1 .= " LEFT JOIN [|PREFIX|]import_variations AS v ON v.productid = p.productid " . $others_factor . "\n\t\t\t\t\t\t\tLEFT JOIN [|PREFIX|]categoryassociations ca on ca.productid = p.productid \n\t\t\t\t\t\t\tLEFT JOIN [|PREFIX|]categories c on c.categoryid = ca.categoryid " . $partnumber_condition . " \n\t\t\t\t\t\t\tLEFT JOIN [|PREFIX|]brands b on prodbrandid = b.brandid \n\t\t\t\t\t\t\tLEFT JOIN [|PREFIX|]brand_series AS bs ON bs.seriesid = p.brandseriesid "; $queryWhere1[] = $queryWhere[] = "p.prodvisible='1'"; // Add in the group category restrictions $permissionSql = GetProdCustomerGroupPermissionsSQL(null, false); if ($permissionSql) { $queryWhere1[] = $queryWhere[] = $permissionSql; } // Do we need to filter on brand? if (isset($searchTerms['brand']) && $searchTerms['brand'] != "") { $brand_query = "select brandid from [|PREFIX|]brands WHERE brandname='" . $searchTerms['brand'] . "'"; $brand_result = $GLOBALS['ISC_CLASS_DB']->Query($brand_query); $brandId = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_result); if ((int) $brandId > 0) { $qualifier_flag = 1; $queryWhere1[] = $queryWhere[] = "p.prodbrandid='" . $GLOBALS['ISC_CLASS_DB']->Quote($brandId) . "'"; } } // Do we need to filter on brand series? if (isset($searchTerms['series']) && $searchTerms['series'] != "") { $qualifier_flag = 1; if (isset($GLOBALS['seriesid'])) { $brand_series_id = (int) $GLOBALS['seriesid']; } else { $series_qry = "select s.seriesid from isc_brand_series s where s.seriesname = '" . $searchTerms['series'] . "' "; $series_res = $GLOBALS['ISC_CLASS_DB']->Query($series_qry); $series_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($series_res); $brand_series_id = (int) $series_arr['seriesid']; } $queryWhere1[] = $queryWhere[] = " p.brandseriesid = " . $GLOBALS['ISC_CLASS_DB']->Quote($brand_series_id); } if (isset($searchTerms['partnumber'])) { $qualifier_flag = 1; $prod_code = $searchTerms['partnumber']; $queryWhere1[] = $queryWhere[] = " p.prodcode like '" . $prod_code . "%'"; } // Do we need to filter on price? if (isset($searchTerms['price'])) { $queryWhere1[] = $queryWhere[] = "p.prodcalculatedprice='" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['price']) . "'"; } else { /*if (isset($searchTerms['price_from']) && is_numeric($searchTerms['price_from'])) { $queryWhere1[] = $queryWhere[] = "p.prodcalculatedprice >= '".$GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['price_from'])."'"; } if (isset($searchTerms['price_to']) && is_numeric($searchTerms['price_to'])) { $queryWhere1[] = $queryWhere[] = "p.prodcalculatedprice <= '".$GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['price_to'])."'"; }*/ } // Do we need to filter on rating? if (isset($searchTerms['rating'])) { $queryWhere1[] = $queryWhere[] = "FLOOR(p.prodratingtotal/p.prodnumratings) = '" . (int) $searchTerms['rating'] . "'"; } else { if (isset($searchTerms['rating_from']) && is_numeric($searchTerms['rating_from'])) { $queryWhere1[] = $queryWhere[] = "FLOOR(p.prodratingtotal/p.prodnumratings) >= '" . (int) $searchTerms['rating_from'] . "'"; } if (isset($searchTerms['rating_to']) && is_numeric($searchTerms['rating_to'])) { $queryWhere1[] = $queryWhere[] = "FLOOR(p.prodratingtotal/p.prodnumratings) <= '" . (int) $searchTerms['rating_to'] . "'"; } } // Do we need to filter on featured? if (isset($searchTerms['featured']) && $searchTerms['featured'] != "") { $featured = (int) $searchTerms['featured']; if ($featured == 1) { $queryWhere1[] = $queryWhere[] = "p.prodfeatured=1"; } else { $queryWhere1[] = $queryWhere[] = "p.prodfeatured=0"; } } // Do we need to filter on free shipping? if (isset($searchTerms['shipping']) && $searchTerms['shipping'] != "") { $shipping = (int) $searchTerms['shipping']; if ($shipping == 1) { $queryWhere1[] = $queryWhere[] = "p.prodfreeshipping='1' "; } else { $queryWhere1[] = $queryWhere[] = "p.prodfreeshipping='0' "; } } // Do we need to filter only products we have in stock? if (isset($searchTerms['instock']) && $searchTerms['instock'] != "") { $stock = (int) $searchTerms['instock']; if ($stock == 1) { $queryWhere1[] = $queryWhere[] = "(p.prodcurrentinv>0 or p.prodinvtrack=0) "; } } // Do we need to filter for make of the product if (isset($searchTerms['make']) && $searchTerms['make'] != "" && (!isset($searchTerms['catuniversal']) || $searchTerms['catuniversal'] != 1)) { $make = $searchTerms['make']; if (!empty($make)) { $qualifier_flag = 1; $ext = ""; //if(isset($searchTerms['is_catg'])) $ext .= " OR v.prodmake = 'NON-SPEC VEHICLE' "; $queryWhere[] = " ( v.prodmake = '" . $make . "' {$ext} ) "; $queryWhere1[] = " ( v.prodmake = '" . $make . "' {$ext} ) "; } } // Do we need to filter for model of the product if (isset($searchTerms['model']) && $searchTerms['model'] != "" && (!isset($searchTerms['catuniversal']) || $searchTerms['catuniversal'] != 1)) { $model = $searchTerms['model']; if (!empty($model)) { $qualifier_flag = 1; $ext = ""; //if(isset($searchTerms['is_catg'])) $ext .= " OR v.prodmodel = 'ALL' "; //if(isset($_REQUEST['model'])) { if (!isset($searchTerms['model_flag']) || isset($searchTerms['model_flag']) && $searchTerms['model_flag'] == 1) { $queryWhere[] = " ( v.prodmodel = '" . $model . "' {$ext} ) "; $queryWhere1[] = " ( v.prodmodel = '" . $model . "' {$ext} ) "; } else { $queryWhere[] = " ( v.prodmodel like '" . $model . "%' {$ext} ) "; $queryWhere1[] = " ( v.prodmodel like '" . $model . "%' {$ext} ) "; } } } // Do we need to filter for submodel of the product if (isset($searchTerms['submodel']) && $searchTerms['submodel'] != "") { $submodel = $searchTerms['submodel']; if (!empty($model)) { $qualifier_flag = 1; $queryWhere[] = " ( v.prodsubmodel = '" . $submodel . "' OR v.prodsubmodel = '' ) "; $queryWhere1[] = " ( v.prodsubmodel = '" . $submodel . "' OR v.prodsubmodel = '' ) "; } } // Do we need to filter for year of the product if (isset($searchTerms['year']) && $searchTerms['year'] != "" && (!isset($searchTerms['catuniversal']) || $searchTerms['catuniversal'] != 1)) { $year = $searchTerms['year']; if (!empty($year)) { $qualifier_flag = 1; if (is_numeric($year)) { $ext = ""; //if(isset($searchTerms['is_catg'])) $ext .= " OR v.prodstartyear = 'ALL' "; $queryWhere[] = " ( " . $year . " between v.prodstartyear and v.prodendyear {$ext} ) "; $queryWhere1[] = " ( " . $year . " between v.prodstartyear and v.prodendyear {$ext} ) "; } else { $queryWhere[] = " ( v.prodstartyear = '{$year}' OR v.prodendyear = '{$year}' ) "; $queryWhere1[] = " ( v.prodstartyear = '{$year}' OR v.prodendyear = '{$year}' ) "; } } } /*if (isset($searchTerms['weight']) && $searchTerms['weight'] != "") { $weight = $searchTerms['weight']; if (!empty($year)) { $queryWhere[] = " p.prodweight = ".$weight; } } if (isset($searchTerms['height']) && $searchTerms['height'] != "") { $height = $searchTerms['height']; if (!empty($year)) { $queryWhere[] = " p.prodheight = ".$height; } } if (isset($searchTerms['brand']) && $searchTerms['brand'] != "") { $brand = $searchTerms['brand']; if (!empty($brand)) { $queryWhere[] = " p.prodbrandid = ".$brand; $queryWhere1[] = " p.prodbrandid = ".$brand; } }*/ if (isset($searchTerms['price_from']) && isset($searchTerms['price_to'])) { $from_price = $searchTerms['price_from']; $to_price = $searchTerms['price_to']; if ($from_price != "" && $to_price != "") { $queryWhere1[] = $queryWhere[] = " p.prodcalculatedprice between " . $from_price . " and " . $to_price; } } else { if (isset($searchTerms['price_from'])) { $from_price = $searchTerms['price_from']; if (!empty($from_price)) { $queryWhere1[] = $queryWhere[] = " p.prodcalculatedprice >= " . $from_price; } } else { if (isset($searchTerms['price_to'])) { $to_price = $searchTerms['price_to']; if (!empty($to_price)) { $queryWhere1[] = $queryWhere[] = " p.prodcalculatedprice <= " . $from_price; } } } } /* --------- these below coditions are commented as they now belongs to qualifiers table ------------ if (isset($searchTerms['bedsize']) && $searchTerms['bedsize'] != "") { $bedsize = $searchTerms['bedsize']; if (!empty($bedsize)) { $queryWhere1[] = $queryWhere[] = " p.prodbedsize like '%".$bedsize."%'"; } } if (isset($searchTerms['cabsize']) && $searchTerms['cabsize'] != "") { $cabsize = $searchTerms['cabsize']; if (!empty($cabsize)) { $queryWhere1[] = $queryWhere[] = " p.prodcabsize like '%".$cabsize."%'"; } } if (isset($searchTerms['tracksystem']) && $searchTerms['tracksystem'] != "") { $tracksystem = $searchTerms['tracksystem']; if (!empty($tracksystem)) { $queryWhere1[] = $queryWhere[] = " p.truckbedtracksystemtype like '%".$tracksystem."%'"; } } if (isset($searchTerms['material']) && $searchTerms['material'] != "") { $material = $searchTerms['material']; if (!empty($material)) { $queryWhere1[] = $queryWhere[] = " p.prodmaterial like '%".$material."%'"; } } if (isset($searchTerms['style']) && $searchTerms['style'] != "") { $style = $searchTerms['style']; if (!empty($style)) { $queryWhere1[] = $queryWhere[] = " p.prodstyle like '%".$style."%'"; } } if (isset($searchTerms['color']) && $searchTerms['color'] != "") { $color = $searchTerms['color']; if (!empty($color)) { $queryWhere1[] = $queryWhere[] = " p.prodcolor like '%".$color."%'"; } } /*---------------------------------------------------------------------------------------------*/ /*---- the below variables are used for displaying submodels in sideproductfilters.php --- */ $GLOBALS['qualifiercategory'] = $qualifier_category; $GLOBALS['wherecondition'] = $queryWhere; $GLOBALS['wherecondition1'] = $queryWhere1; /*--------- creating conditions for dynamic filters----------*/ $havingquery = array(); $outer_condition = ""; if (!empty($searchTerms['dynfilters'])) { $dynfilters = $searchTerms['dynfilters']; foreach ($dynfilters as $dynkey => $dynval) { $qualifier_flag = 1; $orgdynkey = $dynkey; //Added by Simha $str_to_check_pqvq = ""; if (!isset($searchTerms['catuniversal']) || $searchTerms['catuniversal'] == 0) { $str_to_check_pqvq = '^(vq|pq)'; } else { $str_to_check_pqvq = '^pq'; } if (eregi($str_to_check_pqvq, $dynkey)) { $dynkey = " v.{$dynkey} "; //$outer_condition .= " AND $dynkey like '%".$dynval."%'"; if ($dynval == 'others') { $havingquery[] = "( {$orgdynkey} = '' OR {$orgdynkey} IS NULL OR {$orgdynkey} = '~' )"; // here included '~' as in left navi query will return ~ } else { if (strcasecmp($dynkey, ' v.VQbedsize ') == 0) { $outer_condition .= " AND ( ( ( {$dynkey} = '" . $dynval . "') OR ( {$dynkey} regexp ';' AND {$dynkey} regexp '" . $dynval . "' ) ) OR ( ( v.bedsize_generalname = '" . $dynval . "' ) OR ( v.bedsize_generalname regexp ';' AND v.bedsize_generalname regexp '" . $dynval . "' ) ) ) "; } else { if (strcasecmp($dynkey, ' v.VQcabsize ') == 0) { $outer_condition .= " AND ( ( ( {$dynkey} = '" . $dynval . "') OR ( {$dynkey} regexp ';' AND {$dynkey} regexp '" . $dynval . "' ) ) OR ( ( v.cabsize_generalname = '" . $dynval . "' ) OR ( v.cabsize_generalname regexp ';' AND v.cabsize_generalname regexp '" . $dynval . "' ) ) ) "; } else { $outer_condition .= " AND ( ( {$dynkey} regexp ';' AND {$dynkey} regexp '" . $dynval . "' ) OR ( {$dynkey} not regexp ';' AND {$dynkey} = '" . $dynval . "') )"; } } } } } } if (isset($searchTerms['vqsbedsize'])) { $qualifier_flag = 1; $outer_condition .= " AND ( v.VQbedsize like '%" . $searchTerms['vqsbedsize'] . "%' OR v.bedsize_generalname like '%" . $searchTerms['vqsbedsize'] . "%' ) "; } if (isset($searchTerms['vqscabsize'])) { $qualifier_flag = 1; $outer_condition .= " AND ( v.VQcabsize like '%" . $searchTerms['vqscabsize'] . "%' OR v.cabsize_generalname like '%" . $searchTerms['vqscabsize'] . "%' ) "; } if (($qualifier_flag == 0 || isset($searchTerms['search'])) && (eregi('search.php', $_SERVER['REQUEST_URI']) || isset($GLOBALS['PathInfo']) && count($GLOBALS['PathInfo']) > 0) && !isset($_REQUEST['change'])) { //$joinQuery .= "INNER JOIN isc_product_search ps ON (p.productid=ps.productid)"; //$joinQuery1 .= "INNER JOIN isc_product_search ps ON (p.productid=ps.productid)"; if (isset($searchTerms['search_string'])) { $searchTerms['search_query'] = $searchTerms['search_string']; } if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "" && $searchTerms['search_query'] != "categories" && $searchTerms['search_query'] != "brands") { //$termQuery = "(" . $GLOBALS['ISC_CLASS_DB']->FullText($fulltext_fields, $searchTerms['search_query'], true); //$termQuery = " ( "; $termQuery = " p.prodname = '" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "' "; //$termQuery .= " p.prodname like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; /*$termQuery .= "OR p.proddesc like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR p.prodsearchkeywords like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodalternates like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodmake like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodmodel like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodsubmodel like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodstartyear like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR ps.prodendyear like '%" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "%' "; $termQuery .= "OR p.prodcode = '" . $GLOBALS['ISC_CLASS_DB']->Quote($searchTerms['search_query']) . "') ";*/ $queryWhere1[] = $queryWhere[] = $termQuery; } } if (!is_array($sortField)) { $sortField = array($sortField); } if (!is_array($sortOrder)) { $sortOrder = array($sortOrder); } $sortField = array_filter($sortField); $sortOrder = array_filter($sortOrder); if (count($sortOrder) < count($sortField)) { $missing = count($sortField) - count($sortOrder); $sortOrder += array_fill(count($sortOrder), $missing, 'desc'); } else { if (count($sortOrder) > count($sortField)) { $sortOrder = array_slice($sortOrder, 0, count($sortField)); } } if (!empty($sortField)) { $orderBy = array(); $sortField = array_values($sortField); $sortOrder = array_values($sortOrder); foreach ($sortField as $key => $field) { $orderBy[] = $field . ' ' . $sortOrder[$key]; } $orderBy = ' ORDER BY ' . implode(',', $orderBy); } else { $orderBy = ''; } $orderBy = ''; /* the below query is used to check whether any series exist under the selected brand */ if (isset($searchTerms['flag_srch_brand']) && $searchTerms['flag_srch_brand'] == 0) { $brand_series_qry = "select p.brandseriesid from isc_products p LEFT JOIN isc_categoryassociations ca on ca.productid = p.productid LEFT JOIN isc_categories c on c.categoryid = ca.categoryid LEFT JOIN isc_import_variations AS v ON p.productid = v.productid\nWHERE prodbrandid = " . $brandId . " and brandseriesid != 0 " . GetWhereWithAnd($queryWhere) . " {$outer_condition} group by brandseriesid"; $brand_series_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_series_qry); if ($GLOBALS['ISC_CLASS_DB']->CountResult($brand_series_res) > 0) { $GLOBALS['BRAND_SERIES_FLAG'] = 0; } else { $GLOBALS['BRAND_SERIES_FLAG'] = 1; } // series not exist under a brand } $qualifiers_where = ""; ##Added by Simha // for "others" values in qualifier filters //$otherkeys = array_keys($searchTerms['dynfilters'], "others"); $extrasearch = ''; foreach ($p_cols as $key => $value) { if (in_array($value, $otherkeys)) { $extrasearch .= ',MAX(' . $value . ') as ' . $value . ''; unset($p_cols[$key]); $p_cols = array_values($p_cols); } } foreach ($v_cols as $key => $value) { if (in_array($value, $otherkeys)) { $extrasearch .= ',MAX(' . $value . ') as ' . $value . ''; unset($v_cols[$key]); $v_cols = array_values($v_cols); } } ##Added by Simha Ends $v_cols_new = ''; $p_cols_new = ''; if (empty($p_cols)) { $p_cols_new = " '' as productoption "; } else { //$p_cols = " CONCAT_WS('~',".implode(' , ' , $p_cols).") as productoption "; //$p_cols = implode(' , ' , $p_cols); for ($k = 0; $k < count($p_cols); $k++) { //$p_cols = implode(' , ' , $p_cols); $p_cols_new .= " group_concat(DISTINCT " . $p_cols[$k] . " separator '~') as " . $p_cols[$k] . " ,"; } } if (empty($v_cols)) { $v_cols_new = " '' as vehicleoption "; } else { //$v_cols = " CONCAT_WS('~',".implode(' , ' , $v_cols).") as vehicleoption "; //$v_cols = implode(' , ' , $v_cols); for ($k = 0; $k < count($v_cols); $k++) { //$p_cols = implode(' , ' , $p_cols); //2010-11-15 Ronnie modify,VQcabsize,VQbedsize not is Special /*if( $v_cols[$k] == 'VQbedsize' ) { $v_cols_new .= " group_concat( DISTINCT if( v.bedsize_generalname != '', v.bedsize_generalname, v.VQbedsize ) separator '~' ) as VQbedsize ,"; } else if( $v_cols[$k] == 'VQcabsize' ) { //$v_cols_new .= " group_concat( DISTINCT if( v.cabsize_generalname != '', v.cabsize_generalname, v.VQcabsize ) separator '~' ) as VQcabsize ,"; $v_cols_new .= " group_concat( DISTINCT v.VQcabsize separator '~' ) as VQcabsize ,"; } else {*/ $v_cols_new .= " group_concat(DISTINCT " . $v_cols[$k] . " separator '~') as " . $v_cols[$k] . " ,"; //} } } $v_cols_new = trim($v_cols_new, ','); $p_cols_new = trim($p_cols_new, ','); //lguan_20100612: Added rating into select fields list if (isset($searchTerms['flag_srch_brand']) && $GLOBALS['BRAND_SERIES_FLAG'] == 0 && (!isset($searchTerms['srch_category']) || isset($searchTerms['category'])) && !isset($searchTerms['partnumber'])) { $GLOBALS['srch_where'] = "c.catname , c.categoryid , c.catuniversal , group_concat(DISTINCT ca.categoryid separator '~') as subcatgids , pa.catname as parentcatname , group_concat(DISTINCT brandname separator '~') as brandname , min(fp.prodfinalprice) as prodminprice , max(fp.prodfinalprice) as prodmaxprice , bs.seriesphoto as imagefile , p.proddesc , prodwarranty , bs.seriesname, bs.displayname, p.brandseriesid , count(distinct p.productid) as totalproducts , bs.feature_points1 , bs.feature_points2 , bs.feature_points3 , bs.feature_points4 , bs.feature_points , bs.seriesimagealt , b.brandimagefile , b.brandlargefile , b.branddescription , b.brandfooter, bs.serieshoverimagefile,floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings)) AS prodavgrating "; $joinQuery .= "LEFT JOIN isc_categories pa on pa.categoryid = c.catparentid"; $orderBy = ' ORDER BY bs.seriessort ASC , bs.seriesname ASC '; $queryWhere1[] = $queryWhere[] = " p.brandseriesid != 0 "; if (!empty($havingquery)) { $queryWhere1[] = $queryWhere[] = implode(' AND ', $havingquery); unset($havingquery); $extrasearch = ""; } } else { if (isset($searchTerms['flag_srch_category']) && $searchTerms['flag_srch_category'] == 0 && (!isset($GLOBALS['BRAND_SERIES_FLAG']) || isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 0) && !isset($searchTerms['partnumber'])) { //wirror_20100809: add a return field for custom category filter //wirror_20101011: remove the group_concat products $GLOBALS['srch_where'] = "c.catname , c.categoryid , c.catuniversal , c.catimagealt , c.featurepoints , group_concat(DISTINCT brandname separator '~') as brandname , group_concat(DISTINCT p.brandseriesid separator '~') as seriesids , min(fp.prodfinalprice) as prodminprice , max(fp.prodfinalprice) as prodmaxprice , c.catimagefile as imagefile , c.cathoverimagefile , p.proddesc , prodwarranty , bs.seriesname, bs.displayname, p.brandseriesid , count(distinct p.productid) as totalproducts,floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings)) AS prodavgrating "; $orderBy = ' ORDER BY c.catdeptid ASC, c.catsort ASC, c.catname ASC '; if (!empty($havingquery)) { $queryWhere1[] = $queryWhere[] = implode(' AND ', $havingquery); unset($havingquery); $extrasearch = ""; } } else { $GLOBALS['srch_where'] = $common_fields_product . "," . $fields . " , {$p_cols_new} , {$v_cols_new} , bs.seriesname, bs.displayname, p.brandseriesid , bs.seriesdescription , bs.seriesfooter , b.brandimagefile, bs.serieslogoimage "; $GLOBALS['srch_where'] .= $extrasearch; } } $query = "select " . $GLOBALS['srch_where'] . " from\n\t{$fromTable} {$joinQuery} WHERE 1=1 " . GetWhereWithAnd($queryWhere) . " {$outer_condition} "; $countQuery = "SELECT count(p.productid) " . $extrasearch . " FROM {$fromTable}\n\t{$joinQuery1} WHERE 1=1 " . GetWhereWithAnd($queryWhere) . " {$outer_condition} "; //wirror_yin20101102: put the join statement to $_GLOBALS $GLOBALS['join_query'] = $joinQuery; if (isset($havingquery) && count($havingquery) > 0) { $GLOBALS['having_query'] = " HAVING (" . implode(' AND ', $havingquery) . ")"; } else { $GLOBALS['having_query'] = ''; } return array('query' => $query, 'countQuery' => $countQuery, 'orderby' => $orderBy); }
function GetProductQuery($fields = "") { $searchTerms = $this->_searchterms; $queryWhere = array(); $v_cols = array(); $p_cols = array(); $v_cols = isset($GLOBALS['sidev_cols']) ? $GLOBALS['sidev_cols'] : array(); $p_cols = isset($GLOBALS['sidep_cols']) ? $GLOBALS['sidep_cols'] : array(); //2011-3-23 Ronnie add, add fields {b.callbestprice bbestprice, c.callbestprice cbestprice, bs.callbestprice sbestprice} $common_fields_product = " b.callbestprice bbestprice, c.callbestprice cbestprice, bs.callbestprice sbestprice, p.prodcode, p.productid , b.brandname , c.categoryid, c.catname , c.catuniversal,p.proddateadded,csi.icon_file "; $common_fields_variation = " p.prodcode, v.productid, v.prodstartyear, v.prodendyear , v.prodmodel, v.prodsubmodel, v.prodmake "; $new_fields = " p.proddesc , p.prodname , p.proddescfeature , prodwarranty , p.prodvariationid,p.prodconfigfields,p.prodeventdaterequired,p.prodvendorid,p.prodprice,p.prodretailprice,p.prodsaleprice,p.prodistaxable,p.prodcatids,p.prodhideprice,p.prodinvtrack,p.prodcurrentinv,p.prodallowpurchases,p.prodbrandid,p.prodcalculatedprice,prodweight,prodheight "; // Construct the full text search part of the query /*$fulltext_fields = array("ps.prodname", "ps.prodcode", "ps.proddesc", "ps.prodsearchkeywords", "ps.prodalternates", "ps.prodmake", "ps.prodmodel", "ps.prodsubmodel", "ps.prodstartyear", "ps.prodendyear");*/ $fulltext_fields = array("ps.prodname", "ps.prodcode", "ps.proddesc", "ps.prodsearchkeywords"); if (!$fields) { $fields = "{$new_fields}, FLOOR(p.prodratingtotal/p.prodnumratings) AS prodavgrating, " . GetProdCustomerGroupPriceSQL() . ", "; $fields .= "pi.imageisthumb, pi.imagefile "; if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { //$fields .= ', '.$GLOBALS['ISC_CLASS_DB']->FullText($fulltext_fields, $searchTerms['search_query'], false) . " as score "; } } $fields1 = $fields . " ,v. " . implode(",v.", $v_cols); if (isset($searchTerms['categoryid'])) { $searchTerms['category'] = array($searchTerms['categoryid']); } // If we're searching by category, we need to completely // restructure the search query - so do that first $categorySearch = false; $categoryIds = array(); if (isset($searchTerms['category']) && is_array($searchTerms['category'])) { foreach ($searchTerms['category'] as $categoryId) { // All categories were selected, so don't continue if ($categoryId == 0) { $categorySearch = false; break; } $categoryIds[] = (int) $categoryId; // If searching sub categories automatically, fetch & tack them on if (isset($searchTerms['searchsubs']) && $searchTerms['searchsubs'] == 'ON') { $categoryIds = array_merge($categoryIds, GetChildCats($categoryId)); } } $categoryIds = array_unique($categoryIds); if (!empty($categoryIds)) { $categorySearch = true; } } /* this below is condition is used when category is mentioned in search keyword */ if (isset($searchTerms['srch_category'])) { $categorySearch = true; $categoryIds = $searchTerms['srch_category']; } if ($categorySearch == true) { $qualifier_category = 1; $qualifier_flag = 1; /*$fromTable = 'isc_categoryassociations a, isc_products p '; $queryWhere[] = 'a.productid=p.productid AND a.categoryid IN ('.implode(',', $categoryIds).')'; $fromTable1 = 'isc_categoryassociations a, isc_import_variations v '; $queryWhere1[] = 'a.productid=v.productid AND a.categoryid IN ('.implode(',', $categoryIds).')';*/ if ($searchTerms['flag_srch_category'] == 1) { $fromTable = 'isc_products p USE INDEX (PRIMARY) '; } else { $fromTable = 'isc_products p '; } // $fromTable = 'isc_products p USE INDEX (categoryid) '; $queryWhere[] = 'c.categoryid IN (' . implode(',', $categoryIds) . ')'; //$fromTable1 = 'isc_import_variations v '; $queryWhere1[] = 'c.categoryid IN (' . implode(',', $categoryIds) . ')'; } else { $fromTable = 'isc_products p'; //$fromTable1 = 'isc_import_variations v'; $queryWhere[] = " c.categoryid is not null "; } $GLOBALS['qualifiercategory'] = $qualifier_category; /* this code is commented as we are no longer checking in search table as the records are split in product and variations table. if (isset($searchTerms['search_query']) && $searchTerms['search_query'] != "") { // Only need the product search table if we have a search query $joinQuery .= "INNER JOIN [|PREFIX|]product_search ps ON (p.productid=ps.productid) "; } else if ($sortField == "score") { // If we don't, we better make sure we're not sorting by score $sortField = "p.prodname"; $sortOrder = "ASC"; } */ /* Below condition has been added if any product detail page is seen directly , need to assign it as array */ if (!isset($searchTerms['dynfilters'])) { $searchTerms['dynfilters'] = array(); } $otherkeys = array_keys($searchTerms['dynfilters'], "others"); $others_factor = ''; /* if ( isset($searchTerms['partnumber']) || ( isset($searchTerms['flag_srch_category']) && $searchTerms['flag_srch_category'] == 1 ) || (isset($searchTerms['flag_srch_brand']) && $searchTerms['flag_srch_brand'] == 1 ) || isset($searchTerms['series']) || isset($searchTerms['subcategory']) ) { // listing page } else { foreach ($otherkeys as $otherkey) { //$others_factor .= " AND (".$otherkey." = '' OR ".$otherkey." IS NULL )"; $others_factor .= " AND (".$otherkey." = '' OR ".$otherkey." IS NULL )"; } } */ $partnumber_condition = ""; if (!isset($searchTerms['partnumber'])) { //$partnumber_condition = "and c.catvisible = 1 "; } $queryWhereTemp = $this->GetWhereBySearchItems($outer_condition, $havingquery); $queryWhere = array_merge($queryWhere, $queryWhereTemp); $where = ""; if (count($queryWhere) > 0) { $where = " and " . implode(' AND ', $queryWhere); } $qualifiers_where = ""; ##Added by Simha // for "others" values in qualifier filters //$otherkeys = array_keys($searchTerms['dynfilters'], "others"); $extrasearch = ''; foreach ($p_cols as $key => $value) { if (in_array($value, $otherkeys)) { $extrasearch .= ',MAX(' . $value . ') as ' . $value . ''; unset($p_cols[$key]); $p_cols = array_values($p_cols); } } foreach ($v_cols as $key => $value) { if (in_array($value, $otherkeys)) { $extrasearch .= ',MAX(' . $value . ') as ' . $value . ''; unset($v_cols[$key]); $v_cols = array_values($v_cols); } } ##Added by Simha Ends $v_cols_new = ''; $p_cols_new = ''; if (empty($p_cols)) { $p_cols_new = " '' as productoption "; } else { $p_cols_new = " '' as temp_1088 "; //just for a empty column,don't cause sql error } if (empty($v_cols)) { $v_cols_new = " '' as vehicleoption "; } else { $v_cols_new = " '' as temp_1089 "; //just for a empty column,don't cause sql error } /*if(empty($p_cols)) { $p_cols_new = " '' as productoption "; } else { //$p_cols = " CONCAT_WS('~',".implode(' , ' , $p_cols).") as productoption "; //$p_cols = implode(' , ' , $p_cols); for($k=0;$k<count($p_cols);$k++) { //$p_cols = implode(' , ' , $p_cols); $p_cols_new .= " group_concat(DISTINCT ".$p_cols[$k]." separator '~') as ".$p_cols[$k]." ,"; } } if(empty($v_cols)) { $v_cols_new = " '' as vehicleoption "; } else { //$v_cols = " CONCAT_WS('~',".implode(' , ' , $v_cols).") as vehicleoption "; //$v_cols = implode(' , ' , $v_cols); for($k=0;$k<count($v_cols);$k++) { //$p_cols = implode(' , ' , $p_cols); //2010-11-15 Ronnie modify,VQcabsize,VQbedsize not is Special /*if( $v_cols[$k] == 'VQbedsize' ) { $v_cols_new .= " group_concat( DISTINCT if( v.bedsize_generalname != '', v.bedsize_generalname, v.VQbedsize ) separator '~' ) as VQbedsize ,"; } else if( $v_cols[$k] == 'VQcabsize' ) { //$v_cols_new .= " group_concat( DISTINCT if( v.cabsize_generalname != '', v.cabsize_generalname, v.VQcabsize ) separator '~' ) as VQcabsize ,"; $v_cols_new .= " group_concat( DISTINCT v.VQcabsize separator '~' ) as VQcabsize ,"; } else {*/ /*$v_cols_new .= " group_concat(DISTINCT ".$v_cols[$k]." separator '~') as ".$v_cols[$k]." ,"; //} } } $v_cols_new = trim($v_cols_new, ','); $p_cols_new = trim($p_cols_new, ',');*/ //$GLOBALS['srch_where'] = $common_fields_product.",".$fields." , $p_cols_new , $v_cols_new , bs.seriesname, bs.displayname, p.brandseriesid , bs.seriesdescription , bs.seriesfooter , b.brandimagefile, bs.serieslogoimage "; $GLOBALS['srch_where'] = $common_fields_product . "," . $fields . " , {$p_cols_new} , {$v_cols_new} , bs.seriesname, bs.displayname, p.brandseriesid , bs.seriesdescription , bs.seriesfooter , b.brandimagefile, bs.serieslogoimage "; $GLOBALS['srch_where'] .= $extrasearch; ##Added by mike $v_cols_new2 = ''; $p_cols_new2 = ''; if (!empty($p_cols)) { for ($k = 0; $k < count($p_cols); $k++) { $p_cols_new2 .= " " . $p_cols[$k] . " as " . $p_cols[$k] . " ,"; } } if (!empty($v_cols)) { for ($k = 0; $k < count($v_cols); $k++) { $v_cols_new2 .= " " . $v_cols[$k] . " as " . $v_cols[$k] . " ,"; } } /* $v_cols_new2 = trim($v_cols_new2, ','); $p_cols_new2 = trim($p_cols_new2, ',');*/ $PVCols = array_merge($p_cols, $v_cols); $PVColumns = $p_cols_new2 . $v_cols_new2; $PVColumns = trim($PVColumns, ','); $PVQuery = ''; if (count($PVCols) > 0) { $PVQuery = " select p.productid," . $PVColumns . " FROM {$fromTable}\n\t\t\t" . $this->GetJoinCountQueryTables() . " WHERE 1=1 {$where} {$outer_condition} "; } $query = "select " . $GLOBALS['srch_where'] . " from\n\t\t{$fromTable} " . $this->GetJoinQueryTables() . " WHERE 1=1 {$where} {$outer_condition} "; $countQuery = "SELECT count(p.productid) " . $extrasearch . " FROM {$fromTable}\n\t\t" . $this->GetJoinCountQueryTables() . " WHERE 1=1 {$where} {$outer_condition} "; //wirror_yin20101102: put the join statement to $_GLOBALS $GLOBALS['join_query'] = $this->GetJoinQueryTables(); return array('query' => $query, 'countQuery' => $countQuery, 'orderby' => "", 'PVCols' => $PVCols, 'PVQuery' => $PVQuery); }