Пример #1
0
	public function HandlePage()
	{
		SetPGQVariablesManually();
		$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle($this->getPageTitle());
		$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate('sitemap');
		$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
	}
Пример #2
0
 public function _SetBrandData()
 {
     // Retrieve the query string variables. Can't use the $_GET array
     // because of SEO friendly links in the URL
     SetPGQVariablesManually();
     // Grab the page sort details
     $GLOBALS['URL'] = implode("/", $GLOBALS['PathInfo']);
     $this->SetSort();
     if (isset($_REQUEST['brand'])) {
         $brand = $_REQUEST['brand'];
     } else {
         if (isset($GLOBALS['PathInfo'][1])) {
             $brand = preg_replace('#\\.html\\??.*$#i', "", $GLOBALS['PathInfo'][1]);
         } else {
             $brand = '';
         }
     }
     $brand = MakeURLNormal($brand);
     // Get the link to the "all brands" page
     $GLOBALS['AllBrandsLink'] = BrandLink();
     // Get the Id of the brand
     $query = sprintf("select * from [|PREFIX|]brands where brandname='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($brand));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         // Store the brand name
         $this->SetBrand($brand);
         $this->SetBrandName($row['brandname']);
         // Store the brand Id
         $this->SetId($row['brandid']);
         $this->SetBrandPageTitle($row['brandpagetitle']);
         // Store brand meta details
         $this->SetMetaKeywords($row['brandmetakeywords']);
         $this->SetMetaDesc($row['brandmetadesc']);
     }
     $this->SetNumProducts();
     $this->SetPage();
     $this->SetStart();
     $this->SetNumPages();
     // Load the products for the brand
     $this->LoadProductsForBrand();
 }
Пример #3
0
 public function SetCategoryData()
 {
     // Retrieve the query string variables. Can't use the $_GET array
     // because of SEO friendly links in the URL
     SetPGQVariablesManually();
     // Grab the page sort details
     if (isset($_REQUEST['category'])) {
         $GLOBALS['CategoryPath'] = isc_html_escape($_REQUEST['category']);
         $path = explode("/", $_REQUEST['category']);
     } else {
         $GLOBALS['URL'] = implode("/", $GLOBALS['PathInfo']);
         $path = $GLOBALS['PathInfo'];
         array_shift($path);
     }
     $this->SetSort();
     $this->SetCatPath($path);
     $arrCats = $this->_catpath;
     for ($i = 0; $i < count($arrCats); $i++) {
         $arrCats[$i] = MakeURLNormal($arrCats[$i]);
     }
     if (!isset($arrCats[0])) {
         $arrCats[0] = '';
     }
     // The first category *MUST* have a parent ID of 0 or it's invalid
     $query = "\n\t\t\t\tSELECT *\n\t\t\t\tFROM [|PREFIX|]categories\n\t\t\t\tWHERE LOWER(catname) ='" . $GLOBALS['ISC_CLASS_DB']->Quote($arrCats[0]) . "' AND catparentid=0\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $this->SetTrail(array($row['categoryid'], $row['catname']));
         $this->SetId($row['categoryid']);
         $this->SetName($row['catname']);
         $this->SetDesc($row['catdesc']);
         $this->SetLayoutFile($row['catlayoutfile']);
         $this->SetCatPageTitle($row['catpagetitle']);
         $this->SetMetaKeywords($row['catmetakeywords']);
         $this->SetMetaDesc($row['catmetadesc']);
         // The root category is valid, try and loop through each category to find the ID of the last category in the set
         if (count($arrCats) > 1) {
             $parentCat = $row['categoryid'];
             for ($i = 1; $i < count($arrCats); $i++) {
                 if (!$arrCats[$i]) {
                     continue;
                 }
                 $query = "\n\t\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\t\tFROM [|PREFIX|]categories\n\t\t\t\t\t\t\tWHERE LOWER(catname) ='" . $GLOBALS['ISC_CLASS_DB']->Quote($arrCats[$i]) . "' AND catparentid='" . (int) $parentCat . "'\n\t\t\t\t\t\t";
                 $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                 if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     $parentCat = $row['categoryid'];
                     $this->Data = $row;
                     $this->SetTrail(array($row['categoryid'], $row['catname']));
                     $this->SetId($row['categoryid']);
                     $this->SetName($row['catname']);
                     $this->SetDesc($row['catdesc']);
                     $this->SetLayoutFile($row['catlayoutfile']);
                     $this->SetCatPageTitle($row['catpagetitle']);
                     $this->SetMetaKeywords($row['catmetakeywords']);
                     $this->SetMetaDesc($row['catmetadesc']);
                 } else {
                     continue;
                 }
             }
             $this->SetId($parentCat);
         } else {
             $this->Data = $row;
             $this->SetId($row['categoryid']);
             $this->SetName($row['catname']);
             $this->SetDesc($row['catdesc']);
             $this->SetCatPageTitle($row['catpagetitle']);
             $this->SetMetaKeywords($row['catmetakeywords']);
             $this->SetMetaDesc($row['catmetadesc']);
         }
     } else {
         $this->Data = $row;
         $this->SetId(0);
         $this->SetName("");
         $this->SetDesc("");
     }
     if (!$this->_catid) {
         $GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404');
         $GLOBALS['ISC_CLASS_404']->HandlePage();
         exit;
     }
     // Do we have permission to access this category?
     if (!CustomerGroupHasAccessToCategory($this->_catid)) {
         $noPermissionsPage = GetClass('ISC_403');
         $noPermissionsPage->HandlePage();
         exit;
     }
     $GLOBALS['CatTrail'] = $this->GetTrail();
     // Find the number of products in the category
     $this->loadCats = $this->GetId();
     // This product should show products from this category, but if there are none
     // show them from any child categories too
     if (GetConfig('CategoryListingMode') == 'emptychildren') {
         // Load up how many products there are in the current category, if none, load from children too
         $this->SetNumProducts();
         if ($this->_catnumproducts == 0) {
             $this->loadCats = trim(implode(',', $this->GetChildCategories()), ',');
             $this->loadCats = rtrim($this->GetId() . "," . $this->loadCats, ',');
         }
     } else {
         if (GetConfig('CategoryListingMode') == 'children') {
             $cats = $this->GetChildCategories();
             $cats[] = $this->GetId();
             $this->loadCats = trim(implode(',', array_unique($cats)), ',');
         }
     }
     $this->SetNumProducts();
     // Setup paging details
     $this->SetPage();
     $this->SetStart();
     $this->SetNumPages();
     // Load the products for the categories page
     $this->LoadProductsForPage();
 }
