Skip to main content

order by cheapest price!

More
14 years 2 months ago #57655 by papaleksi
Hi again i use the starter edition and i need to show my products order by cheapest (lower price)
i do not want to be a choice - filter i just want to show my products from cheapest to more expensive.
Thank you again!

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #57679 by Xavier
Replied by Xavier on topic Re: order by cheapest price!
Hi papaleksi,

To change the ordering, you have to edit the file: YourSite/components/com_hikashop/views/product/view.html.php
And in the "listing()" function edit the ordering in the SQL Request.

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #57706 by papaleksi
Thank you for your answer do you mean to change ....
if($this->params->get('product_order')=='ordering'){....


and change "ordering" with "product_price"?

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago - 14 years 2 months ago #57757 by Xavier
Replied by Xavier on topic Re: order by cheapest price!
Hi papaleski,

You can add this line:
Code:
$order = ' ORDER BY c.price_value ASC';

Just after:
Code:
if(!empty($pageInfo->filter->order->value)){ $order = ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir; }

And replace the line:
Code:
$query = $select2.' FROM '.$b.$a.$on.' WHERE '.implode(' AND ',$filters).$order;
By:
Code:
$query = $select2.' FROM '.$b.$a.$on.' LEFT JOIN '.hikashop_table('price').' AS c ON c.price_product_id=b.product_id WHERE '.implode(' AND ',$filters).$order;
Last edit: 14 years 2 months ago by Xavier.
The following user(s) said Thank You: FranksBank, papaleksi

Please Log in or Create an account to join the conversation.

More
14 years 2 months ago #57906 by papaleksi
Hi xavier i will try your solution thank you for you precious time and help

Please Log in or Create an account to join the conversation.

More
14 years 4 weeks ago #62764 by beeldstudio
Hello guys!
I think that not good solution overwrite files of core

I have suggestion.

we have event 'onBeforeProductListingLoad'. And just need add more parameters that we can send in plugin.
Now we have only this:
$dispatcher->trigger( 'onBeforeProductListingLoad', array( & $filters, & $order, &$this) );

and if we add also '$select,$select2, $a, $b, $on,' then we could make this changes in plugins without changes core files

Best regards,
Alex

Please Log in or Create an account to join the conversation.

More
14 years 4 weeks ago #62860 by nicolas
Unfortunately, onBeforeProductListingLoad is triggered from other files where $select,$select2, $a, $b, $on are not available.
So that would break other things in HikaShop.

Another solution is to create a system plugin and paste the whole ProductViewProduct class of the view.html.php file in it.
The system will automatically use your class instead of the HikaShop core class.

Please Log in or Create an account to join the conversation.

More
12 years 8 months ago #139240 by nicolas
Instead of that code, you should use that one in order to avoid some conflict with potential filters :

You can add this line:
Code:
$order = ' ORDER BY price_join.price_value ASC';

Just after:
Code:
if(!empty($pageInfo->filter->order->value)){ $order = ' ORDER BY '.$pageInfo->filter->order->value.' '.$pageInfo->filter->order->dir; }

And replace the line:
Code:
$query = $select2.' FROM '.$b.$a.$on.' WHERE '.implode(' AND ',$filters).$order;
By:
Code:
$query = $select2.' FROM '.$b.$a.$on.' LEFT JOIN '.hikashop_table('price').' AS price_join ON price_join.price_product_id=b.product_id WHERE '.implode(' AND ',$filters).$order;

Please Log in or Create an account to join the conversation.

Time to create page: 0.226 seconds
Powered by Kunena Forum