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

Featured Products Fixed Sort Order

Started by woogygun, August 15, 2012, 09:34:19 AM

Previous topic - Next topic

woogygun

Hi there

Is it possible to edit the php of the featured products layout so that the products sort by a fixed order and remain that way, instead of everytime the page refreshes the featured items shuffling themselves around.

I'd like to sort by SKU. for example 001,002,003,004

and it must stay that way.

cmb

Apparently the ordering for the Featured Products is set at line 406 of the \administrator\components\com_virtuemart\models\product.php file. You could override that file and then modify the code by replacing
$orderBy = 'ORDER BY RAND()';
with another $orderBy statement that includes a reference to the product_sku column of the <database-prefix>_virtuemart_products database table.

VirtueMart 2.0.12
Charles

stemithy

Here's my solution:

I used the product URL field placing numbers 1 - 9 on the featured products I wanted to sort.  You could use any product specific field
I know it's a hack, but it's simple stable and only requires overriding a view:

Override the default_products.php view.  Just after "foreach ($this->products as $type => $productList ) {" (line 7)  Add this:

foreach ($productList as $psort) {
$pnew[$psort->product_url-1] = $psort;
}
ksort($pnew);

Then change
"foreach ( $productList as $product )" (line 26) 
-to-
"foreach ($pnew as $product ) {"

Hope this helps

design609