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

Show recently viewed products in product details page

Started by d0ublezer0, October 11, 2012, 19:19:16 PM

Previous topic - Next topic

d0ublezer0

#30
Hello, guys! Glad to see you again  ;)
I give you another fresh and simpy solution:

<?php
$productModel 
VmModel::getModel('Product');
    
$recent_products["products"] = $productModel->getProductListing('recent'6);
if (
count($recent_products["products"]) > 1) {
        
// current product will be always in recent, so we need more than 1
    
        
?>

        <h2>Recently viewed</h2>
        <?php
        
// check current product 
        
$current_key false;
        foreach (
$recent_products["products"] as $key => $prd) {
            if (
$prd->virtuemart_product_id == $this->product->virtuemart_product_id) {
                
$current_key $key;
            }
        }
        
// and remove him from recent list
        
if ($current_key !== false) unset($recent_products["products"][$current_key]);

        
$productModel->addImages($recent_products["products"], 1);
        echo 
shopFunctionsF::renderVmSubLayout('products', array('products' => $recent_products'currency' => $this->currency));
    } }


You able to use it on product details page and anywhere else.