News:

Support the VirtueMart project and become a member

Main Menu

Menu item to list products with discount

Started by sandomatyas, August 13, 2018, 14:30:57 PM

Previous topic - Next topic

sandomatyas

Is it possible to create a menu item to display all of the products with, discount using the standard category layout + products sublayout?
I'm sure I can create a category for that but it has some disadvatages (needs manual mainentance, can modify the url, etc), so I'm looking for a more elengant method.

Studio 42

Check https://shop.st42.fr/en/products/products-any-ways.htm
If it does not meet your need, i can perhaps add a new "discount" filter.

StefanSTS

Hello,

I guess I would make another sublayout products_discounted.php that would be a copy of products.php.
You can choose the sublayout in the category menu item.

Inside of the new sublayout in the foreach loop call the data on the price for the product and see, if the override price is given (if you do it via override price).
If the price is there, show the product, if not, try the next.

That's the short version.

Hope it helps
Stefan

--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Studio 42

Quote from: StefanSTS on August 13, 2018, 21:45:03 PM
That's the short version.
And the long version ?
Really you dont have the filter in Virtuemart core product model(or i missed it), so it's simply not possible

StefanSTS

#4
The long version is:

Put this into the products.php and rename it like said above, make a menu item and choose the sublayout.

if ($product->prices['discountAmount'] < 0) {
    Product DIV
}

And then it looks like this:

http://test.sts-hosting.de/meinkonto/index.php/en/discounts

This example on the test site doesn't have the products in one row properly, but I just had ten minutes to test, sorry. But you see the two products that I gave a discount via override.

Stefan

PS. I would put the discounted products in a category "discounted" and do the extra work if there are a lot of products in the shop, though.
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

Studio 42

OK, you are displaying 2 products from a list, but you can not load 100 products and get the 5 products at a reduced price because you load 100 full products and the result is an overload of memory(and perhaps a warning from virtuemart because you loaded to many product)
in theory it works but not in practice

StefanSTS

It works in practice if you have less products or if you reduce it to categories that have not too many products.

It does not work in practice if you have lots of products that's why I said I would use a category "discounted" instead.

You have to measure the load it takes on your system.
If it works or not, cannot be said without knowing the shop. If it is a simple shop, this is one simple solution to the problem.

Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

sandomatyas

Any updates on this yet? I'm eager to create a menu item for SALE PRODUCTS that isn't dependent on a specific category.