News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Product navigation problem with override price

Started by restodo, September 11, 2017, 04:23:10 AM

Previous topic - Next topic

restodo

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!

Jörgen

Try and switch to template protostar.

regards Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Ghost

#2
VM doesn't take price overrides, taxes and discounts into account when sorting by price. Only base price is used.

restodo

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.

restodo

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.

restodo

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.



restodo

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];
}