- Posts: 25
- Thank you received: 0
order by cheapest price!
14 years 2 months ago #57655
by papaleksi
order by cheapest price! was created 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!
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.
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.
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.
14 years 2 months ago #57706
by papaleksi
Replied by papaleksi on topic Re: order by cheapest price!
Thank you for your answer do you mean to change ....
if($this->params->get('product_order')=='ordering'){....
and change "ordering" with "product_price"?
if($this->params->get('product_order')=='ordering'){....
and change "ordering" with "product_price"?
Please Log in or Create an account to join the conversation.
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:
Just after:
And replace the line:
By:
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;
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.
14 years 2 months ago #57906
by papaleksi
Replied by papaleksi on topic Re: order by cheapest price!
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.
Less
More
- Posts: 6
- Thank you received: 0
14 years 4 weeks ago #62764
by beeldstudio
Replied by beeldstudio on topic Re: order by cheapest price!
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
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.
14 years 4 weeks ago #62860
by nicolas
Replied by nicolas on topic Re: order by cheapest price!
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.
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.
12 years 8 months ago #139240
by nicolas
Replied by nicolas on topic Re: order by cheapest price!
Instead of that code, you should use that one in order to avoid some conflict with potential filters :
You can add this line:
Just after:
And replace the line:
By:
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;
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.349 seconds