示例#1
0
 function getInput()
 {
     $db =& JFactory::getDBO();
     if (!is_dir(JPATH_ADMINISTRATOR . '/components/com_virtuemart')) {
         return JText::_('Virtuemart is not installed');
     }
     // Load the virtuemart main parse code
     if (file_exists(JPATH_ADMINISTRATOR . '/components/com_virtuemart/virtuemart_parser.php')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/virtuemart_parser.php';
         $mosConfig_absolute_path = realpath(dirname(__FILE__) . '/../..');
     } else {
         require_once JPATH_SITE . '/components/com_virtuemart/virtuemart_parser.php';
     }
     if (!is_array($this->value)) {
         $this->value = array('' . $this->value . '' => '1');
     } else {
         foreach ($this->value as $_k => $tmpV) {
             $this->value[$tmpV] = 1;
         }
     }
     require_once CLASSPATH . 'ps_product_category.php';
     $ps_product_category = new ps_product_category();
     ob_start();
     $output = $ps_product_category->list_all('' . $this->name . '[]', '', $this->value, 10, true, true);
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
示例#2
0
 function getProductBySku($sku)
 {
     global $database, $logger;
     $logger->debug(get_class($this) . "::getProductBySku({$sku})");
     $prod = new Product();
     $ps_prod = new ps_product();
     $ps_cat = new ps_product_category();
     $query = "select product_id from #__vm_product where product_sku=" . $sku;
     $database->loadQuery($query);
     $id = $db->loadResult();
     $prod->setOid($id);
     $prod->setName($ps_prod->get_field('product_name'));
     $prod->setFlypage($ps_prod->get_flypage($id));
     $prod->setCategoryId($ps_cat->get_cid($id));
     return $prod;
 }
 function traverse_tree_down(&$mymenu_content, $category_id = '0', $level = '0')
 {
     static $ibg = -1;
     global $db, $module, $mosConfig_live_site;
     $level++;
     $query = "SELECT category_name as cname, category_id as cid, category_child_id as ccid " . "FROM #__{vm}_category as a, #__{vm}_category_xref as b " . "WHERE a.category_publish='Y' AND " . " b.category_parent_id='{$category_id}' AND a.category_id=b.category_child_id " . "ORDER BY category_parent_id, list_order, category_name ASC";
     $db->query($query);
     $categories = $db->record;
     if (!($categories == null)) {
         $i = 1;
         $numCategories = count($categories);
         foreach ($categories as $category) {
             $ibg++;
             $Treeid = $ibg == 0 ? 1 : $ibg;
             $itemid = isset($_REQUEST['Itemid']) ? '&Itemid=' . intval($_REQUEST['Itemid']) : "";
             $mymenu_content .= str_repeat("\t", $level - 1);
             if ($level > 1 && $i == 1) {
                 $mymenu_content .= ",";
             }
             $mymenu_content .= "['" . addslashes($category->cname);
             $mymenu_content .= ps_product_category::products_in_category($category->cid);
             $mymenu_content .= "','" . $_SERVER['PHP_SELF'] . '?option=com_virtuemart&page=product.product_category_form&category_id=' . $category->cid . "'\n ";
             $q = "SELECT #__{vm}_product.product_name,#__{vm}_product.product_id FROM #__{vm}_product, #__{vm}_product_category_xref ";
             $q .= "WHERE #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id ";
             $q .= "AND #__{vm}_product_category_xref.category_id='" . $category->cid . "' ";
             $q .= "ORDER BY #__{vm}_product.product_name";
             $db->query($q);
             $products = $db->record;
             $xx = 1;
             if (count($products) > 0) {
                 $mymenu_content .= ",\n";
             }
             foreach ($products as $product) {
                 // get name and link (just to save space in the code later on)
                 $mymenu_content .= str_repeat("\t", $level) . "['" . addslashes($product->product_name);
                 $url = $_SERVER['PHP_SELF'] . '?option=com_virtuemart&page=product.product_form&product_id=' . $product->product_id;
                 $mymenu_content .= "','" . $url . "']";
                 if ($xx++ < sizeof($products)) {
                     $mymenu_content .= ",\n";
                 } else {
                     $mymenu_content .= "\n";
                 }
             }
             /* recurse through the subcategories */
             $this->traverse_tree_down($mymenu_content, $category->ccid, $level);
             $mymenu_content .= str_repeat("\t", $level - 1);
             /* let's see if the loop has reached its end */
             if ($i == sizeof($categories) && $level == 1) {
                 $mymenu_content .= "]\n";
             } else {
                 $mymenu_content .= "],\n";
             }
             $i++;
         }
     } else {
     }
 }
示例#4
0
 function traverse_tree_down(&$mymenu_content, $category_id = '0', $level = '0')
 {
     static $ibg = -1;
     global $mosConfig_live_site, $sess;
     $db = new ps_DB();
     $level++;
     $query = "SELECT category_name, category_id, category_child_id " . "FROM #__{vm}_category as a, #__{vm}_category_xref as b " . "WHERE a.category_publish='Y' AND " . " b.category_parent_id='{$category_id}' AND a.category_id=b.category_child_id " . "ORDER BY category_parent_id, list_order, category_name ASC";
     $db->query($query);
     while ($db->next_record()) {
         $ibg++;
         $Treeid = $ibg == 0 ? 1 : $ibg;
         $itemid = '&Itemid=' . $sess->getShopItemid();
         $mymenu_content .= ",\n[null,'" . $db->f("category_name", false);
         $mymenu_content .= ps_product_category::products_in_category($db->f("category_id"));
         $mymenu_content .= "','" . sefRelToAbs('index.php?option=com_virtuemart&page=shop.browse&category_id=' . $db->f("category_id") . $itemid . "&TreeId={$Treeid}") . "','_self','" . $db->f("category_name", false) . "'\n ";
         /* recurse through the subcategories */
         $this->traverse_tree_down($mymenu_content, $db->f("category_child_id"), $level);
         /* let's see if the loop has reached its end */
         $mymenu_content .= "]";
     }
 }
*
* This file is included by the virtuemart module if the module parameter
* MenuType is set to treemenu
**/
global $root_label, $sess, $db, $mosConfig_live_site, $mm_action_url;
if (vmIsJoomla('1.5')) {
    $js_src = $mosConfig_live_site . '/modules/mod_virtuemart';
} else {
    $js_src = $mosConfig_live_site . '/modules';
}
$Itemid = vmRequest::getInt('Itemid');
if (@get_class($db) != 'ps_DB') {
    $db = new ps_DB();
}
require_once CLASSPATH . "ps_product_category.php";
$ps_product_category = new ps_product_category();
/*********************************************************
************* CATEGORY TREE ******************************
*/
/* dTree API, default value
 * change to fit your needs **/
$useSelection = 'true';
$useLines = 'true';
$useIcons = 'true';
$useStatusText = 'false';
$useCookies = 'false';
$closeSameLevel = 'false';
// if all folders should be open, we will ignore the closeSameLevel
$openAll = 'false';
if ($openAll == "true") {
    $closeSameLevel = "false";
示例#6
0
文件: Sotvm.php 项目: sergy444/joomla
		function getItems(&$params) {
				
			global $CURRENCY_DISPLAY, $sess, $mm_action_url, $VM_LANG;
			$db = new ps_DB;
			
			if($rows = $this->getProductSKU( $this->NumberOfProducts, $this->SortMethod, $this->vmcategories, $this->featuredProducts, $this->specific_product_ids, $this->source, $this->catfilter ))
			{
				$ps_product = new ps_product;
				$ps_product_category = new ps_product_category;
				$pro_skus = implode("','", $rows);	
				$limit = $this->NumberOfProducts;
				if($limit>0) {
					$limit = "LIMIT $limit";
				} else {
					$limit = "";
				}
				$q = "SELECT product_id, product_name, product_parent_id, product_thumb_image, product_desc, product_full_image FROM #__{vm}_product AS p WHERE product_sku in ('$pro_skus')";
				switch( $this->SortMethod ) {
					case 'random':
						$q .= "\n ORDER BY RAND() $limit";
						break;
					case 'newest':
						$q .= "\n ORDER BY p.cdate DESC $limit";
						break;
					case 'oldest':
						$q .= "\n ORDER BY p.cdate ASC $limit";
						break;
					default:
						$q .= "\n ORDER BY p.cdate DESC $limit";
						break;
				}
				$db->setQuery( $q );
				$items = $db->loadObjectList(); 
				//var_dump($items);die;
				foreach($items as &$item) {
					$product_id = $item->product_id;

					$cid = $ps_product_category->get_cid( $product_id );

					$product_name = $item->product_name;
					$item->title = $product_name;
					if ($item->product_parent_id) {
						$url = "?page=shop.product_details&category_id=$cid&flypage=".$ps_product->get_flypage($item->product_parent_id);
						$url .= "&product_id=" . $item->product_parent_id;
					} else {
						$url = "?page=shop.product_details&category_id=$cid&flypage=".$ps_product->get_flypage($item->product_id);
						$url .= "&product_id=" . $item->product_id;
					}
					$product_link = $sess->url($mm_action_url. "index.php" . $url);
					$item->link = $product_link;
					$product_thumb_image = $item->product_full_image;
					
					//$img = $this->image_url( $product_thumb_image, "alt=\"".$product_name."\"");
					$item->image = IMAGEPATH.'product/'.$product_thumb_image;
					$item->fulltext = $item->product_desc;
					$item->introtext = $item->product_desc;
																			
					$price_base = $this->get_price($ps_product,  $item->product_id);
					$price_ps = $ps_product->get_price($item->product_id, true);
					if (_SHOW_PRICES == '1' && $this->show_price) {
						// Show price, but without "including X% tax"
						$item->price = $CURRENCY_DISPLAY->getFullValue($price_base[1]);
						
					}
					
					if (USE_AS_CATALOGUE != 1 && $this->show_addtocart
							&& isset($price_ps) && $price_ps['product_price'] // Product must have a price to add it to cart
							/*&& !$ps_product->product_has_attributes($item->product_id, true)  // Parent Products and Products with attributes can't be added to cart this way*/
							) {
						$url = "?page=shop.cart&func=cartAdd&product_id=" .  $item->product_id;
						$addtocart_link = $sess->url($mm_action_url. "index.php" . $url);
						$item->addtocart_link = $addtocart_link;

					}
					
				}

				return $this->update($params, $items);
			} else return array();
	
			
	
		}		
* @copyright (C) 2004-2009 soeren - All Rights Reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* VirtueMart is Free Software.
* VirtueMart comes with absolute no warranty.
*
* www.virtuemart.net
*/
/* Load the virtuemart main parse code */
if (!isset($mosConfig_absolute_path)) {
    $mosConfig_absolute_path = $GLOBALS['mosConfig_absolute_path'] = JPATH_SITE;
}
global $mosConfig_absolute_path, $page;
require_once $mosConfig_absolute_path . '/components/com_virtuemart/virtuemart_parser.php';
require_once CLASSPATH . 'ps_product_category.php';
$ps_product_category = new ps_product_category();
global $my, $root_label, $mosConfig_allowUserRegistration, $jscook_type, $jscookMenu_style, $jscookTree_style, $VM_LANG, $sess, $mm_action_url;
$category_id = vmRequest::getInt('category_id');
$mod_dir = dirname(__FILE__);
/* Get module parameters */
$show_login_form = $params->get('show_login_form', 'no');
$show_categories = $params->get('show_categories', 'yes');
$show_listall = $params->get('show_listall', 'yes');
$show_adminlink = $params->get('show_adminlink', 'yes');
$show_accountlink = $params->get('show_accountlink', 'yes');
$useGreyBox_accountlink = $params->get('useGreyBox_accountlink', '0');
$show_minicart = $params->get('show_minicart', 'yes');
$useGreyBox_cartlink = $params->get('useGreyBox_cartlink', '0');
$show_productsearch = $params->get('show_productsearch', 'yes');
$show_product_parameter_search = $params->get('show_product_parameter_search', 'no');
$menutype = $params->get('menutype', "links");
示例#8
0
 /**
  * Returns HTML code for a snapshot of a product based on the product sku.
  * This was written to provide a quick way to display a product inside of modules
  *
  * @param string $product_sku The SKU identifying the product
  * @param boolean $show_price Show the product price?
  * @param boolean $show_addtocart Show the add-to-cart link?
  * @param boolean $show_product_name Show the product name?
  */
 function product_snapshot($product_sku, $show_price = true, $show_addtocart = true, $show_product_name = true)
 {
     global $sess, $mm_action_url;
     $db = new ps_DB();
     require_once CLASSPATH . 'ps_product_category.php';
     $ps_product_category = new ps_product_category();
     $q = "SELECT product_id, product_name, product_parent_id, product_thumb_image FROM #__{vm}_product WHERE product_sku='{$product_sku}'";
     $db->query($q);
     if ($db->next_record()) {
         $product_id = $db->f("product_id");
         $tpl = new $GLOBALS['VM_THEMECLASS']();
         $cid = $ps_product_category->get_cid($product_id);
         $tpl->set('product_id', $product_id);
         $tpl->set('product_name', $db->f("product_name"));
         $tpl->set('show_product_name', $show_product_name);
         if ($db->f("product_parent_id")) {
             $url = "?page=shop.product_details&category_id={$cid}&flypage=" . $this->get_flypage($db->f("product_parent_id"));
             $url .= "&product_id=" . $db->f("product_parent_id");
         } else {
             $url = "?page=shop.product_details&category_id={$cid}&flypage=" . $this->get_flypage($db->f("product_id"));
             $url .= "&product_id=" . $db->f("product_id");
         }
         $product_link = $sess->url($mm_action_url . "index.php" . $url);
         $tpl->set('product_link', $product_link);
         $tpl->set('product_thumb_image', $db->f("product_thumb_image"), "alt=\"" . $db->f("product_name") . "\"");
         if (_SHOW_PRICES == '1' && $show_price) {
             // Show price, but without "including X% tax"
             $price = $this->show_price($db->f("product_id"), true);
             $tpl->set('price', $price);
         }
         if (USE_AS_CATALOGUE != 1 && $show_addtocart && isset($GLOBALS['product_info'][$product_id]['price']['product_price_id']) && !$this->product_has_attributes($product_id, true)) {
             $url = "?page=shop.cart&func=cartAdd&product_id=" . $db->f("product_id");
             $addtocart_link = $sess->url($mm_action_url . "index.php" . $url);
             $tpl->set('addtocart_link', $addtocart_link);
         }
         return $tpl->fetch('common/productsnapshot.tpl.php');
     }
     return '';
 }
示例#9
0
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
// load important class files
require_once CLASSPATH . "ps_product.php";
$ps_product = new ps_product();
require_once CLASSPATH . "ps_product_category.php";
$ps_product_category = new ps_product_category();
require_once CLASSPATH . "ps_product_files.php";
require_once CLASSPATH . "ps_reviews.php";
require_once CLASSPATH . "imageTools.class.php";
require_once CLASSPATH . "PEAR/Table.php";
require_once CLASSPATH . 'ps_product_attribute.php';
$ps_product_attribute = new ps_product_attribute();
$Itemid = $sess->getShopItemid();
$keyword1 = $vmInputFilter->safeSQL(urldecode(vmGet($_REQUEST, 'keyword1', null)));
$keyword2 = $vmInputFilter->safeSQL(urldecode(vmGet($_REQUEST, 'keyword2', null)));
$search_op = $vmInputFilter->safeSQL(vmGet($_REQUEST, 'search_op', null));
$search_limiter = $vmInputFilter->safeSQL(vmGet($_REQUEST, 'search_limiter', null));
if (empty($category_id)) {
    $category_id = $search_category;
}
$default['category_flypage'] = FLYPAGE;
示例#10
0
* @version $Id: shop.index.php 2409 2010-05-20 20:05:30Z soeren $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2007 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
require_once CLASSPATH . 'ps_product.php';
require_once CLASSPATH . 'ps_product_category.php';
$ps_product_category = new ps_product_category();
$ps_product = new ps_product();
// Show only top level categories and categories that are
// being published
$tpl = new $GLOBALS['VM_THEMECLASS']();
$category_childs = $ps_product_category->get_child_list(0);
$tpl->set('categories', $category_childs);
//echo $vendor_store_desc;
$categories = $tpl->fetch('common/categoryChildlist.tpl.php');
$tpl->set('vendor_store_desc', $vendor_store_desc);
$tpl->set('categories', $categories);
$tpl->set('ps_product', $ps_product);
$tpl->set('recent_products', $ps_product->recentProducts(null, $tpl->get_cfg('showRecent', 5)));
if (file_exists(CLASSPATH . 'payment/ps_paypal_api.php')) {
    require_once CLASSPATH . 'payment/ps_paypal_api.php';
    if (ps_paypal_api::getPaymentMethodId() && ps_paypal_api::isActive()) {
示例#11
0
 /**
  * Shows the Number of Products in category $category_id
  *
  * @param int $category_id
  * @return string The number in brackets
  */
 function products_in_category($category_id)
 {
     if (PSHOP_SHOW_PRODUCTS_IN_CATEGORY == '1' || vmIsAdminMode()) {
         $num = ps_product_category::product_count($category_id);
         if (empty($num) && ps_product_category::has_childs($category_id)) {
             $db = new ps_DB();
             $q = "SELECT category_child_id FROM #__{vm}_category_xref ";
             $q .= "WHERE category_parent_id='{$category_id}' ";
             $db->query($q);
             while ($db->next_record()) {
                 $num += ps_product_category::product_count($db->f("category_child_id"));
             }
         }
         return " ({$num}) ";
     } else {
         return "";
     }
 }
示例#12
0
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName(__FILE__);
require_once CLASSPATH . 'ps_product_files.php';
require_once CLASSPATH . 'imageTools.class.php';
require_once CLASSPATH . 'ps_product.php';
$ps_product = $GLOBALS['ps_product'] = new ps_product();
require_once CLASSPATH . 'ps_product_category.php';
$ps_product_category = new ps_product_category();
require_once CLASSPATH . 'ps_product_attribute.php';
$ps_product_attribute = new ps_product_attribute();
require_once CLASSPATH . 'ps_product_type.php';
$ps_product_type = new ps_product_type();
require_once CLASSPATH . 'ps_reviews.php';
$product_id = intval(vmGet($_REQUEST, "product_id", null));
$product_sku = $db->getEscaped(vmGet($_REQUEST, "sku", ''));
$category_id = vmGet($_REQUEST, "category_id", null);
$pop = (int) vmGet($_REQUEST, "pop", 0);
$manufacturer_id = vmGet($_REQUEST, "manufacturer_id", null);
$Itemid = $sess->getShopItemid();
$db_product = new ps_DB();
// Check for non-numeric product id
if (!empty($product_id)) {
    if (!is_numeric($product_id)) {
示例#13
0
    			<?php 
    $number_of_categories = ps_product_category::count_categories();
    if ($number_of_categories > 200) {
        ?>
					<td style="vertical-align:top;">
						<?php 
        echo $VM_LANG->_('PHPSHOP_CATEGORIES');
        ?>
:<br/>
						<input type="text" size="40" name="catsearch" id="categorySearch" value="" />
					</td>
					<td>
						<input style="vertical-align: top;" type="button" name="remove_category" onclick="removeSelectedOptions(relatedCatSelection, 'category_ids' )" value="&nbsp; &lt; &nbsp;" />
						<?php 
        foreach (array_keys($my_categories) as $cat_id) {
            $categoriesArr[$cat_id] = ps_product_category::get_name_by_catid($cat_id);
        }
        echo ps_html::selectList('relCats', '', $categoriesArr, 10, 'multiple="multiple"', 'id="relatedCatSelection" ondblclick="removeSelectedOptions(relatedCatSelection, \'category_ids\');"');
        ?>
						<input type="hidden" name="category_ids" value="<?php 
        echo implode('|', array_keys($my_categories));
        ?>
" />
					</td>	
					<?php 
    } else {
        ?>
		    
		      		<td width="29%" valign="top"><div style="text-align:right;font-weight:bold;">
		       			<?php 
        echo $VM_LANG->_('PHPSHOP_CATEGORIES');
 if (!isset($depth_list[$n])) {
     $depth_list[$n] = 0;
 }
 $catname = shopMakeHtmlSafe($categories[$row_list[$n]]["category_name"]);
 $listObj->newRow();
 // The row number
 $listObj->addCell($pageNav->rowNumber($ibg));
 // The Checkbox
 $listObj->addCell(vmCommonHTML::idBox($ibg, $categories[$row_list[$n]]["category_child_id"], false, "category_id"));
 // Which category depth level we are in?
 $repeat = $depth_list[$n] + 1;
 $tmp_cell = str_repeat("&nbsp;&nbsp;&nbsp;", $repeat) . "&#095&#095;|" . $repeat . "|&nbsp;" . "<a href=\"" . $_SERVER['PHP_SELF'] . "?option=com_virtuemart&page=product.product_category_form&category_id=" . $categories[$row_list[$n]]["category_child_id"] . "&category_parent_id=" . $categories[$row_list[$n]]["category_parent_id"] . "\">" . $catname . "</a>";
 $listObj->addCell($tmp_cell);
 $desc = strlen($categories[$row_list[$n]]["category_description"]) > 255 ? mm_ToolTip($categories[$row_list[$n]]["category_description"], $VM_LANG->_('PHPSHOP_CATEGORY_FORM_DESCRIPTION')) : $categories[$row_list[$n]]["category_description"];
 $listObj->addCell("&nbsp;&nbsp;" . $desc);
 $listObj->addCell(ps_product_category::product_count($categories[$row_list[$n]]["category_child_id"]) . "&nbsp;<a href=\"" . $_SERVER['PHP_SELF'] . "?page=product.product_list&category_id=" . $categories[$row_list[$n]]["category_child_id"] . "&option=com_virtuemart" . "\">[ " . $VM_LANG->_('PHPSHOP_SHOW') . " ]</a>");
 // Publish / Unpublish
 $tmp_cell = "<a href=\"" . $sess->url($_SERVER['PHP_SELF'] . "?page=product.product_category_list&category_id=" . $categories[$row_list[$n]]["category_child_id"] . "&func=changePublishState");
 if ($categories[$row_list[$n]]["category_publish"] == 'N') {
     $tmp_cell .= "&task=publish\">";
 } else {
     $tmp_cell .= "&task=unpublish\">";
 }
 $tmp_cell .= vmCommonHTML::getYesNoIcon($categories[$row_list[$n]]["category_publish"]);
 $tmp_cell .= "</a>";
 $listObj->addCell($tmp_cell);
 // Order Up and Down Icons
 if ($keyword == '') {
     // This must be a big cheat, because we're working on sorted arrays,
     // not on database information
     // Check for predecessors and brothers and sisters
示例#15
0
 /**
  * Returns HTML code for a snapshot of a product based on the product sku.
  * This was written to provide a quick way to display a product inside of modules
  *
  * @param string $product_sku The SKU identifying the product
  * @param boolean $show_price Show the product price?
  * @param boolean $show_addtocart Show the add-to-cart link?
  * @param boolean $show_product_name Show the product name?
  */
 function product_snapshot($product_sku, $show_price = true, $show_addtocart = true, $show_product_name = true)
 {
     global $sess, $mm_action_url;
     $db = new ps_DB();
     require_once CLASSPATH . 'ps_product_category.php';
     $ps_product_category = new ps_product_category();
     $q = "SELECT product_id, product_name, product_parent_id, product_thumb_image, product_in_stock, product_nobuy, cdate, top,\n\t\t\n\t\tIFNULL((SELECT SUM(product_in_stock) FROM `jos_vm_product` AS cp WHERE cp.`product_parent_id` = jos_vm_product.product_id AND product_publish = \"Y\" AND product_in_stock > 0 ), 0) AS product_in_stock_child\n\n\t\tFROM #__{vm}_product WHERE product_sku='{$product_sku}'";
     $db->query($q);
     if ($db->next_record()) {
         $product_id = $db->f("product_id");
         $tpl = new $GLOBALS['VM_THEMECLASS']();
         $cid = $ps_product_category->get_cid($product_id);
         $novinka = "";
         if (time() - $db->f("cdate") < 30 * 86400) {
             // 14 Days *  (number of seconds in  24 hours)
             $novinka = 'Y';
         }
         $tpl->set('product_id', $product_id);
         $tpl->set('product_name', $db->f("product_name"));
         //$tpl->set( 'product_in_stock', $db->f("product_in_stock") );
         $tpl->set('product_in_stock', $db->f("product_in_stock_child") ? $db->f("product_in_stock_child") : $db->f("product_in_stock"));
         $tpl->set('product_nobuy', $db->f("product_nobuy"));
         $tpl->set('show_product_name', $show_product_name);
         $tpl->set('novinka', $novinka);
         $tpl->set('top', $db->f('top'));
         if ($db->f("product_parent_id")) {
             $url = "?page=shop.product_details&category_id={$cid}&flypage=" . $this->get_flypage($db->f("product_parent_id"));
             $url .= "&product_id=" . $db->f("product_parent_id");
         } else {
             $url = "?page=shop.product_details&category_id={$cid}&flypage=" . $this->get_flypage($db->f("product_id"));
             $url .= "&product_id=" . $db->f("product_id");
         }
         $product_link = $sess->url($mm_action_url . "index.php" . $url);
         $tpl->set('product_link', $product_link);
         $tpl->set('product_thumb_image', $db->f("product_thumb_image"), "alt=\"" . $db->f("product_name") . "\"");
         if (_SHOW_PRICES == '1' && $show_price) {
             // Show price, but without "including X% tax"
             $price = $this->show_price($db->f("product_id"), true);
             $tpl->set('price', $price);
         }
         if (USE_AS_CATALOGUE != 1 && $show_addtocart && isset($GLOBALS['product_info'][$product_id]['price']['product_price_id']) && !$this->product_has_attributes($product_id, true)) {
             $url = "?page=shop.cart&func=cartAdd&product_id=" . $db->f("product_id");
             $addtocart_link = $sess->url($mm_action_url . "index.php" . $url);
             $tpl->set('addtocart_link', $addtocart_link);
         }
         $has_attributes = ps_product::product_has_attributes($product_id, true);
         $tpl->set('has_attributes', $has_attributes);
         require_once CLASSPATH . 'ps_product_attribute.php';
         $ps_product_attribute = new ps_product_attribute();
         $tpl->set('ps_product_attribute', $ps_product_attribute);
         return $tpl->fetch('common/productsnapshot.tpl.php');
     }
     return '';
 }