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

Menu/page for displaying only featured/Latest Product from category issue

Started by skhn123, September 26, 2014, 11:40:49 AM

Previous topic - Next topic

skhn123

Hello Everyone
I am Using Joomla 2.5.25 and VM 2.6.6 (cant update right now.)
My site is in local server right now.
I was searching for solution to display only featured product and new arrivals from all categories in a separate page and i fount this thread:
http://forum.virtuemart.net/index.php?topic=119323.0
I add this code  in components/com_virtuemart/views/category/tmpl/default.xml
<fields name="params">
                <fieldset name="basic">

                        <field name="product_group" type="list" default=""
                                label="product_type"
                                description="product type">
                        <option value="none">COM_VIRTUEMART_NO</option>
                        <option value="featured">COM_VIRTUEMART_FEATURED_PRODUCT</option>
                        <option value="latest">latest</option>
                        <option value="random">random</option>
                        <option value="topten">topten</option>
                        <option value="discounted">discounted</option>
                        </field> 
                </fieldset>         
</fields>

And in components/com_virtuemart/views/category/view.html.php i replace this code :
// Load the products in the given category
$ids = $productModel->sortSearchListQuery (TRUE, $categoryId);

With :
                    jimport( 'joomla.html.parameter' );
                    $application = JFactory::getApplication();
                    $menu = $application->getMenu();
                    $activeMenuItem = $menu->getActive();
                    $activeMenuParams = new JParameter($activeMenuItem->params);
                    $group = $activeMenuParams->get('product_group');
                    if ($group == 'none') $group = false;
                    if ($group!=='none' && !empty($group)) $category->category_name = $title;
                    $ids = $productModel->sortSearchListQuery (TRUE, $categoryId,$group);

And finally in administrator/components/com_virtuemart/models/product.php instead of this:
switch ($group) {
case 'featured':
$where[] = 'p.`product_special`="1" ';
$orderBy = 'ORDER BY RAND()';
break;
case 'latest':
$date = JFactory::getDate (time () - (60 * 60 * 24 * $latest_products_days));
$dateSql = $date->toMySQL ();
$where[] = 'p.`' . $latest_products_orderBy . '` > "' . $dateSql . '" ';
$orderBy = 'ORDER BY p.`' . $latest_products_orderBy . '`';
$this->filter_order_Dir = 'DESC';
break;
case 'random':
$orderBy = ' ORDER BY RAND() '; //LIMIT 0, '.(int)$nbrReturnProducts ; //TODO set limit LIMIT 0, '.(int)$nbrReturnProducts;
break;
case 'topten';
$orderBy = ' ORDER BY p.`product_sales` '; //LIMIT 0, '.(int)$nbrReturnProducts;  //TODO set limitLIMIT 0, '.(int)$nbrReturnProducts;
$where[] = 'pp.`product_price`>"0.0" ';
$this->filter_order_Dir = 'DESC';
break;
case 'recent';
$rSession = JFactory::getSession();
$rIds = $rSession->get('vmlastvisitedproductids', array(), 'vm'); // get recent viewed from browser session
return $rIds;
}

i replace the code with this:
switch ($group) {
case 'featured':
$where[] = 'p.`product_special`="1" ';
$orderBy = 'ORDER BY RAND()';
break;
case 'latest':
$date = JFactory::getDate (time () - (60 * 60 * 24 * $latest_products_days));
$dateSql = $date->toMySQL ();
$where[] = 'p.`' . $latest_products_orderBy . '` > "' . $dateSql . '" ';
$orderBy = 'ORDER BY p.`' . $latest_products_orderBy . '`';
$this->filter_order_Dir = 'DESC';
break;
case 'random':
$orderBy = ' ORDER BY RAND() '; //LIMIT 0, '.(int)$nbrReturnProducts ; //TODO set limit LIMIT 0, '.(int)$nbrReturnProducts;
break;
case 'topten';
$orderBy = ' ORDER BY p.`product_sales` '; //LIMIT 0, '.(int)$nbrReturnProducts;  //TODO set limitLIMIT 0, '.(int)$nbrReturnProducts;
$where[] = 'pp.`product_price`>"0.0" ';
$this->filter_order_Dir = 'DESC';
break;
                                        case 'discounted':
$where[] = 'pp.`override`!="0" OR pp.`product_discount_id` != "0"';
$orderBy = 'ORDER BY RAND()';
break;
case 'recent';
$rSession = JFactory::getSession();
$rIds = $rSession->get('vmlastvisitedproductids', array(), 'vm'); // get recent viewed from browser session
return $rIds;
}


I follow the process and its working the only issue i am having right now is when i am login i see these error which is happening because of hack i think :
vmError: exeSortSearchListQuery Unknown column 'pp.product_price' in 'where clause' SQL=SELECT p.`virtuemart_product_id` FROM `glre2_virtuemart_products` as p INNER JOIN `glre2_virtuemart_products_en_gb` as l using (`virtuemart_product_id`) LEFT JOIN `glre2_virtuemart_product_shoppergroups` as ps ON p.`virtuemart_product_id` = `ps`.`virtuemart_product_id` LEFT JOIN `glre2_virtuemart_product_categories` as pc ON p.`virtuemart_product_id` = `pc`.`virtuemart_product_id` WHERE ( p.`published`="1" AND `pc`.`virtuemart_category_id` > 0 AND ( `ps`.`virtuemart_shoppergroup_id`= "2" OR `ps`.`virtuemart_shoppergroup_id` IS NULL ) AND pp.`product_price`>"0.0" ) group by p.`virtuemart_product_id` ORDER BY p.`product_sales` DESC LIMIT 0, 2

And when try to search a product i get all the product in result page instead of searched products.

I know its not suggested by virtuemart but i need these functions so please help me fix this.

Thanks
Sadique

skhn123

I have added some more information now. so please can anyone help me on this.

Thanks
Sadique