private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms = array()) { $this->_SetFeedDetails(); $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int) GetConfig('RSSCacheTime') * 60); $channel = array("title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath']); $feed->SetChannel($channel); // The magical Interspire Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function $searchterms = BuildProductSearchTerms($searchTerms); $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder); // Run the query $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int) GetConfig('RSSItemsLimit')); $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if (isc_strlen($product['proddesc']) > 300) { $product['proddesc'] = isc_substr($product['proddesc'], 0, 298) . ".."; } if ($product['imagefile']) { $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", ImageThumb($product['imagefile'], ProdLink($product['prodname'])), $product['proddesc']); } // Determine the price of this product $price = CalculateProductPrice($product); $price = GetLang('Price') . ": " . $price; if (GetConfig('ShowProductRating')) { $ratingImage = $GLOBALS['TPL_PATH'] . '/images/IcoRating' . (int) $product['prodavgrating'] . '.gif'; $ratingImage = '<img src="' . $ratingImage . '" alt="" />'; } else { $ratingImage = ''; } $product['proddesc'] .= '<p><strong>' . $price . '</strong> ' . $ratingImage . '</p>'; // Add the item to the feed $item = array("title" => $product['prodname'], "description" => $product['proddesc'], "link" => ProdLink($product['prodname']), "date" => $product['proddateadded']); $feed->AddItem($item); } // Send the feed to the browser $feed->OutputFeed(); }
function DoAjaxSearch() { if (isset($_GET['search_query']) && isc_strlen($_GET['search_query']) >= 3) { $searchterms = BuildProductSearchTerms($_REQUEST); // Build the search query using our terms & the fields we want $searchQueries = BuildProductSearchQuery($searchterms); $Search_Count = $GLOBALS['ISC_CLASS_DB']->FetchOne($searchQueries['countQuery']); // No results? if ($Search_Count == 0) { exit; } // Add the limit $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5); $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result)) { $product['imagefile'] = ''; $products[$product['productid']] = $product; } // Fetch product images $productids = implode(",", array_keys($products)); $query = sprintf("select imageprodid, imagefile from [|PREFIX|]product_images where imageprodid in (%s) and imageisthumb=2", $GLOBALS['ISC_CLASS_DB']->Quote($productids)); $Result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($productimage = $GLOBALS['ISC_CLASS_DB']->Fetch($Result)) { $products[$productimage['imageprodid']]['imagefile'] = $productimage['imagefile']; } $view_all = ''; if ($Search_Count > 5) { $view_all = sprintf(' view_all="%s"', $this->EscapeEntity(sprintf('<a href="%s/search.php?search_query=%s">%s »</a>', $GLOBALS['ShopPathNormal'], $_REQUEST['search_query'], GetLang('QuickSearchViewAll')))); } echo '<?xml version="1.0"?>' . "\n"; echo sprintf('<results type="%s" result_count="%s"%s>' . "\n", GetLang('QuickSearchProducts'), $Search_Count, $view_all); foreach ($products as $product) { if ($product['imagefile']) { $image = sprintf("%s/%s/%s", $GLOBALS['ShopPathNormal'], GetConfig('ImageDirectory'), $product['imagefile']); } else { $image = GetLang('QuickSearchNoImage'); } if (GetConfig('EnableProductReviews')) { $ratingimg = sprintf("%s/images/IcoRating%s.gif", $GLOBALS['TPL_PATH'], (int) $product['prodavgrating']); } else { $ratingimg = ''; } echo sprintf('<result title="%s" price="%s" url="%s" image="%s" ratingimg="%s" />' . "\n", $this->EscapeEntity($product['prodname']), $this->EscapeEntity(CalculateProductPrice_retail($product)), ProdLink($product['prodname']), $this->EscapeEntity($image), $this->EscapeEntity($ratingimg)); } echo "</results>\n"; } }
/** * Run the full text searches to find matching products */ function DoSearch($Start, &$Search_Result, &$Search_Count) { $category_ids = array(); if (isset($_REQUEST['pageid'])) { $pageid = (int) $_REQUEST['pageid']; $query = sprintf("select * from [|PREFIX|]abtesting_pages where pageid='%d' and pagestatus = 1", $GLOBALS['ISC_CLASS_DB']->Quote($pageid)); } else { if (isset($GLOBALS['PathInfo'][1])) { $page = preg_replace('#\\.html$#i', '', $GLOBALS['PathInfo'][1]); $page = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($page)); $query = sprintf("select * from [|PREFIX|]abtesting_pages where pagename='%s' and pagestatus = 1", $page); } } $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); if (!$row) { ob_end_clean(); header("Location: " . GetConfig('ShopPath') . '/index.php'); exit; } $temp_srch_qry = $_REQUEST['search_query']; if ($row['pagetype'] == 2) { $subcatg_qry = "select catname from [|PREFIX|]categories where categoryid = " . $row['pagecategoryid']; $subcatg_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatg_qry); $subcatg_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatg_res); $_REQUEST['search_query'] = $subcatg_arr['catname']; //$_REQUEST['search_query'] = $temp_cat_name; } else { if ($row['pagetype'] == 3) { $subcatg_qry = "select c.categoryid as catid , c.catname as childname , p.categoryid , p.catname \n\t\t\t\t\t\t\t\t\tfrom [|PREFIX|]categories c \n\t\t\t\t\t\t\t\t\tleft join [|PREFIX|]categories p on c.catparentid = p.categoryid\n\t\t\t\t\t\t\t\t\twhere c.categoryid = '" . $row['pagecategoryid'] . "'"; $subcatg_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatg_qry); $subcatg_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatg_res); if ($subcatg_arr['categoryid'] != "") { $_REQUEST['search_query'] = $subcatg_arr['catname']; $_REQUEST['subcategory'] = $subcatg_arr['childname']; } else { $_REQUEST['search_query'] = $subcatg_arr['childname']; $_REQUEST['subcategory'] = $subcatg_arr['childname']; } } } // Set the incoming search terms $this->_searchterms = BuildProductSearchTerms($_REQUEST); //$this->_searchterms['search_query'] = $temp_srch_qry; $params = $this->_searchterms; if ($row['pagetype'] == 2 && isset($params['subcategory']) && $params['subcategory'] != "") { $row['pagetype'] = 3; } $GLOBALS['CatgDescandBrandImage'] = $row['pageheaderdesc']; $GLOBALS['CatgBrandSeriesFooter'] = $row['pagefooterdesc']; $GLOBALS['CategoryTrackingCodeTop'] = isset($row['pagecontrolscript']) ? $row['pagecontrolscript'] : ''; $GLOBALS['CategoryTrackingCodeBottom'] = isset($row['pagetrackingscript']) ? $row['pagetrackingscript'] : ''; $this->_pagetitle = $row['pagetitle']; $GLOBALS['pagetype'] = $row['pagetype']; if ($row['pagetype'] == 1) { $GLOBALS['results_page_flag'] = 1; $Search_Result = $row['pagecontent']; $Search_Count = 1; return; } else { if ($row['pagetype'] == 2) { $GLOBALS['results_page_flag'] = 0; $custom_cond = ""; if (isset($params['brand'])) { $custom_cond .= " and cp.brandname = '" . $params['brand'] . "' "; } if ($row['pagecontent'] == 1) { if (isset($params['make']) || isset($params['model']) || isset($params['year'])) { $concat_cond = ""; if (isset($params['make'])) { $concat_cond .= " and ( v.prodmake = 'NON-SPEC VEHICLE' OR v.prodmake = '" . $params['make'] . "') "; } if (isset($params['model'])) { $concat_cond .= " and ( v.prodmodel = 'all' OR v.prodmodel = '" . $params['model'] . "') "; } if (isset($params['year'])) { $concat_cond .= " and ( v.prodstartyear = 'all' OR " . $params['year'] . " between v.prodstartyear and v.prodendyear) "; } $temp_query = " SELECT group_concat(distinct cp.categoryid) as catid , group_concat(distinct cp.subcategoryid) as subcatid FROM [|PREFIX|]abtesting_custom_products cp INNER JOIN [|PREFIX|]abtesting_pages cc on cc.pageid=cp.pageid WHERE cp.enabled=1 and cc.pageid = " . $pageid . " ORDER BY cp.displayorder ASC "; $temp_result = $GLOBALS['ISC_CLASS_DB']->Query($temp_query); $temp_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($temp_result); $ccatg_qry = " SELECT group_concat( distinct ca.categoryid) as catids from [|PREFIX|]categoryassociations ca inner join [|PREFIX|]import_variations v on v.productid = ca.productid where ca.categoryid in (" . $temp_arr['catid'] . "," . $temp_arr['subcatid'] . ") " . $concat_cond; $ccatg_result = $GLOBALS['ISC_CLASS_DB']->Query($ccatg_qry); $ccatg_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($ccatg_result); $cc_query = " SELECT cp.productids, cp.categoryid, cp.subcategoryid, cp.brandid, cp.seriesid, cp.description FROM [|PREFIX|]abtesting_custom_products cp INNER JOIN [|PREFIX|]abtesting_pages cc on cc.pageid=cp.pageid WHERE cp.enabled=1 and cc.pageid = " . $pageid . " " . $custom_cond; $ccatg_arr['catids'] = isset($ccatg_arr['catids']) && $ccatg_arr['catids'] != '' ? $ccatg_arr['catids'] : ''; $cc_query .= " and ( cp.categoryid in (" . $ccatg_arr['catids'] . ") OR cp.subcategoryid in (" . $ccatg_arr['catids'] . ") ) "; $cc_query .= " ORDER BY cp.displayorder ASC "; } else { $cc_query = " SELECT cp.productids, cp.categoryid, cp.subcategoryid, cp.brandid, cp.seriesid, cp.description FROM [|PREFIX|]abtesting_custom_products cp INNER JOIN [|PREFIX|]abtesting_pages cc on cc.pageid=cp.pageid WHERE cp.enabled=1 and cc.pageid = " . $pageid . " " . $custom_cond . " ORDER BY cp.displayorder ASC "; } $cc_result = $GLOBALS['ISC_CLASS_DB']->Query($cc_query); $total_count = $GLOBALS['ISC_CLASS_DB']->CountResult($cc_result); $Search_Count = $total_count; if ($total_count > 0) { $GLOBALS['pagecontent'] = $row['pagecontent']; $GLOBALS['CustomPage'] = ""; while ($ccrow = $GLOBALS['ISC_CLASS_DB']->Fetch($cc_result)) { $GLOBALS['CustomPage'] .= $ccrow['description']; } return; } //2010-11-30 Ronnie modify //return; } //2010-11-30 Ronnie add,no result show Dynamic content //echo "123".$total_count; if ($total_count == 0) { $row['pagecontent'] = 0; } //echo "456".$row['pagecontent']; if ($row['pagecontent'] == 0) { $getsubcatqry = "select group_concat(distinct c.categoryid) as catids from isc_categories c \n\t\t\t\t\t\twhere c.catparentid = " . $row['pagecategoryid']; $gersubcatres = $GLOBALS['ISC_CLASS_DB']->Query($getsubcatqry); $gersubcatarr = $GLOBALS['ISC_CLASS_DB']->Fetch($gersubcatres); $gersubcatarr['catids'] .= "," . $row['pagecategoryid']; $this->_searchterms['srch_category'] = $params['srch_category'] = explode(",", $gersubcatarr['catids']); /*$count_qry = "SELECT count(p.productid) as tot FROM isc_products p LEFT JOIN isc_import_variations AS v ON v.productid = p.productid LEFT JOIN isc_categoryassociations ca on ca.productid = p.productid LEFT JOIN isc_categories c on c.categoryid = ca.categoryid LEFT JOIN isc_brands b on prodbrandid = b.brandid LEFT JOIN isc_brand_series AS bs ON bs.seriesid = p.brandseriesid WHERE 1=1 AND c.categoryid IN (".$gersubcatarr['catids'].") AND p.prodvisible='1' ".$concat_cond." ".$dynamic_cond." group by c.categoryid"; $catquery = "select c.catname , c.categoryid , c.catuniversal , c.catimagealt , c.featurepoints , c.videourlwidthheight , c.thumbnailvideoimage , c.pricerange , c.warrantyinfo , 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 from isc_products p LEFT JOIN isc_import_variations AS v ON v.productid = p.productid LEFT JOIN isc_categoryassociations ca on ca.productid = p.productid LEFT JOIN isc_categories c on c.categoryid = ca.categoryid LEFT JOIN isc_brands b on prodbrandid = b.brandid LEFT JOIN isc_brand_series AS bs ON bs.seriesid = p.brandseriesid LEFT JOIN isc_product_images pi ON (p.productid=pi.imageprodid AND pi.imageisthumb=1) LEFT JOIN isc_product_finalprice fp ON p.productid = fp.productid WHERE 1=1 AND c.categoryid IN (".$gersubcatarr['catids'].") AND p.prodvisible='1' ".$concat_cond." ".$dynamic_cond." group by c.categoryid ORDER BY c.catdeptid ASC, c.catsort ASC, c.catname ASC LIMIT 0, 16"; $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_DB']->Query($catquery);*/ // Build the search query using our terms & the fields we want $searchQueries = BuildProductSearchQuery($this->_searchterms); $group = " group by c.categoryid "; $orderby = $searchQueries['orderby']; /* below template variables are added for subcategory page to add category specific tracking code*/ if (isset($params['srch_category'])) { $selected_catg = end($params['srch_category']); if ($selected_catg != '') { $script_query = "select catname , catpagetitle , catmetakeywords , catmetadesc , controlscript , trackingscript from [|PREFIX|]categories where categoryid = " . $selected_catg; $script_result = $GLOBALS['ISC_CLASS_DB']->Query($script_query); $script_array = $GLOBALS['ISC_CLASS_DB']->Fetch($script_result); /* the below lines assign meta discription, keywords and title for the categories*/ $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaKeywords($script_array['catmetakeywords']); $GLOBALS['ISC_CLASS_TEMPLATE']->SetMetaDescription($script_array['catmetadesc']); if ($script_array['catpagetitle'] != "") { $this->_pagetitle = $script_array['catpagetitle']; } else { $this->_pagetitle = ucwords($script_array['catname']); } } } } } else { if ($row['pagetype'] == 3) { $GLOBALS['results_page_flag'] = 2; $this->_searchterms['srch_category'][] = $params['srch_category'][] = $row['pagecategoryid']; // Build the search query using our terms & the fields we want $searchQueries = BuildProductSearchQuery($this->_searchterms); $group = " group by p.productid "; if (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) { if ($_REQUEST['orderby'] == "brandname") { $orderby = " order by brandname " . (isset($_REQUEST['sortby']) ? $_REQUEST['sortby'] : "asc") . " , seriesname "; } else { $orderby = " order by " . $_REQUEST['orderby'] . " "; } } else { $orderby = " order by p.prodprice "; } if (isset($_REQUEST['sortby']) && !empty($_REQUEST['sortby'])) { $orderby .= $_REQUEST['sortby']; } else { $orderby .= " asc"; } } } } /* the below three lines has been added to group by SKU as same sku was showing in multiple products */ $searchQueries['query'] .= $group . $GLOBALS['having_query'] . $orderby; $searchQueries['countQuery'] .= $group . $GLOBALS['having_query']; //$searchQueries['countQuery'] = "select count(*) from ( ".$searchQueries['countQuery']." ) p "; $count_res = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['countQuery']); $Search_Count = $GLOBALS['ISC_CLASS_DB']->CountResult($count_res); // Add the limit $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit($Start, GetConfig('CategoryProductsPerPage')); $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); $GLOBALS['DoSearchQuery'] = $searchQueries['query']; }
private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms=array()) { $this->_SetFeedDetails(); $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int)GetConfig('RSSCacheTime')*60); $channel = array( "title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath'], 'namespaces' => array( 'isc' => array( //'http://dtd.interspire.com/rss/isc-1.0.dtd', '', array( 'store_title' => getConfig('StoreName') ) ) ) ); $feed->SetChannel($channel); // The magical Unreal Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function $searchterms = BuildProductSearchTerms($searchTerms); $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder); // Run the query $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int)GetConfig('RSSItemsLimit')); $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if(isc_strlen($product['proddesc']) > 300) { $product['proddesc'] = isc_substr($product['proddesc'], 0, 298).".."; } $item = array( 'title' => $product['prodname'], 'date' => $product['proddateadded'], 'link' => prodLink($product['prodname']), 'namespaces' => array( 'isc' => array( 'description' => $product['proddesc'], 'productid' => $product['productid'], ) ) ); if($product['imagefile']) { $thumb = ImageThumb($product, ProdLink($product['prodname'])); $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", $thumb, $product['proddesc']); $image = new ISC_PRODUCT_IMAGE; $image->populateFromDatabaseRow($product); try { $item['namespaces']['isc']['thumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); } catch (Exception $exception) { } try { $item['namespaces']['isc']['image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); } catch (Exception $exception) { } unset ($image); } // Determine the price of this product $price = ''; if (GetConfig('ShowProductPrice') && !$product['prodhideprice']) { $calcPrice = $product['prodcalculatedprice']; $plainPrice = formatProductPrice($product, $calcPrice, array( 'strikeRetail' => false, 'displayInclusive' => getConfig('taxDefaultTaxDisplayCatalog') )); if($plainPrice) { $item['namespaces']['isc']['price'] = $plainPrice; $price = '<strong>'.getLang('Price').': '.$plainPrice.'</strong>'; } } if(GetConfig('ShowProductRating')) { $ratingImage = $GLOBALS['IMG_PATH'].'/IcoRating'.(int)$product['prodavgrating'].'.gif'; $item['namespaces']['isc']['rating'] = (int)$product['prodavgrating']; $item['namespaces']['isc']['rating_image'] = $ratingImage; $ratingImage = '<img src="'.$ratingImage.'" alt="" />'; } else { $ratingImage = ''; } $product['proddesc'] .= '<p>'.$price.' '.$ratingImage.'</p>'; $item['description'] = $product['proddesc']; $feed->AddItem($item); } // Send the feed to the browser $feed->OutputFeed(); }
public function _SetSearchData($altData=null) { if (!is_array($altData)) { $altData = $_REQUEST; } if (isset($altData['search_query_adv'])) { $altData['search_query'] = $altData['search_query_adv']; } if (isset($altData['search_query'])) { // Set the incoming search terms $this->_searchterms = BuildProductSearchTerms($altData); $GLOBALS['HideIfSearchQuery'] = 'display: none'; $GLOBALS['OriginalSearchQuery'] = isc_html_escape($altData['search_query']); $GLOBALS['FormattedSearchQuery'] = isc_html_escape($this->_searchterms['search_query']); $GLOBALS['SearchTitle'] = sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']); $GLOBALS['SearchTitleShort'] = getLang('SearchResults'); $this->_pagetitle = sprintf(GetLang('SearchSimpleTitle'), GetConfig('StoreName'), $GLOBALS['SearchTitle']); } else { // No search query set, show the advanced search form $GLOBALS['SearchTitle'] = sprintf(GetLang('SearchXStore'), $GLOBALS['StoreName']); $GLOBALS['SearchTitleShort'] = sprintf(GetLang('SearchXStore'), $GLOBALS['StoreName']); $GLOBALS['HideSearchBox'] = 'display: none'; $this->_pagetitle = sprintf(GetLang('SearchAdvancedTitle'), GetConfig('StoreName')); } }