Пример #4
0
		public function SetCategoryData()
		{
			// Retrieve the query string variables. Can't use the $_GET array
			// because of SEO friendly links in the URL
			SetPGQVariablesManually();

			// Grab the page sort details
			if (isset($_REQUEST['category'])) {
				$GLOBALS['CategoryPath'] = isc_html_escape($_REQUEST['category']);
				$path = explode("/", $_REQUEST['category']);
			}
			else {
				$GLOBALS['URL'] = implode("/", $GLOBALS['PathInfo']);
				$path = $GLOBALS['PathInfo'];
				array_shift($path);
			}

			$this->SetSort();

			$this->SetCatPath($path);

			$arrCats = $this->_catpath;

			for ($i = 0; $i < count($arrCats); $i++) {
				$arrCats[$i] = MakeURLNormal($arrCats[$i]);
			}

			if (!isset($arrCats[0])) {
				$arrCats[0] = '';
			}

			// The first category *MUST* have a parent ID of 0 or it's invalid
			$parentCat = 0;

			// Because of the way SEO friendly links work at the moment, we need to loop through
			// the category path to check each level is valid. Ideally we'd store the built category
			// URL in the database and check based on that.
			for($i = 0; $i < count($arrCats); ++$i) {
				if(empty($arrCats[$i])) {
					continue;
				}

				$query = "
					SELECT
						*
					FROM
						[|PREFIX|]categories
					WHERE
						catname = '".$GLOBALS['ISC_CLASS_DB']->quote($arrCats[$i])."' AND
						catparentid = '".(int)$parentCat."' AND
						catvisible = 1
				";
				$result = $GLOBALS['ISC_CLASS_DB']->query($query);
				$category = $GLOBALS['ISC_CLASS_DB']->fetch($result);

				// Supplied category could not be found. They've followed an incorrect link so show the 404 page.
				if(!$category) {
					$GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404');
					$GLOBALS['ISC_CLASS_404']->HandlePage();
					exit;
				}

				// Add this category to the breadcrumb/trail
				$this->SetTrail(array($category['categoryid'], $category['catname']));
				$parentCat = $category['categoryid'];
			}

			if (!empty($category)) {
				// $category contains the details of the actual category we're viewing
				$this->Data = $category;
				$this->SetId($category['categoryid']);
				$this->SetName($category['catname']);
				$this->SetDesc($category['catdesc']);
				$this->SetLayoutFile($category['catlayoutfile']);
				$this->SetCatPageTitle($category['catpagetitle']);
				$this->SetMetaKeywords($category['catmetakeywords']);
				$this->SetMetaDesc($category['catmetadesc']);
				$this->SetSearchKeywords($category['catsearchkeywords']);
				$this->SetEnableOptimizer($category['cat_enable_optimizer']);
			} else {
				// Reached /categories/ directly with no additional path.
				// This is the root category
			}

			// Do we have permission to access this category?
			if(!CustomerGroupHasAccessToCategory($this->_catid)) {
				$noPermissionsPage = GetClass('ISC_403');
				$noPermissionsPage->HandlePage();
				exit;
			}

			$GLOBALS['CatTrail'] = $this->GetTrail();

			// Find the number of products in the category
			$this->loadCats = $this->GetId();

			// This product should show products from this category, but if there are none
			// show them from any child categories too
			if(GetConfig('CategoryListingMode') == 'emptychildren') {
				// Load up how many products there are in the current category, if none, load from children too
				$this->SetNumProducts();
				if($this->_catnumproducts == 0) {
					$cats = $this->GetChildCategories();

					// Add in the current category too- which helps out shop by price etc
					$cats[] = $this->getId();

					$group = GetClass('ISC_CUSTOMER')->GetCustomerGroup();
					if(is_array($group) && $group['categoryaccesstype'] == 'specific') {
						$cats = array_intersect($cats, $group['accesscategories']);
					}

					$this->loadCats = trim(implode(',', array_unique($cats)), ',');
				}
			}

			// Otherwise, this category shows products from itself + children
			else if(GetConfig('CategoryListingMode') == 'children') {
				$cats = $this->GetChildCategories();
				$cats[] = $this->GetId();

				$group = GetClass('ISC_CUSTOMER')->GetCustomerGroup();
				if(is_array($group) && $group['categoryaccesstype'] == 'specific') {
					$cats = array_intersect($cats, $group['accesscategories']);
				}

				$this->loadCats = trim(implode(',', array_unique($cats)), ',');
			}

			$this->SetNumProducts();

			// Setup paging details
			$this->SetPage();
			$this->SetStart();
			$this->SetNumPages();

			// Load the products for the categories page
			$this->LoadProductsForPage();
		}
