Sorry I have a lot of questions today.
I notice that the orderby price option is not using the override price (looks like it is perhaps using baseprice?), is there a way I can fix this?
(which file should I look in?)
I've got the same question.. this should be included already. Does anyone have a fix for this?
Hi. In my sight it works well. It even can order direct discount)
in administrator/components/com_virtuemart/models/product.php You should make changes
1. add $selectByPrice=""; and
in switch ($this->filter_order) case 'product_price': change width my
you should replace it
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 'pc.ordering':
$orderBy = ' ORDER BY `pc`.`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->filter_order . ' ';
}
else {
$this->filter_order_Dir = '';
}
break;
}
replace with
$selectByPrice="";
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 'pc.ordering':
$orderBy = ' ORDER BY `pc`.`ordering` ';
$joinCategory = TRUE;
break;
case 'product_price':
//$filters[] = 'p.`virtuemart_product_id` = p.`virtuemart_product_id`';
//$orderBy = ' ORDER BY `product_price` ';
$orderBy = ' ORDER BY `pr_price` ';
$selectByPrice = "
,(CASE
WHEN (pp.override=1)
THEN pp.`product_override_price`
WHEN ISNULL(pp.`product_discount_id`) OR pp.`product_discount_id` = 0
THEN pp.`product_price`
WHEN pp.`product_discount_id` > 0 AND calc.`calc_value_mathop` = '-'
THEN (pp.`product_price` - calc.`calc_value`)
WHEN pp.`product_discount_id` > 0 AND calc.`calc_value_mathop` = '-%'
THEN ROUND(pp.`product_price` - (pp.`product_price` * (calc.`calc_value`/100)))
ELSE pp.`product_price`
END) AS pr_price ";
$joinPrice = TRUE;
break;
case 'created_on':
$orderBy = ' ORDER BY p.`created_on` ';
break;
default;
if (!empty($this->filter_order)) {
$orderBy = ' ORDER BY ' . $this->filter_order . ' ';
}
else {
$this->filter_order_Dir = '';
}
break;
}
2. Then
if ($joinPrice == TRUE) {
$joinedTables .= ' LEFT JOIN `#__virtuemart_product_prices` as pp ON p.`virtuemart_product_id` = pp.`virtuemart_product_id` ';
}
replace with
if ($joinPrice == TRUE) {
$joinedTables .= ' LEFT JOIN `#__virtuemart_product_prices` as pp ON p.`virtuemart_product_id` = pp.`virtuemart_product_id` ';
$joinedTables .= ' LEFT JOIN #__virtuemart_calcs AS calc ON (calc.calc_kind="DATax" OR calc.calc_kind="DBTax") AND calc.published=1 AND pp.`product_discount_id` = calc.`virtuemart_calc_id`';
}
3. And add my selectByPrice item for right order) in $select
just replace it
if ($joinLang) {
$select = ' l.`virtuemart_product_id` FROM `#__virtuemart_products_' . VMLANG . '` as l';
$joinedTables = ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)';
}
else {
$select = ' p.`virtuemart_product_id`FROM `#__virtuemart_products` as p';
$joinedTables = '';
}
with it
if ($joinLang) {
$select = ' l.`virtuemart_product_id` '.$selectByPrice.' FROM `#__virtuemart_products_' . VMLANG . '` as l';
$joinedTables = ' JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)';
}
else {
$select = ' p.`virtuemart_product_id` '.$selectByPrice.' FROM `#__virtuemart_products` as p';
$joinedTables = '';
}
I hope it helps for you.