VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: bardius on December 22, 2011, 14:56:26 PM

Title: How to add functionality to show discounted products in default products module
Post by: bardius on December 22, 2011, 14:56:26 PM
I wanted to add functionality to present discounted products in a module so I figured out a way to do that with the included products module and a small core hack at the products model. Hence with a template of the module view you can create a scroller or a slideshow of discounted products.

Firstly I added an option for discounted products at modules/mod_virtuemart_product/mod_virtuemart_product.xml (line 26)

<option value="discounted">MOD_VIRTUEMART_PRODUCT_DISCOUNTED</option>

Then I edited the product model file to add functionality for discounted "group". At administrator/components/com_virtuemart/models/product.php I modified function sortSearchListQuery (line 168)

//administrative variables to organize the joining of tables
$joinCategory    = false ;
$joinMf       = false ;
//GEORGE BARDIS adding module support to list discounted products
if($group == 'discounted')
{
   $joinPrice       = true ;
}
else
{
   $joinPrice       = false ;         
}
//Bardis ends
$joinCustom      = false ;

So I can enable the Join of the prices table if i want to select the discounted products.

Afterwards I add the discounted products "group" case along with the other cases under switch($group)

//GEORGE BARDIS adding module support to list discounted products
case 'discounted';
   $where[] = 'pp.`override`="1" || pp.`product_discount_id` IS NOT null';
   $orderBy = '';
//BARDIS ends

And that is all. You choose from the module options to show the discount products and all works just fine.

Using same logic you can create a "group" to list products based on any product property or even an attribute.

Hope it will get handy.
Title: Re: How to add functionality to show discounted products in default products module
Post by: styleman32 on May 19, 2012, 15:27:09 PM
Hello,
Thank you for the tip. But although I did exactly as instructed I can not find the module "discounted" anywhere in the modules or anywhere else. May I looking in the wrong section or the module haw not installed?
Thank you,
Spiros Kostopoulos.
Title: Re: How to add functionality to show discounted products in default products module
Post by: sondarva_niraj on July 11, 2012, 13:42:11 PM
Please don't forget to add

<option value="discounted">MOD_VIRTUEMART_PRODUCT_DISCOUNTED</option>

on line around 107 also in mod_virtuemart_product.xml file.. we have to put it in two places.. first one as shown above.

and don't forget to define english word for 'discounted' in \language\en-GB\en-GB.mod_virtuemart_product.ini file

as per,

MOD_VIRTUEMART_PRODUCT_DISCOUNTED="Discounted"

and try pp.`product_discount_id` > 0 condition instead of  pp.`override`="1" || pp.`product_discount_id` IS NOT null'; if you migrated from 1.9 to 2.0

Title: Re: How to add functionality to show discounted products in default products module
Post by: bytelord on July 12, 2012, 11:33:14 AM
Hello and Thank you for the share!

That feature should be embedded in the standard installation of VM product modules.

Nikos
Title: Re: How to add functionality to show discounted products in default products module
Post by: borro on April 02, 2013, 16:05:19 PM
Thank you. I'll try. Do you add this:
Quote from: bardius on December 22, 2011, 14:56:26 PM
//GEORGE BARDIS adding module support to list discounted products
case 'discounted';
   $where[] = 'pp.`override`="1" || pp.`product_discount_id` IS NOT null';
   $orderBy = '';
//BARDIS ends
in the same administrator/components/com_virtuemart/models/product.php file?

Discounted are that products, which have overrideprice >0. Am I right? I'm using VM 2.0.18a

Title: Re: How to add functionality to show discounted products in default products module
Post by: clarckconnect on July 10, 2013, 20:15:25 PM
Solve it thanks :D.
Title: Re: How to add functionality to show discounted products in default products module
Post by: mkt on September 05, 2014, 06:57:06 AM
Hi, this method dont work with vm 2.6.6. Please help, who did "sales" in vm 2.6.6.
Title: Re: How to add functionality to show discounted products in default products module
Post by: MC Web Design on October 19, 2014, 19:40:50 PM
For vm 2.6.6 use 'pp.`product_override_price`>"0.0" ' instead of pp.`override`="1" || pp.`product_discount_id` IS NOT null'.
Title: Re: How to add functionality to show discounted products in default products module
Post by: thebit on February 04, 2015, 16:53:30 PM
Hi,
I followed all this tips but mod_virtuemart_product doesn't shows the field "discounted" in dropdown menu.

VM version: 2.6.14
Title: Re: How to add functionality to show discounted products in default products module
Post by: kalozpepi on September 18, 2016, 19:38:51 PM
Hello,
thank you for this trick!

Awesome!  ;D
Title: Re: How to add functionality to show discounted products in default products module
Post by: beny.rfg on October 02, 2016, 11:48:12 AM
Hello!

I need to modify this upgrade. I need to Display products based on the data in the db table virtuemart_calcs, but I can not get into this table.

If I understand correctly, that  'pp.`product_override_price`>"0.0" ';  for db table virtuemart_product_prices (pp is indetifier for Product_Prices)

so that not working, what I mean:
$ Where [] = 'pp.`product_discount_id` > 0 && c.`published` = "1" '; for db table virtuemart_calcs ...(c is as identifier Calcs)?

Sorry, I'm a beginner in php ..

Thanks, Petr