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

How to add functionality to show discounted products in default products module

Started by bardius, December 22, 2011, 14:56:26 PM

Previous topic - Next topic

bardius

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.
George Bardis
Team Leader / Senior Web Developer
http://www.bardis.info

styleman32

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.

sondarva_niraj

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

Virtuemart is like Girlfriend ! eats out your brain, yet you can't resist to love it..

bytelord

Hello and Thank you for the share!

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

Nikos
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

borro

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

Wish you happiness!

clarckconnect

Solve it thanks :D.

mkt

Hi, this method dont work with vm 2.6.6. Please help, who did "sales" in vm 2.6.6.

MC Web Design

For vm 2.6.6 use 'pp.`product_override_price`>"0.0" ' instead of pp.`override`="1" || pp.`product_discount_id` IS NOT null'.

thebit

Hi,
I followed all this tips but mod_virtuemart_product doesn't shows the field "discounted" in dropdown menu.

VM version: 2.6.14


beny.rfg

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