Пример #5
0
 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;
     }
 }
Пример #6
0
 private function _SetPriceData()
 {
     $pos = 0;
     $min = null;
     $max = null;
     $catid = null;
     $catpath = "";
     // Retrieve the query string variables. Can't use the $_GET array
     // because of SEO friendly links in the URL
     SetPGQVariablesManually();
     // Grab the page sort details
     $GLOBALS['URL'] = implode("/", $GLOBALS['PathInfo']);
     $this->SetSort();
     if (isset($_REQUEST['low']) && isset($_REQUEST['high']) && isset($_REQUEST['category']) && isset($_REQUEST['path'])) {
         $min = (int) $_REQUEST['low'];
         $max = (int) $_REQUEST['high'];
         $catid = (int) $_REQUEST['category'];
         $catpath = "/" . $_REQUEST['path'];
     } else {
         $count = 1;
         // Get the min price, max price and category id
         foreach ($GLOBALS['PathInfo'] as $piece) {
             if (isc_strtolower($piece) == "price") {
                 break;
             }
             $count++;
         }
         for ($i = $count; $i < count($GLOBALS['PathInfo']); $i++) {
             if ($pos == 0) {
                 $min = (int) $GLOBALS['PathInfo'][$i];
             } else {
                 if ($pos == 1) {
                     $max = (int) $GLOBALS['PathInfo'][$i];
                 } else {
                     if ($pos == 2) {
                         $catid = (int) $GLOBALS['PathInfo'][$i];
                     } else {
                         if ($pos > 2) {
                             $catpath .= "/" . $GLOBALS['PathInfo'][$i];
                         }
                     }
                 }
             }
             $pos++;
         }
         $catpath = preg_replace('#\\.html$#', "", $catpath);
     }
     // Do we have bad data? If so, bail out!
     if (!(is_numeric($min) && is_numeric($max) && is_numeric($catid))) {
         ob_end_clean();
         header("Location:" . $GLOBALS['ShopPath']);
         die;
     }
     $this->SetMinPrice((int) $min);
     $this->SetMaxPrice((int) $max);
     $this->SetCatId($catid);
     $catpath = trim($catpath, "/");
     $this->SetCatPath($catpath);
     // Get the categories name
     $query = sprintf("select catname from [|PREFIX|]categories where categoryid='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($this->GetCatId()));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $this->_pricecategory = $row['catname'];
         $GLOBALS['CatName'] = $this->_pricecategory;
     } else {
         $GLOBALS['ISC_CLASS_404'] = GetClass('ISC_404');
         $GLOBALS['ISC_CLASS_404']->HandlePage();
         exit;
     }
     // Find the number of products in the category
     $this->loadCats = $this->GetCatId();
     // This product should show products from this category, but if there are none
     // show them from any child categories too
     if (GetConfig('CategoryListingMode') == 'emptychildren') {
         // Load up how many products there are in the current category, if none, load from children too
         $this->SetNumProducts();
         if ($this->GetNumProducts() == 0) {
             $this->loadCats = trim(implode(',', $this->GetChildCategories()), ',');
         }
     } else {
         if (GetConfig('CategoryListingMode') == 'children') {
             $cats = $this->GetChildCategories();
             $cats[] = $this->GetCatId();
             $this->loadCats = trim(implode(',', array_unique($cats)), ',');
         }
     }
     $this->SetNumProducts();
     $this->SetPage();
     $this->SetStart();
     $this->SetNumPages();
     // Setup the trail
     $this->SetTrails();
     // Load the products for this price range
     if ($this->GetNumProducts()) {
         $this->LoadProductsForPrice();
     }
 }
