The product navigation in product details doesn't work properly:
I have product a, b, c, d, e, f, g, h, sortet by name. Whe I go now to product detail of product "a" the navigation starts to the left instead to the right and shows product "c" ( <- c ). There in the navigation I see product "e" directed to the left and product "a" to the right. (<- e -> a )
So there are two errors: 1. The navigation goes to the wrong direction. 2. Only every second product will be shown. (If I start with product "b" the navigation goes to product "d")
Can anybody confirm this problem? It worked fine with VM 2.0.0
Regards Patrik
I have still this problem. I am now on VM 2.0.1 rev 5339. Isn't this a bug?? As soon as I go down to the official VM 2.0.0 release, the problem disappears.
You mean the neighboured products?
Yes, they are in the wrong order as I tried to descrihe above.
Yes the previous / next arrows are going by Product ID and not the ordering set in the config of ordering on category view.
It is correct that the neighbour products start alphabeticly in order of the name.
The errors are the following:
- neighbour products should start to the right on the right upper corner. They don't, instead they start on the left upper corner to the left.
- Only every second product appears ( e.g. "a , c , e , g...)
So which order is to choose then?
the manual ordering? I think it should depend on the selection you did before in the category view.
Ok, I have atached two pics. the "correct" shows the correct order of the neighbour products: to the left you go to the previous product. to the right you go to the next product.
after uppdating the "wrong" pic shows the following: to the left you go to the after next product, to the right you go to the pre-previous product.
It doesn't matter which order is selected in the category overview. The neighbour products always follows in alphabetic order. back to the left, forward to the right.
This doesn't work any longer in newer versions than 2.0.0. In the old VM 1.1 it was depending on the selection in category view.
[attachment cleanup by admin]
I'm now on rev 5409. I have seen that there have been some changes. But there are new problems now: Back and Forward arrows are working now properly (left=back, right= forward). But now always only the first and the last product of a category (in alphabetic order) are shown in the product navigation ! it doesn't matter, which kind of order is selected in the category view.
oha shit, too small sample, sorry. I take a look, it is an interesting part.
yes, you've got it. works fine now (rev 5413)!
Please anyone... state a public code solution of this issue I guess I am not the only one that have this issue and cannot use the SVN.
So that productdetail page can have a proper function next/previous navigation
It is not working for me in 2.0.1F(and E) (actually more bad than in 2.0.0 ?!)
Only two products are available: the first and the last of that category (a-z)
And please no "its fixed in SVN" I cannot bear to wait for yet another update to find something working before, is now broken in the new version...
:) So I really hope this is possible with a quick fix.
The code I see changed in /productdetails/default.php is:Quote<?php
// Product Navigation
if (VmConfig::get('product_navigation', 1)) { ?>
<div class="product-neighbours">
<?php
if (!empty($this->product->neighbours ['previous'][0])) {
$prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id);
echo JHTML::_('link', $prev_link, $this->product->neighbours ['previous'][0]
['product_name'], array('class' => 'previous-page'));
}
if (!empty($this->product->neighbours ['next'][0])) {
$next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id);
echo JHTML::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('class' => 'next-page'));
}
?>
But I am not a coder and do not know what these
- means that arrived.
And it seems if I remove them (same as VM2.0.0) the navigation disappears.
System:
J. 1.5.25
VM 2.0.1E and VM 2.0.1F
Thanks.
It is in the last version, it is updated, installer is available.
I'm having this same problem in VM 2.0.6. I can sort the products by SKU or custom order, and they are displayed correctly on the Category page. However, on the Product Details, the next/prev links go to in seemingly random order.
My product navigation works only with produtcs name, so the prev/next button show the the prev/netx product by alpabetical order of produtcs name in category.
The product are displayed correctly on the Category page (by product AZ)
Hello,
How is this issue fixed?I updated yesterday to version 2.0.14 and I am still getting this problem.
Seems product neighbours wherever they are ordered are getting the wrong order..and I don't seem to find what order that is.Or even where is the file that does this..
Can someone help?
Best regards,
Joao Garin
Hello,
I found this thread exactly with the same problem as Joao Garin reported (version 2.0.14) ... prev/next seem to show random neighbour products, in Category-Page the order is fine. At virtuemart 1.x it just worked out of the box correctly.
Any hint would be really apreciated.
Regards
Spule
It is using always order by $q .= ' ORDER BY `slug` ' . $direction . ' LIMIT 0,' . (int)$max;
slug = Product Alias
We have migrated to 2.0.18a only to find out that product navigation does not work. You can not go "next" and jump to the next product in that category..Can someone help.
thanks
Carol
There is nothing solved with VM 2.0.18a. Going forward or backward from product details page with the navigation buttons does choose products from somewhere in the category but not the next or previous product in that category!!
QuoteThere is nothing solved with VM 2.0.18a. Going forward or backward from product details page with the navigation buttons does choose products from somewhere in the category but not the next or previous product in that category!!
I don't have this problem any more since a long time. To be sure that it isn't a problem of mine (maybe with other extensions) I have installed a clean Joomla with only the latest VM 2 version with the sample datas on my local environment. Before posting a problem I always check it there. As far as it works fine there I try to find the problems in my configuration.
Did you try this?
Sometimes problems like these remain because using old template overrides. Disabling the whole html folder in the template folder could solve the problem too.
Regards
Patrik
Quote from: ccfs70 on January 15, 2013, 01:59:46 AM
We have migrated to 2.0.18a only to find out that product navigation does not work. You can not go "next" and jump to the next product in that category..Can someone help.
thanks
Carol
Quote from: franzpeter on January 15, 2013, 14:20:51 PM
There is nothing solved with VM 2.0.18a. Going forward or backward from product details page with the navigation buttons does choose products from somewhere in the category but not the next or previous product in that category!!
I have found something which should help you to resolve this problem to some extent.
Product Navigation (Next/Prev) is directly related to the "
Default product sort order". For some unknown reason product neighbors array only gets populated when you set the "
Default product sort order" field to one of the followings:
- Product Name
- Product Short description
- Product Description
- Product in stock
- Product Sales
- Featured Product
If you set the same to something else for example Product Price or Product Available Date then it does not seem to be working.
"Default product sort order" also decide which products to be displayed when you click on Prev or Next product link.
You may find this helpful if your site is not at all displaying Product Navigation (even after enabling product navigation option in VM Config) and to understand how exactly it works.
Default product sort order" field can be found in VM
Configuration page under
Product Order Settings tab.
Milbo, I am sure there is some problem in the neighbor products array model. Please take a look at it.
Well Jumbo this is why I will continue to pay you for templates and support! That fixed the problem however shows that there is a much bigger problem.
this fix work for "Product Sort Order Settings" set to "ordering" in VM2 ver 2.018a
file: administrator/components/com_virtuemart/models/product.php (row: 1258)
if ($this->filter_order == "pc.ordering") // added
$q .= ' and pc.ordering ' . $op . ' ' . $product->ordering .' '; // added
else // added
$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';
}
if(!empty($this->orderByString)){
$orderBy = $this->orderByString;
} else {
$orderBy = ' ORDER BY '.$this->filter_order.' '; // <-- remove `
}
$q .= $orderBy . $direction . ' LIMIT 0,' . (int)$max;
Can I get a bit more specific details. Is this a find and replace or an add?
I copied your //add and your //<--remove and it still doesnt work. Why is this topic marked as solved?
Here is the file. What did I miss?
//}
/////////////////////////////////////////
///////// Added from http://forum.virtuemart.net/index.php?topic=96784.15;topicseen
if ($this->filter_order == "pc.ordering") // added
$q .= ' and pc.ordering ' . $op . ' ' . $product->ordering .' '; // added
else // added
/////////////// end the addition
$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';
}
if(!empty($this->orderByString)){
$orderBy = $this->orderByString;
} else {
// Original script $orderBy = ' ORDER BY `'.$this->filter_order.'` ';
$orderBy = ' ORDER BY '.$this->filter_order.' '; // <-- remove `
}
$q .= $orderBy . $direction . ' LIMIT 0,' . (int)$max;
I'm running into the exact same problem - Default order is set to Ordering and MUST remain that way. Product navigation doesn't work properly. Same as everyone elses. Version is 2.0.20b.
Edit - I found a temp solution:http://forum.virtuemart.net/index.php?topic=111450.0 (http://forum.virtuemart.net/index.php?topic=111450.0)
However this isn't a fix. This problem is NOT solved as it requires editting a core file. Please fix in next update.
That doesn't seem like a real fix either. :( Ill wait to see if they fix it. I wont hold my breath but I will cross my fingers.
The fix is already in the svn and the solution is already in another post,.. lol.
Umm, jeez thanks for your help milbo! Lol. How bout a link to where it is fixed so I don't have to search for another hour through dozens of unanswered threads on the same topic? Lol not
Johnjeez
Milbo has said that you should get the lates svn, 2.0.21C I believe.
If you dont want to update then extract the relevant code and replace in your version
Hi,
thanks empixmultimedia, it's works ;)
I still haven't been able to find a fix so I've added a bit of code in my template override to set the 'prev' and 'next' links according to "product ordering" which is what my customer wants. This goes above Product Navigation section and sets new values for $this->product->neighbours.
Yes, yes all very naughty because it breaks the MVC model, bolts in the language, has my quirky indenting, etc but it works.
// Ben's Product Navigation
function cbProductName ($id)
{
// get the name for a product.
// Alert: languare is bolted in!!
$cbDB = JFactory::getDBO() ;
$cbQuery = $cbDB->getQuery(true) ;
$cbQuery = "select product_name from #__virtuemart_products_en_gb where virtuemart_product_id = ".$id ;
$cbDB->setQuery((string)$cbQuery) ;
$cbName = $cbDB->loadResult() ;
return $cbName ;
}
// get the info
$cbProduct = $this->product->virtuemart_product_id ;
$cbCategory = $this->product->virtuemart_category_id ;
// query the database for the product ids in order (fallback order is product id)
$cbDB = JFactory::getDBO() ;
$cbQuery = $cbDB->getQuery(true) ;
$cbQuery = "select virtuemart_product_id from #__virtuemart_product_categories where virtuemart_category_id = ".$cbCategory." order by ordering,virtuemart_product_id" ;
$cbDB->setQuery((string)$cbQuery) ;
$cbList = $cbDB->loadResultArray() ;
// get prev & next from the list
$cbPosition = array_search ($cbProduct,$cbList) ;
if ($cbPosition === false)
{
$this->product->neighbours ['previous'][0] = '' ;
$this->product->neighbours ['next'][0] = '' ;
}
else
{
$cbPrev = ($cbPosition - 1 + count($cbList)) % count($cbList) ;
$cbNext = ($cbPosition + 1 + count($cbList)) % count($cbList) ;
// insert the results into $this
$this->product->neighbours ['previous'][0]['virtuemart_product_id'] = $cbList[$cbPrev] ;
$this->product->neighbours ['next'][0]['virtuemart_product_id'] = $cbList[$cbNext] ;
$this->product->neighbours ['previous'][0]['product_name'] = cbProductName($cbList[$cbPrev]) ;
$this->product->neighbours ['next'][0]['product_name'] = cbProductName($cbList[$cbNext]);
}
BTW, I'm on VM 2.0.22c and now see there is a 2.00.24. Will the ordering have been fixed in that release? Maybe somebody can answer. If it has you can ignore the above.
Also Joomla 2.5.14 and PHP 5.3.10
On 2.0.24 the neighbors are still out of order when using for example 'creation date' as a sort option :P
This is NOT solved in version 2.0.24 -- looks like there is nothing for sorting by product_sku and no matter what else we choose in admin Configuration > Product Order Settings it will always sort by the product slug (alias).
My WORK AROUND is to set our slug (alias) so that the products sort how we like (currently have it the same as our sku). Looks like administrator/components/com_virtuemart/models/product.php needs a little work to get it sorting as we would expect.
Hope this helps.
In the file administrator\components\com_virtuemart\models\product.php replace the function public function getNeighborProducts to this below.
Works in versions from 2.0.24 with every choice of sorting in backend and also when a visitor changes his preference
happy, happy, happy ;D
<?php
public function getNeighborProducts ($product, $onlyPublished = TRUE, $max = 1) {
$db = JFactory::getDBO ();
$direction = $this->filter_order_Dir;
$app = JFactory::getApplication();
if ($app->isSite ()) {
$usermodel = VmModel::getModel ('user');
$currentVMuser = $usermodel->getUser ();
$virtuemart_shoppergroup_ids = (array)$currentVMuser->shopper_groups;
}
if(!empty($this->orderByString)){
$orderBy = $this->orderByString;
} else {
$orderBy = ' ORDER BY '.$this->filter_order.' ';
}
$joinPrice = strpos($orderBy,'product_price');
$joinCat = strpos($orderBy,'category_name');
$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 ($joinPrice) {
$q .= ' LEFT JOIN `#__virtuemart_product_prices` as pp ON p.`virtuemart_product_id` = pp.`virtuemart_product_id` ';
}
if ($joinCat) {
$q .= ' LEFT JOIN `#__virtuemart_categories_' . VMLANG . '` as `c` using (`virtuemart_category_id`) ';
}
$q .= ' WHERE `virtuemart_category_id` = ' . (int)$product->virtuemart_category_id;
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) . " ) ";
}
}
if ($onlyPublished) {
$q .= ' AND p.`published`= 1';
}
$q .= $orderBy . $direction;
$db->setQuery ($q);
if ($result = $db->loadAssocList ()) {
$key = array_search(array('virtuemart_product_id' => $product->virtuemart_product_id, 'product_name' => $product->product_name) , $result);
$neighbors = array('previous' => array($result[(int)$key-1]), 'next' => array($result[(int)$key+1]));
}
$err = $db->getErrorMsg();
if($err){
vmError('getNeighborProducts '.$err,'getNeighborProducts error');
}
return $neighbors;
}
?>
I left out the slug and ASC/DESC usage ... it now creates an array of all the products in that product's category, sorted according to the settings in the backend config (or set by visitor) and gets the key of the product your currently viewing ... automatically because the list is sorted, the key-1 is the previous record and the key+1 is the next record.
Only one problem left... when choosing a product from viewing the toplevel category, you always go to the sublevel category wherein that product is located. Therefore the productdetailnavigation is limited to that sublevel category.
P2 Peter, can you get fix for VM ver. 2.6.0 (Revision: 7816)? In this version I have the same problem, but your code doesn't work. (prev next links are not shown). Thanks!
Piombo the code is completly different now. It takes the same sql as for browsing. Just use the original files and everything should work.
Milbo, I clearly understand that the code is changed :) But I got the VM ver. 2.6.0 (Revision: 7816) from virtuemart.net - and I have this problem :( Which original files should I use? Thanks!
You did not modify it? so which ordering does not work then? It depends on the ordering.
In "sort settings" i set "order" the Product Neighbours doesn't work correctly, if i set "sort by sku, name" - everything is working correctly. Thanks!
ehrm are you aware that a product can have different ordering PER category, which you only see if you filter for one category.
The ordering which you see in the product edit is for the ordering of the child products!
I'm sorry, I did not understand.
I mean that - sreen 1 (http://pasteboard.co/2vFRGI23.png) - "product neighbours" do not work correctly
If i do like this - sreen 2 (http://pasteboard.co/2vGFFExa.png) - "product neighbours" is working fine
Quote from: Piombo on April 30, 2014, 09:34:02 AM
I'm sorry, I did not understand.
I mean that - sreen 1 (http://pasteboard.co/2vFRGI23.png) - "product neighbours" do not work correctly
If i do like this - sreen 2 (http://pasteboard.co/2vGFFExa.png) - "product neighbours" is working fine
I have almost the same problem.
If I set (in the BE) the default ordering for a category according to "name", product navigation (in the FE) works as expected. It works fine also for "price". I haven't tried all of them.
But with lots of other fields like "ordering" or "sku" (in the BE), the product navigation is wrong, either products are missing in the navigation, or there is the same product on both sides (to the left and right), simply it's not how it is supposed to be.
Maybe it has something to do with SEF URL, I use JoomSEF, this needs a bit more testing I guess.
Somebody solve this problem? I'm using VM 2.6.6 and the only way it works is using Order by Name.