product navigation on detailpage doesn´t stay in choosen category

Started by slammy, April 13, 2012, 13:42:19 PM

Previous topic - Next topic

slammy

Hi,

I am facing the following problem (I am currently using joomla 2.5.4 and VM2.0.4.)
If I use the prev and next productlinks at the productdetails view the links doesn´t stay in the initially choosen category:

For Example: I choose "scented candles" as a product-category to browse. I click at the details from one of it´s products and want to click with prev and next to the neighbour-products in that category, but what happens is: the click redirects me to products of other categories, not every, but nearly each click the category is switching, sometimes the prev and next links stay for 1,2,3 clicks in the category. For that, I can´t find any pattern why this is happening. I really did notice it as I activate breadcrumbs and see the switching.

First I thought it has something to do with products in multiple categories, but that seems not to be the problem.

does anyone have that problem too or am I the only one? Do I have to configure something special so that prev and next work?
would appreciate any help or information
thx jens

qme1ster

I'm having the same issue in VM 1.1, so it appears the issue persists. I'd be curious to know if you manage to resolve. It may help me also.

Milbo

The is intended, sorry didnt read the whole post, but it is connected to SEF. Problem would be, when it would take an unpublished category for it.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

slammy

Hi Milbo,

thx for your reply! I am sorry I am asking again, I am not a native english speaker, maybe I get something wrong. Does your answer means that this problem occurs if prev-or-next products are belonging both to published and unpublished categorys and SEF is turned on? thx again for ur time, best regards slam

qme1ster

I was experiencing the same type of issue with VM 1.1.9 whereby the navigation just didn't match up to the browse page order.

I've subsequently done a fresh install of the latest VM 2.0.6 and imported the product list. With SEF DISABLED the problem persists, so as far as I can see SEF isn't to blame. Whatever the reason, with products residing in multiple categories the navigation on the product details page seems random. This is harmful to a store. Certainly my clients are not happy about it.

It seems like a bug to me - surely this can't be intentional behaviour ? In my humble opinion this is an inadequacy that could have a detrimental effect on sales.

Is there any solution ?


qme1ster

No posts here really resolve or provide a definitive explanation on this issue, for VM 1.1 nor for VM 2.0.

Are there any VM contributors/moderators/experts willing to help out with an explanation as to what might be going on and what we might be able to do to resolve ?

To recap the issue- you click into Category A to arrive at that category's browse page, select a product to arrive at that product's flypage. VM breadcrumbs indicate you are in Category A. As you use the prev and next navigation you pass through various categories B, C, D etc and what's more the order doesn't relate to the browse page. Even worse some products are skipped while others not in Cat A appear.

I'm not sure where to go on this. Clients getting antsy and understandably so.

Here's hoping some help or advice will arrive !

Thanks in advance

 


slammy

Hi qme1ster,

thx for ur post. I did have the issue with vm 1.1.9 too.
I just did the update from vm 2.0.6 to 2.0.7 and it seems the problem is gone. Can u confirm?
best regards jens

qme1ster

I've run that upgrade also to 2.0.7 but in my case this made no difference - the product navigation is still way out.


slammy

hm, ok I will test again when I am back in my office. Weird. Did you use the latest productdetails-view-template -> default.php ? I have seen come code changes there in productnavigation with 2.0.7, I come back again, jens

slammy

ok my fault, sry. What now happens is: The breadcrumb is now still consistent, what means: If I choose for Example scented Candles -> the breadcrumbs stay - while switching with prev and next - in the choosed category but the products  are still further from different categories.

Milbo

Quote from: qme1ster on May 03, 2012, 14:50:07 PM
To recap the issue- you click into Category A to arrive at that category's browse page, select a product to arrive at that product's flypage. VM breadcrumbs indicate you are in Category A. As you use the prev and next navigation you pass through various categories B, C, D etc and what's more the order doesn't relate to the browse page. Even worse some products are skipped while others not in Cat A appear.

It happens because you have product b in at least two categories. Every product has one maincategory, only one url per product gives the best SEO. So when you go to the other product it shows you the other category.