Пример #7
0
		public function _SetProductData($productid=0)
		{

			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'];
				}
				else if(isset($GLOBALS['PathInfo'][1])) {
					$product = preg_replace('#\.html$#i', '', $GLOBALS['PathInfo'][1]);
				}
				else {
					$product = '';
				}

				$product = $GLOBALS['ISC_CLASS_DB']->Quote(MakeURLNormal($product));
				$productSQL = sprintf("p.prodname='%s'", $product);
			}
			else {
				$productSQL = sprintf("p.productid='%s'", (int)$productid);
			}

			$query = "
				SELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, pi.*, ".GetProdCustomerGroupPriceSQL().",
				(SELECT COUNT(fieldid) FROM [|PREFIX|]product_customfields WHERE fieldprodid=p.productid) AS numcustomfields,
				(SELECT COUNT(reviewid) FROM [|PREFIX|]reviews WHERE revstatus='1' AND revproductid=p.productid AND revstatus='1') AS numreviews,
				(SELECT brandname FROM [|PREFIX|]brands WHERE brandid=p.prodbrandid) AS prodbrandname,
				(SELECT COUNT(imageid) FROM [|PREFIX|]product_images WHERE imageprodid=p.productid) AS numimages,
				(SELECT COUNT(discountid) FROM [|PREFIX|]product_discounts WHERE discountprodid=p.productid) AS numbulkdiscounts
				FROM [|PREFIX|]products p
				LEFT JOIN [|PREFIX|]product_images pi ON (pi.imageisthumb=1 AND p.productid=pi.imageprodid)
				WHERE ".$productSQL;

			if(!isset($_COOKIE['STORESUITE_CP_TOKEN'])) {
				// ISC-1073: don't check visibility if we are on control panel
				$query .= " AND p.prodvisible='1'";
			}

			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);

			if (!$row) {
				return;
			}

			$this->_product = $row;
			$this->_prodid = $row['productid'];
			$this->_prodname = $row['prodname'];
			$this->_prodsku = $row['prodcode'];
			$this->_prodthumb = $row['imagefile'];
			$this->_proddesc = $row['proddesc'];
			$this->_prodimages = $row['numimages'];
			$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 = (int)$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->_prodcondition = $row['prodcondition'];
			$this->_prodshowcondition = $row['prodshowcondition'];
			$this->_prodoptimizerenabled = $row['product_enable_optimizer'];
			$this->_prodvariationid = $row['prodvariationid'];
			$this->_prodminqty = $row['prodminqty'];
			$this->_prodmaxqty = $row['prodmaxqty'];
			$this->_upc = $row['upc'];
			$this->_disable_google_checkout = $row['disable_google_checkout'];

			$videoQuery = 'select * from `[|PREFIX|]product_videos` where video_product_id=' . (int)$this->_prodid . ' order by `video_sort_order` asc';
			$videoResource = $GLOBALS['ISC_CLASS_DB']->Query($videoQuery);

			$this->_prodvideos = array();

			while($videoRow = $GLOBALS['ISC_CLASS_DB']->Fetch($videoResource)) {
				$this->_prodvideos[] = $videoRow;
			}

			$this->_prodrelatedproducts = $row['prodrelatedproducts'];
			$this->setLayoutFile($row['prodlayoutfile']);

			$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();
			}

			$this->_prodpreorder = true;
			if ($row['prodpreorder'] == 0) {
				$this->_prodpreorder = false;
			}

			$this->_prodpreordermessage = $row['prodpreordermessage'];

			$this->_prodreleasedate = $row['prodreleasedate'];

			$this->_prodreleasedateremove = true;
			if ($row['prodreleasedateremove'] == 0) {
				$this->_prodreleasedateremove = false;
			}

			$this->_opengraph_type = $row['opengraph_type'];

			if ($row['opengraph_use_product_name']) {
				$this->_opengraph_title = $row['prodname'];
			}
			else {
				$this->_opengraph_title = $row['opengraph_title'];
			}

			if ($row['opengraph_use_meta_description']) {
				$this->_opengraph_description = $row['prodmetadesc'];
			}
			else {
				$this->_opengraph_description = $row['opengraph_description'];
			}

			if ($row['opengraph_use_image'] != '') {
				try {
					$productImage = new ISC_PRODUCT_IMAGE;
					$productImage->populateFromDatabaseRow($row);
					$this->_opengraph_image = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true);
				} catch (Exception $exception) {
					// nothing
				}
			}

			$GLOBALS['CurrentProductLink'] = ProdLink($this->_prodname);
		}
