本文整理汇总了PHP中shopFunctionsF::getLastVisitedCategoryId方法的典型用法代码示例。如果您正苦于以下问题:PHP shopFunctionsF::getLastVisitedCategoryId方法的具体用法?PHP shopFunctionsF::getLastVisitedCategoryId怎么用?PHP shopFunctionsF::getLastVisitedCategoryId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shopFunctionsF
的用法示例。
在下文中一共展示了shopFunctionsF::getLastVisitedCategoryId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareContinueLink
public function prepareContinueLink()
{
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryStr = '';
if ($virtuemart_category_id) {
$categoryStr = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$ItemidStr = '';
$Itemid = shopFunctionsF::getLastVisitedItemId();
if (!empty($Itemid)) {
$ItemidStr = '&Itemid=' . $Itemid;
}
$this->continue_link = JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryStr . $ItemidStr, FALSE);
//$this->continue_link_html = '<a class="continue_link" href="' . $continue_link . '" ><span>' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</span></a>';
$this->continue_link_html = '<a class="continue continue_link" href="' . $this->continue_link . '">' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart' . $ItemidStr, FALSE);
return;
}
示例2: prepareContinueLink
private function prepareContinueLink()
{
// Get a continue link
$menuid = JRequest::getVar('Itemid', '');
if (!empty($menuid)) {
$menuid = '&Itemid=' . $menuid;
}
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryLink = '';
if ($virtuemart_category_id) {
$categoryLink = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$continue_link = JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . $menuid, FALSE);
$continue_link_html = '<a class="continue_link" href="' . $continue_link . '" ><span>' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</span></a>';
$this->assignRef('continue_link_html', $continue_link_html);
$this->assignRef('continue_link', $continue_link);
$cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart' . $menuid, FALSE);
$this->assignRef('cart_link', $cart_link);
}
示例3: display
/**
* Collect all data to show on the template
*
* @author RolandD, Max Milbers
*/
function display($tpl = null)
{
//TODO get plugins running
// $dispatcher = JDispatcher::getInstance();
// $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
VmConfig::loadJLang('com_virtuemart', true);
$show_prices = VmConfig::get('show_prices', 1);
if ($show_prices == '1') {
if (!class_exists('calculationHelper')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
}
}
$this->assignRef('show_prices', $show_prices);
$document = JFactory::getDocument();
// add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
vmJsApi::jPrice();
$mainframe = JFactory::getApplication();
$pathway = $mainframe->getPathway();
$task = JRequest::getCmd('task');
if (!class_exists('VmImage')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
}
// Load the product
//$product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder
$product_model = VmModel::getModel('product');
$this->assignRef('product_model', $product_model);
$virtuemart_product_idArray = JRequest::getVar('virtuemart_product_id', 0);
if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) {
$virtuemart_product_id = (int) $virtuemart_product_idArray[0];
} else {
$virtuemart_product_id = (int) $virtuemart_product_idArray;
}
$quantityArray = JRequest::getVar('quantity', array());
//is sanitized then
JArrayHelper::toInteger($quantityArray);
$quantity = 1;
if (!empty($quantityArray[0])) {
$quantity = $quantityArray[0];
}
$product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity);
if (!class_exists('shopFunctionsF')) {
require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
if (empty($product->slug)) {
//Todo this should be redesigned to fit better for SEO
$mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'));
$categoryLink = '';
if (!$last_category_id) {
$last_category_id = JRequest::getInt('virtuemart_category_id', false);
}
if ($last_category_id) {
$categoryLink = '&virtuemart_category_id=' . $last_category_id;
}
if (VmConfig::get('handle_404', 1)) {
$mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE));
} else {
JError::raise(E_ERROR, '404', 'Not found');
}
return;
}
if (!empty($product->customfields)) {
foreach ($product->customfields as $k => $custom) {
if (!empty($custom->layout_pos)) {
$product->customfieldsSorted[$custom->layout_pos][] = $custom;
unset($product->customfields[$k]);
}
}
$product->customfieldsSorted['normal'] = $product->customfields;
unset($product->customfields);
}
$product->event = new stdClass();
$product->event->afterDisplayTitle = '';
$product->event->beforeDisplayContent = '';
$product->event->afterDisplayContent = '';
if (VmConfig::get('enable_content_plugin', 0)) {
shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc');
}
$product_model->addImages($product);
$this->assignRef('product', $product);
if (isset($product->min_order_level) && (int) $product->min_order_level > 0) {
$min_order_level = $product->min_order_level;
} else {
$min_order_level = 1;
}
$this->assignRef('min_order_level', $min_order_level);
if (isset($product->step_order_level) && (int) $product->step_order_level > 0) {
$step_order_level = $product->step_order_level;
} else {
$step_order_level = 1;
}
$this->assignRef('step_order_level', $step_order_level);
// Load the neighbours
if (VmConfig::get('product_navigation', 1)) {
$product->neighbours = $product_model->getNeighborProducts($product);
//.........这里部分代码省略.........
示例4: getContinueLink
function getContinueLink(&$ref)
{
include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
if (!empty($no_continue_link)) {
return "";
}
$cl = '';
$reff = @$_SERVER['HTTP_REFERER'];
if (!empty($reff)) {
$reff = OPCloader::slash($reff);
if (stripos($reff, 'script') === false) {
$cl = $reff;
}
}
if (empty($cl)) {
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryLink = '';
if ($virtuemart_category_id) {
$categoryLink = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$cl = JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink);
}
$session = JFactory::getSession();
if (!empty($cl)) {
$cl2 = $session->get('lastcontiuelink', '', 'opc');
if (!empty($cl2)) {
return $cl2;
}
$session->set('lastcontiuelink', $cl, 'opc');
return $cl;
}
$cl = $session->get('lastcontiuelink', '', 'opc');
return $cl;
}
示例5: addJS
/**
* Add the product to the cart, with JS
* @access public
*/
public function addJS()
{
$this->json = new stdClass();
$cart = VirtueMartCart::getCart(false);
if ($cart) {
$view = $this->getView('cart', 'json');
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryLink = '';
if ($virtuemart_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
}
$continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink);
$virtuemart_product_ids = vRequest::getInt('virtuemart_product_id');
$view = $this->getView('cart', 'json');
$errorMsg = 0;
$products = $cart->add($virtuemart_product_ids, $errorMsg);
$view->setLayout('padded');
$this->json->stat = '1';
if (!$products or count($products) == 0) {
$view->setLayout('perror');
$this->json->stat = '2';
}
$view->assignRef('products', $products);
$view->assignRef('errorMsg', $errorMsg);
ob_start();
$view->display();
$this->json->msg = ob_get_clean();
} else {
$this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart', FALSE) . '" >' . vmText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<p>' . vmText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
$this->json->stat = '0';
}
echo json_encode($this->json);
jExit();
}
示例6: getProductSingle
public function getProductSingle($virtuemart_product_id = null, $front = true, $withCalc = true, $onlyPublished = true)
{
//$this->fillVoidProduct($front);
if (!empty($virtuemart_product_id)) {
$virtuemart_product_id = $this->setId($virtuemart_product_id);
}
// if(empty($this->_data)){
if (!empty($this->_id)) {
// $joinIds = array('virtuemart_product_price_id' =>'#__virtuemart_product_prices','virtuemart_manufacturer_id' =>'#__virtuemart_product_manufacturers','virtuemart_customfield_id' =>'#__virtuemart_product_customfields');
$joinIds = array('virtuemart_manufacturer_id' => '#__virtuemart_product_manufacturers', 'virtuemart_customfield_id' => '#__virtuemart_product_customfields');
$product = $this->getTable('products');
$product->load($this->_id, 0, 0, $joinIds);
$xrefTable = $this->getTable('product_medias');
$product->virtuemart_media_id = $xrefTable->load((int) $this->_id);
// Load the shoppers the product is available to for Custom Shopper Visibility
$product->shoppergroups = $this->getProductShoppergroups($this->_id);
if (!empty($product->shoppergroups) and $front) {
if (!class_exists('VirtueMartModelUser')) {
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php';
}
$usermodel = VmModel::getModel('user');
$currentVMuser = $usermodel->getUser();
$virtuemart_shoppergroup_ids = (array) $currentVMuser->shopper_groups;
// vmdebug('$user->shoppergroups',$virtuemart_shoppergroup_ids);
$commonShpgrps = array_intersect($virtuemart_shoppergroup_ids, $product->shoppergroups);
if (empty($commonShpgrps)) {
$product = new stdClass();
return $this->fillVoidProduct($front);
}
}
$ppTable = $this->getTable('product_prices');
$ppTable->load($this->_id);
$product = (object) array_merge((array) $ppTable, (array) $product);
if (!empty($product->virtuemart_manufacturer_id)) {
$mfTable = $this->getTable('manufacturers');
$mfTable->load((int) $product->virtuemart_manufacturer_id);
$product = (object) array_merge((array) $mfTable, (array) $product);
} else {
$product->virtuemart_manufacturer_id = array();
$product->mf_name = '';
$product->mf_desc = '';
$product->mf_url = '';
}
// Load the categories the product is in
$product->categories = $this->getProductCategories($this->_id, $front);
if (!empty($product->categories) and is_array($product->categories) and !empty($product->categories[0])) {
$product->virtuemart_category_id = $product->categories[0];
$q = 'SELECT `ordering`,`id` FROM `#__virtuemart_product_categories`
WHERE `virtuemart_product_id` = "' . $this->_id . '" and `virtuemart_category_id`= "' . $product->virtuemart_category_id . '" ';
$this->_db->setQuery($q);
// change for faster ordering
$ordering = $this->_db->loadObject();
if (!empty($ordering)) {
$product->ordering = $ordering->ordering;
//What is this? notice by Max Milbers
$product->id = $ordering->id;
}
}
if (empty($product->virtuemart_category_id)) {
if (isset($product->categories[0])) {
$product->virtuemart_category_id = $product->categories[0];
} else {
$product->virtuemart_category_id = 0;
}
}
if (!empty($product->categories[0])) {
$virtuemart_category_id = 0;
if ($front) {
if (!class_exists('shopFunctionsF')) {
require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
if (in_array($last_category_id, $product->categories)) {
$virtuemart_category_id = $last_category_id;
} else {
$virtuemart_category_id = JRequest::getInt('virtuemart_category_id', 0);
}
}
if ($virtuemart_category_id == 0) {
if (array_key_exists('0', $product->categories)) {
$virtuemart_category_id = $product->categories[0];
}
}
$catTable = $this->getTable('categories');
$catTable->load($virtuemart_category_id);
$product->category_name = $catTable->category_name;
} else {
$product->category_name = '';
}
// $this->productHasCustoms($this->_id);
if (!$front) {
// if (!empty($product->virtuemart_customfield_id ) ){
$customfields = VmModel::getModel('Customfields');
$product->customfields = $customfields->getproductCustomslist($this->_id);
if (empty($product->customfields) and !empty($product->product_parent_id)) {
//$product->customfields = $this->productCustomsfieldsClone($product->product_parent_id,true) ;
$product->customfields = $customfields->getproductCustomslist($product->product_parent_id, $this->_id);
$product->customfields_parent_id = $product->product_parent_id;
}
// vmdebug('$product->customfields',$product->customfields);
//.........这里部分代码省略.........
示例7: prepareContinueLink
function prepareContinueLink()
{
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryStr = '';
if ($virtuemart_category_id) {
$categoryStr = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$ItemidStr = '';
$Itemid = shopFunctionsF::getLastVisitedItemId();
if (!empty($Itemid)) {
$ItemidStr = '&Itemid=' . $Itemid;
}
$lang = '';
if (VmConfig::$langCount > 1 and !empty(VmConfig::$vmlangSef)) {
$lang = '&lang=' . VmConfig::$vmlangSef;
}
$this->continue_link = JURI::root() . '/index.php?option=com_virtuemart&view=category' . $categoryStr . $lang . $ItemidStr;
$this->continue_link_html = '<a class="continue_link" href="' . $this->continue_link . '">' . vmText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->cart_link = JURI::root() . 'index.php?option=com_virtuemart&view=cart' . $lang;
return;
}
示例8: display
public function display($tpl = null)
{
$show_prices = tsmConfig::get('show_prices', 1);
if ($show_prices == '1') {
if (!class_exists('calculationHelper')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
}
}
$this->assignRef('show_prices', $show_prices);
if (!class_exists('shopFunctionsF')) {
require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$pathway = $app->getPathway();
if (!class_exists('VmImage')) {
require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
}
// set search and keyword
if ($keyword = vRequest::getString('keyword', false)) {
//uword('keyword', false, ' ,-,+,.,_')) {
$pathway->addItem($keyword);
//$title .=' ('.$keyword.')';
}
//$search = vRequest::uword('keyword', null);
$this->searchcustom = '';
$this->searchCustomValues = '';
//if (!empty($keyword)) {
$this->getSearchCustom();
$search = $keyword;
/*} else {
$keyword ='';
$search = NULL;
}*/
$this->assignRef('keyword', $keyword);
$this->assignRef('search', $search);
$menus = $app->getMenu();
$menu = $menus->getActive();
if (!empty($menu->id)) {
ShopFunctionsF::setLastVisitedItemId($menu->id);
} else {
if ($itemId = vRequest::getInt('Itemid', false)) {
ShopFunctionsF::setLastVisitedItemId($itemId);
}
}
$virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', -1);
if ($virtuemart_manufacturer_id === -1 and !empty($menu->query['virtuemart_manufacturer_id'])) {
$virtuemart_manufacturer_id = $menu->query['virtuemart_manufacturer_id'];
vRequest::setVar('virtuemart_manufacturer_id', $virtuemart_manufacturer_id);
}
$this->categoryId = vRequest::getInt('virtuemart_category_id', -1);
if ($this->categoryId === -1 and !empty($menu->query['virtuemart_category_id'])) {
$this->categoryId = $menu->query['virtuemart_category_id'];
vRequest::setVar('virtuemart_category_id', $this->categoryId);
} else {
if ($this->categoryId === -1 and $virtuemart_manufacturer_id === -1) {
$this->categoryId = ShopFunctionsF::getLastVisitedCategoryId();
}
}
$this->setCanonicalLink($tpl, $document, $this->categoryId, $virtuemart_manufacturer_id);
if (($this->categoryId === -1 or $this->categoryId === 0) and $virtuemart_manufacturer_id) {
$this->categoryId = 0;
$catType = 'manufacturer';
$this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType);
}
$categoryModel = tmsModel::getModel('category');
$productModel = tmsModel::getModel('product');
if ($this->categoryId === -1) {
$this->categoryId = 0;
}
$vendorId = 1;
$category = $categoryModel->getCategory($this->categoryId);
if (!isset($menu->query['showproducts'])) {
$menu->query['showproducts'] = 1;
}
$this->showproducts = vRequest::getInt('showproducts', $menu->query['showproducts']);
if (!empty($category)) {
$vendorId = $category->virtuemart_vendor_id;
if ($this->showproducts) {
//if(empty($category->category_layout) or $category->category_layout != 'categories') {
// Load the products in the given category
$this->products = $productModel->getItemList();
//$products = $productModel->getProductsInCategory($this->categoryId);
$productModel->addImages($this->products, tsmConfig::get('prodimg_browse', 1));
}
//No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) {
if (empty($category->slug)) {
vmInfo(tsmText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
} else {
if ($category->virtuemart_id !== 0 and !$category->published) {
vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId);
}
}
//Fallback
$categoryLink = '';
if ($category->category_parent_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id;
} else {
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
//.........这里部分代码省略.........
示例9: addJS
/**
* Add the product to the cart, with JS
*
* @author Max Milbers
* @access public
*/
public function addJS()
{
//maybe we should use $mainframe->close(); or jexit();instead of die;
/* Load the cart helper */
//require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$this->json = null;
$cart = VirtueMartCart::getCart(false);
if ($cart) {
// Get a continue link */
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
if ($virtuemart_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id;
} else {
$categoryLink = '';
}
$continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink);
$virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
$errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
if ($cart->add($virtuemart_product_ids, $errorMsg)) {
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart") . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>';
if ($errorMsg) {
$this->json->msg .= '<div>' . $errorMsg . '</div>';
}
$this->json->stat = '1';
} else {
// $this->json->msg = '<p>' . $cart->getError() . '</p>';
$this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<div>' . $errorMsg . '</div>';
$this->json->stat = '2';
}
} else {
$this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart') . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
$this->json->stat = '0';
}
echo json_encode($this->json);
jExit();
}
示例10: getProductSingle
//.........这里部分代码省略.........
require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php';
}
$commonShpgrps = array_intersect($virtuemart_shoppergroup_ids, $product->shoppergroups);
if (empty($commonShpgrps)) {
vmdebug('getProductSingle creating void product, shoppergroups does not fit ', $product->shoppergroups);
return $this->fillVoidProduct($front);
}
}
$this->getRawProductPrices($product, $quantity, $virtuemart_shoppergroup_ids, $front, $withParent);
$xrefTable = $this->getTable('product_manufacturers');
$product->virtuemart_manufacturer_id = $xrefTable->load((int) $this->_id);
if (!empty($product->virtuemart_manufacturer_id[0])) {
//This is a fallback
$mfTable = $this->getTable('manufacturers');
$mfTable->load((int) $product->virtuemart_manufacturer_id[0]);
$product = (object) array_merge((array) $mfTable, (array) $product);
} else {
$product->virtuemart_manufacturer_id = array();
$product->mf_name = '';
$product->mf_desc = '';
$product->mf_url = '';
}
// Load the categories the product is in
$product->categoryItem = $this->getProductCategories($this->_id, FALSE);
//We need also the unpublished categories, else the calculation rules do not work
$product->canonCatId = false;
if (!empty($product->categoryItem)) {
//$tmp = array();
foreach ($product->categoryItem as $category) {
if ($category['published'] and !$product->canonCatId) {
$product->canonCatId = $category['virtuemart_category_id'];
}
$tmp[] = $category['virtuemart_category_id'];
}
$product->categories = $tmp;
}
$product->virtuemart_category_id = 0;
if (!empty($product->categories) and is_array($product->categories)) {
if ($front) {
if (!class_exists('shopFunctionsF')) {
require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
//We must first check if we come from another category, due the canoncial link we would have always the same catgory id for a product
//But then we would have wrong neighbored products / category and product layouts
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
if ($last_category_id !== 0 and in_array($last_category_id, $product->categories)) {
$product->virtuemart_category_id = $last_category_id;
}
}
if (empty($product->virtuemart_category_id)) {
$virtuemart_category_id = vRequest::getInt('virtuemart_category_id', 0);
if ($virtuemart_category_id !== 0 and in_array($virtuemart_category_id, $product->categories)) {
$product->virtuemart_category_id = $virtuemart_category_id;
} else {
if (!empty($product->canonCatLink)) {
$product->virtuemart_category_id = $product->canonCatLink;
} else {
if (!$front and !empty($product->categories) and is_array($product->categories) and array_key_exists(0, $product->categories)) {
$product->virtuemart_category_id = $product->categories[0];
//vmdebug('I take for product the main category ',$product->virtuemart_category_id,$product->categories);
}
}
}
}
}
if (!empty($product->virtuemart_category_id)) {
$found = false;
foreach ($product->categoryItem as $category) {
if ($category['virtuemart_category_id'] == $product->virtuemart_category_id) {
$product->ordering = $category['ordering'];
//This is the ordering id in the list to store the ordering notice by Max Milbers
$product->id = $category['id'];
$product->category_name = $category['category_name'];
$found = true;
break;
}
}
if (!$found) {
$product->ordering = $this->_autoOrder++;
$product->id = $this->_autoOrder;
vmdebug('$product->virtuemart_category_id no ordering stored for product ' . $this->_id);
}
} else {
$product->category_name = null;
$product->virtuemart_category_id = null;
$product->ordering = null;
$product->id = $this->_autoOrder++;
//vmdebug('$product->virtuemart_category_id is empty ',$product->virtuemart_product_id);
}
// Check the stock level
if (empty($product->product_in_stock)) {
$product->product_in_stock = 0;
}
//$product->setDboNull();
$_productsSingle[$productKey] = $product;
} else {
$_productsSingle[$productKey] = $this->fillVoidProduct($front);
}
return clone $_productsSingle[$productKey];
}
示例11: getNeighborProducts
/**
* This function retrieves the "neighbor" products of a product specified by $virtuemart_product_id
* Neighbors are the previous and next product in the current list
*
* @author RolandD, Max Milbers
* @param object $product The product to find the neighours of
* @return array
*/
public function getNeighborProducts($product, $onlyPublished = TRUE, $max = 1)
{
$db = JFactory::getDBO();
$neighbors = array('previous' => '', 'next' => '');
$direction = 'DESC';
$op = '<';
$app = JFactory::getApplication();
if ($app->isSite()) {
$usermodel = VmModel::getModel('user');
$currentVMuser = $usermodel->getUser();
$virtuemart_shoppergroup_ids = (array) $currentVMuser->shopper_groups;
}
foreach ($neighbors as &$neighbor) {
$q = 'SELECT `l`.`virtuemart_product_id`, `l`.`product_name`
FROM `#__virtuemart_products` as `p`
JOIN `#__virtuemart_products_' . VMLANG . '` as `l` using (`virtuemart_product_id`)
JOIN `#__virtuemart_product_categories` as `pc` using (`virtuemart_product_id`)';
if ($app->isSite()) {
$q .= ' LEFT JOIN `#__virtuemart_product_shoppergroups` as `psgr` on (`psgr`.`virtuemart_product_id`=`l`.`virtuemart_product_id`)';
}
if ($app->isSite()) {
if (!class_exists('shopFunctionsF')) {
require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopFunctionsF.php';
}
$lastId = shopFunctionsF::getLastVisitedCategoryId();
if (empty($lastId)) {
$lastId = (int) $product->virtuemart_category_id;
}
$q .= ' WHERE `virtuemart_category_id` = ' . $lastId;
} else {
$q .= ' WHERE `virtuemart_category_id` = ' . (int) $product->virtuemart_category_id;
}
$q .= ' and `slug` ' . $op . ' "' . $product->slug . '" ';
if ($app->isSite()) {
if (is_array($virtuemart_shoppergroup_ids)) {
$sgrgroups = array();
foreach ($virtuemart_shoppergroup_ids as $key => $virtuemart_shoppergroup_id) {
$sgrgroups[] = 'psgr.`virtuemart_shoppergroup_id`= "' . (int) $virtuemart_shoppergroup_id . '" ';
}
$sgrgroups[] = 'psgr.`virtuemart_shoppergroup_id` IS NULL ';
$q .= " AND ( " . implode(' OR ', $sgrgroups) . " ) ";
}
}
// $q .= ' AND (`psgr`.`virtuemart_shoppergroup_id` IS NULL OR `psgr`.`virtuemart_shoppergroup_id`= "'..'" ';
if ($onlyPublished) {
$q .= ' AND p.`published`= 1';
}
$q .= ' ORDER BY `slug` ' . $direction . ' LIMIT 0,' . (int) $max;
$db->setQuery($q);
if ($result = $db->loadAssocList()) {
$neighbor = $result;
}
$direction = 'ASC';
$op = '>';
//vmdebug('getNeighborProducts '.$db->getQuery());
//vmdebug('getNeighborProducts '.$db->getErrorMsg());
}
return $neighbors;
}
示例12: display
public function display($tpl = null)
{
$show_prices = VmConfig::get('show_prices', 1);
if ($show_prices == '1') {
if (!class_exists('calculationHelper')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
}
}
$this->assignRef('show_prices', $show_prices);
// add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
vmJsApi::jPrice();
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$pathway = $app->getPathway();
if (!class_exists('VmImage')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
}
$categoryModel = VmModel::getModel('category');
$productModel = VmModel::getModel('product');
// set search and keyword
if ($keyword = vmRequest::uword('keyword', false, ' ,-,+,.,_')) {
$pathway->addItem($keyword);
//$title .=' ('.$keyword.')';
}
//$search = VmRequest::uword('keyword', null);
$this->searchcustom = '';
$this->searchcustomvalues = '';
if (!empty($keyword)) {
$this->searchcustom = $this->getSearchCustom();
$search = $keyword;
} else {
$keyword = '';
$search = NULL;
}
$this->assignRef('search', $search);
$this->assignRef('keyword', $keyword);
$categoryId = JRequest::getInt('virtuemart_category_id', false);
$virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', false);
if ($categoryId === false and $virtuemart_manufacturer_id === false) {
$categoryId = ShopFunctionsF::getLastVisitedCategoryId();
$catType = 'category';
$this->setCanonicalLink($tpl, $document, $categoryId, $catType);
} else {
if ($categoryId === false and $virtuemart_manufacturer_id) {
$catType = 'manufacturer';
$this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType);
} else {
$catType = 'category';
$this->setCanonicalLink($tpl, $document, $categoryId, $catType);
}
}
if ($categoryId !== -1) {
$vendorId = 1;
$category = $categoryModel->getCategory($categoryId);
}
if (!empty($category)) {
if (empty($category->category_layout) or $category->category_layout != 'category') {
// Load the products in the given category
$ids = $productModel->sortSearchListQuery(TRUE, $categoryId);
$perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row;
$this->assignRef('perRow', $perRow);
$pagination = $productModel->getPagination($perRow);
$this->assignRef('vmPagination', $pagination);
$products = $productModel->getProducts($ids);
//$products = $productModel->getProductsInCategory($categoryId);
$productModel->addImages($products, 1);
$this->assignRef('products', $products);
if ($products) {
$currency = CurrencyDisplay::getInstance();
$this->assignRef('currency', $currency);
foreach ($products as $product) {
$product->stock = $productModel->getStockIndicator($product);
}
}
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);
$orderByList = $productModel->getOrderByList($categoryId);
$this->assignRef('orderByList', $orderByList);
// Add feed links
if ($products && VmConfig::get('feed_cat_published', 0) == 1) {
$link = '&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
}
if (!class_exists('Permissions')) {
require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
}
$showBasePrice = Permissions::getInstance()->check('admin');
//todo add config settings
$this->assignRef('showBasePrice', $showBasePrice);
}
//No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) {
if (empty($category->slug)) {
vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
} else {
if ($category->virtuemart_id !== 0 and !$category->published) {
//.........这里部分代码省略.........
示例13: display
public function display($tpl = null)
{
$show_prices = VmConfig::get('show_prices', 1);
if ($show_prices == '1') {
JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php');
}
$this->assignRef('show_prices', $show_prices);
// add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
vmJsApi::jPrice();
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$pathway = $app->getPathway();
JLoader::register('VmImage', JPATH_VM_ADMINISTRATOR . '/helpers/image.php');
$categoryModel = VmModel::getModel('category');
$productModel = VmModel::getModel('product');
$search = JRequest::getvar('keyword', null);
if ($search !== null) {
$searchcustom = $this->getSearchCustom();
}
$this->assignRef('keyword', $keyword);
$this->assignRef('search', $search);
$categoryId = JRequest::getInt('virtuemart_category_id', ShopFunctionsF::getLastVisitedCategoryId());
$virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', 0);
$this->setCanonicalLink($tpl, $document, $categoryId);
// $vendorId = JRequest::getInt('virtuemart_vendor_id', 1);
$vendorId = JRequest::getInt('virtuemart_vendor_id', null);
// Load the products in the given category
$products = $productModel->getProductsInCategory($categoryId, $vendorId);
$productModel->addImages($products, 1);
$this->assignRef('products', $products);
if ($products) {
$currency = CurrencyDisplay::getInstance();
$this->assignRef('currency', $currency);
foreach ($products as $product) {
$product->stock = $productModel->getStockIndicator($product);
}
}
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$this->assignRef('showRating', $showRating);
$orderByList = $productModel->getOrderByList($categoryId);
$this->assignRef('orderByList', $orderByList);
// Add feed links
if ($products && VmConfig::get('feed_cat_published', 0) == 1) {
$link = '&format=feed&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
}
JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php');
$showBasePrice = Permissions::getInstance()->check('admin');
//todo add config settings
$this->assignRef('showBasePrice', $showBasePrice);
//set this after the $categoryId definition
$paginationAction = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId, FALSE);
$this->assignRef('paginationAction', $paginationAction);
shopFunctionsF::setLastVisitedCategoryId($categoryId);
shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id);
if ($categoryId !== -1) {
$vendorId = JRequest::getInt('virtuemart_vendor_id', 1);
$category = $categoryModel->getCategory($categoryId);
}
$perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row;
$this->assignRef('perRow', $perRow);
$pagination = $productModel->getPagination($perRow);
$this->assignRef('vmPagination', $pagination);
if (!empty($category)) {
if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) {
if (empty($category->slug)) {
vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
} else {
if ($category->virtuemart_id !== 0 and !$category->published) {
vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $categoryId);
//return false;
}
}
$categoryLink = '';
if ($category->category_parent_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id;
} else {
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
if (!$last_category_id or $categoryId == $last_category_id) {
$last_category_id = JRequest::getInt('virtuemart_category_id', false);
}
if ($last_category_id and $categoryId != $last_category_id) {
$categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id;
}
}
$app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE));
return;
}
//No redirect here, category id = 0 means show ALL categories! note by Max Milbers
/* if(empty($category->virtuemart_vendor_id) && $search == null ) {
$app -> enqueueMessage(JText::_('COM_VIRTUEMART_CATEGORY_NOT_FOUND'));
$app -> redirect( 'index.php');
}*/
// Add the category name to the pathway
if ($category->parents) {
foreach ($category->parents as $c) {
//.........这里部分代码省略.........
示例14: prepareContinueLink
function prepareContinueLink()
{
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryStr = '';
if ($virtuemart_category_id) {
$categoryStr = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$ItemidStr = '';
$Itemid = shopFunctionsF::getLastVisitedItemId();
if (!empty($Itemid)) {
$ItemidStr = '&Itemid=' . $Itemid;
}
$lang = '';
if (VmConfig::$jLangCount > 1 and !empty(VmConfig::$vmlangSef)) {
$lang = '&lang=' . VmConfig::$vmlangSef;
}
$this->continue_link = JURI::root() . 'index.php?option=com_virtuemart&view=category' . $categoryStr . $lang . $ItemidStr;
$this->continue_link_html = '<a class="continue_link" href="' . $this->continue_link . '">' . vmText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$juri = JUri::getInstance()->toString(array('host', 'port'));
$scheme = 'http';
if (VmConfig::get('useSSL', false)) {
$scheme .= 's';
}
$this->cart_link = $scheme . '://' . $juri . JURI::root(true) . '/index.php?option=com_virtuemart&view=cart' . $lang;
return;
}
示例15: getProductSingle
//.........这里部分代码省略.........
$product = (object) array_merge((array) $mfTable, (array) $product);
} else {
$product->virtuemart_manufacturer_id = array();
$product->mf_name = '';
$product->mf_desc = '';
$product->mf_url = '';
}
// Load the categories the product is in
//$product->categories = $this->getProductCategories ($this->_id, $front);
$product->categories = $this->getProductCategories($this->_id, FALSE);
//We need also the unpublished categories, else the calculation rules do not work
if (!empty($product->product_url)) {
$product->canonCatLink = $product->product_url;
} else {
if (!empty($product->categories)) {
$categories = $this->getProductCategories($this->_id, TRUE);
//only published
if ($categories) {
if (!is_array($categories)) {
$categories = (array) $categories;
}
$product->canonCatLink = $categories[0];
}
}
}
$product->virtuemart_category_id = 0;
if ($front) {
if (!empty($product->categories) and is_array($product->categories) and count($product->categories) > 1) {
if (!class_exists('shopFunctionsF')) {
require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
//We must first check if we come from another category, due the canoncial link we would have always the same catgory id for a product
//But then we would have wrong neighbored products / category and product layouts
$last_category_id = shopFunctionsF::getLastVisitedCategoryId();
if ($last_category_id !== 0 and in_array($last_category_id, $product->categories)) {
$product->virtuemart_category_id = $last_category_id;
//vmdebug('I take for product the last category ',$last_category_id,$product->categories);
} else {
$virtuemart_category_id = vRequest::getInt('virtuemart_category_id', 0);
if ($virtuemart_category_id !== 0 and in_array($virtuemart_category_id, $product->categories)) {
$product->virtuemart_category_id = $virtuemart_category_id;
//vmdebug('I take for product the requested category ',$virtuemart_category_id,$product->categories);
} else {
if (!empty($product->categories) and is_array($product->categories) and array_key_exists(0, $product->categories)) {
$product->virtuemart_category_id = $product->categories[0];
//vmdebug('I take for product the main category ',$product->virtuemart_category_id,$product->categories);
}
}
}
} else {
if (!empty($product->canonCatLink)) {
$product->virtuemart_category_id = $product->canonCatLink;
}
}
} else {
//This construction should allow us to see category depended prices in the BE
$virtuemart_category_id = JRequest::getInt('virtuemart_category_id', 0);
if ($virtuemart_category_id !== 0 and !empty($product->categories)) {
if (is_array($product->categories) and in_array($virtuemart_category_id, $product->categories)) {
$product->virtuemart_category_id = $virtuemart_category_id;
} else {
if ($product->categories == $virtuemart_category_id) {
$product->virtuemart_category_id = $virtuemart_category_id;
}
}
}