VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: restodo on September 11, 2017, 04:23:10 AM

Title: Product navigation problem with override price
Post by: restodo on September 11, 2017, 04:23:10 AM
Hi,

I'm having a problem with product navigation when some product has an override price.

For example I have:

Product 1 : Cost price $ 7509 / Override $ 0 / Disabled
Product 2 : Cost price $ 7933 / Override $ 0 / Disabled
Product 3 : Cost price $ 13499 / Override $ 8499 / Overwrite final
Product 4 : Cost price $ 8549 / Override $ 0 / Disabled

A correct product navigation from lower to higher price should be: Product 1 -> Product 2 -> Product 3 -> Product 4
But the product navigation is: Product 1 -> Product 2 -> Product 4 -> Product 3

Someone could tell me how can I solve this problem?

I've been looking in /administrator/components/com_virtuemart/models/product.php and try to modify getNeighborProducts unsuccessfully

I'm using Joomla 3.7.5 and Virtuemart 3.2.4


Thanks!
Title: Re: Product navigation problem with override price
Post by: Jörgen on September 11, 2017, 06:41:25 AM
Try and switch to template protostar.

regards Jörgen @ Kreativ Fotografi
Title: Re: Product navigation problem with override price
Post by: Ghost on September 11, 2017, 10:24:43 AM
VM doesn't take price overrides, taxes and discounts into account when sorting by price. Only base price is used.
Title: Re: Product navigation problem with override price
Post by: restodo on September 11, 2017, 15:49:37 PM
Quote from: Jörgen on September 11, 2017, 06:41:25 AM
Try and switch to template protostar.

regards Jörgen @ Kreativ Fotografi

I've tried protostar template and same result.
Title: Re: Product navigation problem with override price
Post by: restodo on September 11, 2017, 15:51:34 PM
Quote from: Ghost on September 11, 2017, 10:24:43 AM
VM doesn't take price overrides, taxes and discounts into account when sorting by price. Only base price is used.

VM has problem with price overrides only in product navigation nor in category view or other listing.
Then I think VM take price overrides when sorting by price in other places than product navigation.
Title: Re: Product navigation problem with override price
Post by: restodo on September 12, 2017, 15:15:36 PM
Nobody?

I've found that this line is responsible of making a correct listing of products in a category.
$ff_select_price = ' , IF(pp.override, pp.product_override_price, pp.product_price) as product_price ';

But I can not find how to solve the navigation problem in products.


Title: Re: Product navigation problem with override price
Post by: restodo on September 13, 2017, 19:13:54 PM
I've solved the problem modifying the following functions.


public function getNeighborProducts ($product, $onlyPublished = TRUE, $max = 1) {

LINE 1893

if($orderByNameMain=='product_price'){
     if(isset($product->prices['product_price'])){
         //$product->prices['product_price'];
         $product->product_price = $product->prices['product_override_price']; // New Line //
     } else {
         $product->product_price = 0.0;
     }
}


LINE 1915

//$whereorderByName = $orderByNameMain;
if ($orderByNameMain=='product_price'){ // New Lines //
    $whereorderByName = ' product_override_price';
    $orderByName = str_replace('product_price', 'product_override_price', $orderByName);
} else {
    $whereorderByName = $orderByNameMain;
}
               
            

public function store (&$product) {

LINE 2132

//$pricesToStore['product_override_price'] = $data['mprices']['product_override_price'][$k];
if ((int)$data['mprices']['override'][$k] == 1) {  // New Lines //
   $pricesToStore['product_override_price'] = $data['mprices']['product_override_price'][$k];
} else {
   $pricesToStore['product_override_price'] = $data['mprices']['product_price'][$k];
}