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

SOLVED: productsnapshots output order when displaying a row of products

Started by donmarvin, July 13, 2008, 03:06:03 AM

Previous topic - Next topic

donmarvin

VM 1.1; J1.5

When listing a row of product ID's like this:

{product_snapshot:id=161|160|157|155}

the output always returns the row in order of product ID, not the order you put it in.  For example, the products in the code above would be shown in this order:

155, 157, 160, 161

To correct this, in plugins/content/vmproductsnapshots.php, around line 160, directly after:   

$db->query( $q ) ;

insert this code:

   
    $ordering=explode(",",$params['id']);
    $db->recordx = array();
    foreach($ordering as $key1 => $value1) {
        foreach ($db->record as $key2 => $value2) {
            $a = "'" . $value2->product_id . "'";
            if ($a == $value1) {
                $db->recordx[] = $value2;
            }
        }
    }
    foreach($db->record as $key => $value) {
        $db->record[$key] = $db->recordx[$key];
    }


This should display the products in the order in which you designated.