VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: thefbi on April 27, 2020, 09:05:41 AM

Title: Specific category product ordering
Post by: thefbi on April 27, 2020, 09:05:41 AM
Hello,

i search a way to order my product "by order" in ONLY one category. Actually, i use the alphabetic ordering for all the site.
I have seen many post in this forum but no solution...

Any idea ?

Regards

VM 3.6.10 10211
Joomla 3.9.18
Title: Re: Specific category product ordering
Post by: GJC Web Design on April 27, 2020, 09:40:47 AM
make a manual url menu to it with the required ordering?

index.php?option=com_virtuemart&view=category&virtuemart_category_id=13&keyword=&Itemid=101&orderby=product_sku

or perhaps a local redirect in the template over ride

if catid == 13
redirect to index.php?option=com_virtuemart&view=category&virtuemart_category_id=13&keyword=&Itemid=101&orderby=product_sku
Title: Re: Specific category product ordering
Post by: thefbi on April 27, 2020, 10:37:43 AM
Hello,
Thank you. But i have the default category on the VM main page + a menu extension tierce. So i think the template override will be better.
Can you please be a little bit more precise for the code i have to put and where i have to put this code ?

I see in the category configuration i can select a template override. Is it this in your mind ? Can create a template override with this function, and after, i can select it in the cat config ?
Title: Re: Specific category product ordering
Post by: thefbi on April 27, 2020, 10:41:17 AM
Is it possible to create another product layout with a specific ordering, and after that, use it independently of the default order ?
Title: Re: Specific category product ordering
Post by: GJC Web Design on April 27, 2020, 12:01:15 PM
QuoteIs it possible to create another product layout with a specific ordering, and after that, use it independently of the default order ?

no  .. because the order is already set by the model


$category_id  = vRequest::getInt ('virtuemart_category_id', 0);
$orderby  = vRequest::getString ('orderby', '');
if ($category_id == 13 && !$orderby){
$uri = JUri::getInstance();
$url = $uri->toString().'&orderby=product_sku';
header("Location: " .$url);
exit();
}

Title: Re: Specific category product ordering
Post by: thefbi on April 27, 2020, 17:28:59 PM
OK thank you. I will try this next day and i come back.
Last question, can i put this code in my template css override ? Or i have to put it in a specific VM view ?
Title: Re: Specific category product ordering
Post by: GJC Web Design on April 27, 2020, 18:37:52 PM
over ride of components\com_virtuemart\views\category\tmpl\default.php
Title: Re: Specific category product ordering
Post by: thefbi on April 28, 2020, 13:31:36 PM
Hello,
that dosent work... I have the error : ERR_TOO_MANY_REDIRECTS
And if i check the url, i have

https://boutique.energie-sante.ch/materiel-therapeutique-aimants-chromotherapie/chromoth%C3%A9rapie-1&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku&orderby=product_sku

Regards
Title: Re: Specific category product ordering
Post by: Studio 42 on April 28, 2020, 18:04:11 PM
Check if the ordering by product_sku is active in the virtuemart config.
Else it try to set &orderby=product_sku in the URL, product_sku  is not valid then remove it and redirect again and try to set &orderby=product_sku ....
Title: Re: Specific category product ordering
Post by: thefbi on April 28, 2020, 18:27:22 PM
It dosent work. I will to order by "order" and not product_sku...

But i thing it is SEF causing problem ?

If i put in my url : https://boutique.energie-sante.ch/index.php?option=com_virtuemart&view=category&virtuemart_category_id=47&orderby=order
It render good.

But with the code in the template override, the output url is with sef and it dosent work.
But i see another thing, that if i am in my category and modify the selector and put order by "order", in my url i have : https://boutique.energie-sante.ch/materiel-therapeutique-aimants-chromotherapie/chromoth%C3%A9rapie-1/by,ordering?keyword=

I dont know if is it important or relevant ?
Title: Re: Specific category product ordering
Post by: thefbi on April 28, 2020, 18:40:07 PM
I just tested on a test site, if i desactivate the sef, it work with orderby=order with your code.
But not with sef...
Title: Re: Specific category product ordering
Post by: thefbi on April 28, 2020, 18:58:41 PM
So i have modified your code and tested on my test site, it work but i dont know if it is correct or not :

<?php
$category_id  
vRequest::getInt ('virtuemart_category_id'0); 
$orderby  vRequest::getString ('orderby''');
if (
$category_id == 47 && !$orderby){
$uri JUri::getInstance();
$url $uri->toString().'/by,ordering?keyword=';
header("Location: " .$url);
exit();
}
?>

Title: Re: Specific category product ordering
Post by: pinochico on April 28, 2020, 19:08:09 PM
Quote$url = $uri->toString().'/by,ordering?keyword=';

I think yes.
But for another language we use translated values for "by" and "ordering". Then I think not function. The values I think is language constant in SEF componeent (I remember then see inside Artio JoomSEF).
Maybe better use language constant at first?
Title: Re: Specific category product ordering
Post by: Studio 42 on April 28, 2020, 19:16:40 PM
Try to change
'&orderby=product_sku'
to
'?orderby=product_sku'
Title: Re: Specific category product ordering
Post by: pinochico on April 28, 2020, 19:23:46 PM
delete
Title: Re: Specific category product ordering
Post by: thefbi on April 28, 2020, 19:40:03 PM
Quote from: Studio 42 on April 28, 2020, 19:16:40 PM
Try to change
'&orderby=product_sku'
to
'?orderby=product_sku'

YES ! It work like this.
Thank you very much.
Title: Re: Specific category product ordering
Post by: pinochico on April 28, 2020, 20:18:42 PM
Thanks Patrick :)