It is changed now that hte breadcrumb stas consistent, so people can use it to click back. I dont know how to solve this problem easily.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

slammy

Hi Milbo, thx for ur answer.
Only for information, how is virtuemart choosing the maincategory of a product? Does it take the lowest entry (category-name) in alphabetical order?
thanks in advance,

slammy

Hi,

just as information. This thread is solved now. I´ve just installed sr vm 2.0.14_f and now it´s possible to put products in more than one category without getting a inconsistent prev- and next navigation on productdetailpages.

Great Work VM-Developers!
best regards
slammy

slammy

sorry for my last post, the prev and next navigation on productsdetailspage is still inconsistent when having products in more than one category with sr vm 2.0.14_f and jml 2.5.8

regards slammy

Peter Pillen

I have found what is causing this problem... The function that fetches the neighbours only uses the slug of each product and nothing else. It is not changeable in the administrator end because it is coded in core.

the file causing this is /administrator/components/com_virtuemart/models/product.php

Here you will find the following code at about line 1221 (attention! the code below is already adapted to my needs)

<?php public function getNeighborProducts ($product, $onlyPublished = TRUE, $max = 1) {

$db = JFactory::getDBO ();
$neighbors = array('previous' => '', 'next' => '');
$direction = 'ASC';//DROPPED BY P2 PETER $direction = 'DESC';
$op = '>'; //DROPPED BY P2 PETER $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 `l`.`virtuemart_product_id` ' . $op . ' "' . $product->virtuemart_product_id . '" '; //DROPPED BY P2 PETER $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 `l`.`virtuemart_product_id` ' . $direction . ' LIMIT 0,' . (int)$max;  //DROPPED BY P2PETER $q .= ' ORDER BY `slug` ' . $direction . ' LIMIT 0,' . (int)$max;

$db->setQuery ($q);
if ($result = $db->loadAssocList ()) {
$neighbor = $result;
}
$direction = 'DESC'; //DROPPED BY P2 PETER $direction = 'ASC';
$op = '<'; //DROPPED BY P2 PETER $op = '>';
  //vmdebug('getNeighborProducts '.$db->getQuery());
//vmdebug('getNeighborProducts '.$db->getErrorMsg());
}

return $neighbors;
}
?>



In my case, I sort the products by product_id as standard. So as you can see in the code, I changed several lines to use the product_id instead of the product Slug. You can see which lines I dropped there where //DROPPED BY P2 PETER is written. Of course when a visitor changes the order in browseview, it will not translate these settings to the productdetails navigation.

To solve this problem once and forever, someone would need to integrate the case-switch coding from line 353 (see below) in the function getNeighborProducts
<?php switch ($this->filter_order) {
case 'product_special':
if($isSite){
$where[] = ' p.`product_special`="1" '; // TODO Change  to  a  individual button
$orderBy = 'ORDER BY RAND()';
} else {
$orderBy = 'ORDER BY `product_special`';
}

break;
case 'category_name':
$orderBy = ' ORDER BY `category_name` ';
$joinCategory = TRUE;
break;
case 'category_description':
$orderBy = ' ORDER BY `category_description` ';
$joinCategory = TRUE;
break;
case 'mf_name':
$orderBy = ' ORDER BY `mf_name` ';
$joinMf = TRUE;
break;
case 'ordering':
$orderBy = ' ORDER BY `#__virtuemart_product_categories`.`ordering` ';
$joinCategory = TRUE;
break;
case 'product_price':
//$filters[] = 'p.`virtuemart_product_id` = p.`virtuemart_product_id`';
$orderBy = ' ORDER BY `product_price` ';
$joinPrice = TRUE;
break;
case 'created_on':
$orderBy = ' ORDER BY p.`created_on` ';
break;
default;
if (!empty($this->filter_order)) {
$orderBy = ' ORDER BY ' . $this->_db->getEscaped ($this->filter_order) . ' ';
}
else {
$this->filter_order_Dir = '';
}
break;
} ?>