Пример #8
0
 public function SetComparisonData()
 {
     if ($GLOBALS['EnableSEOUrls']) {
         $path = '/' . implode('/', $GLOBALS['PathInfo']) . '/';
     } else {
         if (isset($_SERVER['REQUEST_URI'])) {
             $path = $_SERVER['REQUEST_URI'];
         } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
             $path = $_SERVER['HTTP_X_REWRITE_URL'];
         } else {
             $path = $_SERVER['QUERY_STRING'];
         }
         $path = preg_replace('#\\.php[\\?]?#si', '/', $path);
     }
     // Retrieve the query string variables. Can't use the $_GET array
     // because of SEO friendly links in the URL
     SetPGQVariablesManually();
     if (isset($_GET['sort'])) {
         $sort = $_GET['sort'];
         switch ($sort) {
             case "product_name":
                 $this->_comparesort = "p.prodname asc";
                 break;
             case "product_price":
                 $this->_comparesort = "p.prodcalculatedprice asc";
                 break;
             case "product_rating":
                 $this->_comparesort = "prodavgrating asc";
                 break;
             case "product_brand":
                 $this->_comparesort = "brand asc";
                 break;
         }
     }
     if (is_numeric(isc_strpos($path, '/compare/'))) {
         $iPos = isc_strpos($path, '/compare/') + isc_strlen('/compare/');
         $ids = isc_substr($path, $iPos, isc_strlen($path));
     } else {
         $ids = $path;
     }
     // With SEO urls off the url might have additional get vars (e.g. sorting) so make sure
     // we don't include those otherwise the last productid will fail the is_numeric check
     if (isc_strpos($ids, '&') !== false) {
         $ids = isc_substr($ids, 0, isc_strpos($ids, '&'));
     }
     $ids = rtrim($ids, '/');
     $ids_array = explode('?', $ids);
     $ids = $ids_array[0];
     $exploded_ids = explode('/', $ids);
     foreach ($exploded_ids as $k => $v) {
         if (!is_numeric($v) || $v < 0) {
             unset($exploded_ids[$k]);
         }
     }
     $exploded_ids = array_unique($exploded_ids);
     $this->_compareids = implode('/', $exploded_ids);
     $this->_compareproducts = $exploded_ids;
     // Are we comparing more products than allowed by the template?
     $this->CheckTemplateRestrictions();
     // Load the products to compare
     $this->LoadProductsToCompare();
 }