Example #1
0
	/**
	 * Set the panel settings.
	 */
	public function SetPanelSettings()
	{
		if(GetConfig('HomeFeaturedProducts') <= 0) {
			$this->DontDisplay = true;
			return false;
		}

		$GLOBALS['SNIPPETS']['VendorFeaturedItems'] = '';

		if(!getProductReviewsEnabled()) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		$cVendor = GetClass('ISC_VENDORS');
		$vendor = $cVendor->GetVendor();

		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'],
			'p.prodvendorfeatured DESC, RAND()',
			getConfig('HomeFeaturedProducts')
		);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		$GLOBALS['AlternateClass'] = '';
		while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$this->setProductGlobals($row);
			$GLOBALS['SNIPPETS']['VendorFeaturedItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorFeaturedItemsItem");
		}

		$GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);

		if(!$GLOBALS['SNIPPETS']['VendorFeaturedItems']) {
			$this->DontDisplay = true;
		}
	}
Example #2
0
 /**
  * Set the panel settings.
  */
 public function SetPanelSettings()
 {
     $GLOBALS['SNIPPETS']['VendorList'] = '';
     $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]vendors\n\t\t\tORDER BY vendorname ASC\n\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($vendor = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['VendorId'] = $vendor['vendorid'];
         $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
         $GLOBALS['VendorLink'] = VendorLink($vendor);
         $GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);
         $GLOBALS['SNIPPETS']['VendorList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('VendorListItem');
     }
     if (!$GLOBALS['SNIPPETS']['VendorList']) {
         $this->DontDisplay = true;
         return false;
     }
 }
 public function SetPanelSettings()
 {
     if (isset($GLOBALS['ISC_CLASS_PRODUCT'])) {
         $vendor = GetClass('ISC_PRODUCT')->GetProductVendor();
     } else {
         $cVendor = GetClass('ISC_VENDORS');
         $vendor = $cVendor->GetVendor();
     }
     $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
     $GLOBALS['VendorHomeLink'] = VendorLink($vendor);
     $GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);
     // Does this vendor have any products?
     $query = "\n\t\t\tSELECT productid\n\t\t\tFROM [|PREFIX|]products\n\t\t\tWHERE prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t\tLIMIT 1\n\t\t";
     $hasProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
     if (!$hasProducts) {
         $GLOBALS['HideVendorProductsLink'] = 'display: none';
     }
     // Fetch out any pages belonging to this vendor to show in the menu
     $GLOBALS['PageLinks'] = '';
     // If the customer is not logged in then they can only see pages that aren't restricted to 'customers only'
     $customersOnly = '';
     $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
     if (!$GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId()) {
         $customersOnly = ' AND pagecustomersonly=0';
     }
     // Fetch any pages that this page is a parent of
     $query = "\n\t\t\tSELECT *\n\t\t\tFROM [|PREFIX|]pages\n\t\t\tWHERE pagestatus='1' AND pageparentid='0' AND pagevendorid='" . (int) $vendor['vendorid'] . "' " . $customersOnly . "\n\t\t\tORDER BY pagesort ASC, pagetitle ASC\n\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($page = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         $GLOBALS['PageName'] = isc_html_escape($page['pagetitle']);
         // Is it a normal page, external page or RSS feed?
         switch ($page['pagetype']) {
             case 0:
             case 2:
             case 3:
                 // Normal Page or RSS feed
                 $GLOBALS['PageLink'] = PageLink($page['pageid'], $page['pagetitle'], $vendor);
                 break;
             case 1:
                 // External Link
                 $GLOBALS['PageLink'] = $page['pagelink'];
                 break;
         }
         $GLOBALS['PageLinks'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('SidePageLink');
     }
 }
	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(!getProductReviewsEnabled()) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'].' AND p.productid!='.$GLOBALS['ISC_CLASS_PRODUCT']->getProductId(),
			'p.prodvendorfeatured DESC, RAND() DESC',
			10 // Select 1 more than will be shown to check if we need to show the "has more" link
		);
		$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'] = formatProductCatalogPrice($row);

			$GLOBALS['ProductThumb'] = ImageThumb($row, 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['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';
		}
	}
Example #5
0
 /**
  * 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");
     }
 }
 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';
     }
 }
Example #7
0
	/**
	 * 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.calculated_price ASC';
				$GLOBALS['SortPriceAsc'] = 'selected="selected"';
				break;
			case 'pricedesc';
				$sortField = 'p.calculated_price 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 = "
			SELECT COUNT(p.productid) AS numproducts
			FROM [|PREFIX|]products p
			".GetProdCustomerGroupPermissionsSQL()."
			WHERE p.prodvisible='1' AND p.prodvendorid='".(int)$vendor['vendorid']."'
		";
		$numProducts = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
		$numPages = ceil($numProducts / GetConfig('CategoryProductsPerPage'));

		// Now load the actual products for this vendor
		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'],
			$sortField.', prodname ASC',
			getConfig('CategoryProductsPerPage'),
			$start
		);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		$GLOBALS['SNIPPETS']['VendorProducts'] = '';

		if(!GetConfig('ShowProductRating')) {
			$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)) {
			$this->setProductGlobals($row);
			$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()
 {
     if (GetConfig('HomeFeaturedProducts') <= 0) {
         $this->DontDisplay = true;
         return false;
     }
     $GLOBALS['SNIPPETS']['VendorFeaturedItems'] = '';
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $cVendor = GetClass('ISC_VENDORS');
     $vendor = $cVendor->GetVendor();
     $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 imageisthumb=1)\n\t\t\tWHERE p.prodvisible='1' AND p.prodvendorid='" . (int) $vendor['vendorid'] . "'\n\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\tORDER BY p.prodvendorfeatured DESC, RAND()\n\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeFeaturedProducts'));
     $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
         $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']));
         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']['VendorFeaturedItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorFeaturedItemsItem");
     }
     $GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);
     if (!$GLOBALS['SNIPPETS']['VendorFeaturedItems']) {
         $this->DontDisplay = true;
     }
 }