VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Apple7 on April 14, 2016, 23:27:39 PM

Title: List all products with attributes for each category on main page
Post by: Apple7 on April 14, 2016, 23:27:39 PM
Hi there!

VirtueMart3.0.12_Joomla_2.5.29
Custom_Fields_For_All_3.0.1

I need to list all the products of all catigories at the main page.
UPD a day after to clarify:
QuoteLike this:

CATEGORY 01
PRODUCT 01 PRODUCT 02 PRODUCT 03
PRODUCT 04 PRODUCT 05 PRODUCT 06
CATEGORY 02
PRODUCT 07 PRODUCT 08 PRODUCT 09
PRODUCT 10 PRODUCT 11 PRODUCT 12
CATEGORY 03
PRODUCT 13 PRODUCT 14 PRODUCT 15
PRODUCT 16 PRODUCT 17 PRODUCT 18
And I thought I could just publish a module for each category.
Tried creating a new module Virtuemart Products.

But it doesn't show product attributes and variants (as a default listing does).
http://ipic.su/alWqA.jpg

Is there any solution?

I'm sure that must be a common task but I couldn't find anything.
Thanks in advance.
Title: Re: List all products with attributes for each category on main page
Post by: jenkinhill on April 14, 2016, 23:41:12 PM
To show all products on a page use this url (you can add it as a Joomla menu item)  http://www.yourstoresite.com]/index.php?option=com_virtuemart&view=category&limit=5000&page=shop.browse&virtuemart_category_id=0

Attibutes& variants show on J3.5.1 VM3.0.16 as I just tested it, but I have no custom fields for all plugin.
Title: Re: List all products with attributes for each category on main page
Post by: Apple7 on April 15, 2016, 00:09:02 AM
Hi Kelvyn,

Thanks for your reply!

I already saw that method (you answered someone else).
And it does show the attributs and custom fields.

The problem is that I need to distinguish between products of different categories.
So I actually need to list all categories along with their products.

Like this:

CATEGORY 01
PRODUCT 01 PRODUCT 02 PRODUCT 03
PRODUCT 04 PRODUCT 05 PRODUCT 06
CATEGORY 02
PRODUCT 07 PRODUCT 08 PRODUCT 09
PRODUCT 10 PRODUCT 11 PRODUCT 12
CATEGORY 03
PRODUCT 13 PRODUCT 14 PRODUCT 15
PRODUCT 16 PRODUCT 17 PRODUCT 18

How do I do that?
Title: Re: List all products with attributes for each category on main page
Post by: Ghost on April 15, 2016, 07:34:51 AM
Doubt this is the best practice, but you can use the product module. Just need to customize it. You can actually use the product sublayout inside the module to achieve the same look as category view.
Title: Re: List all products with attributes for each category on main page
Post by: Apple7 on April 15, 2016, 08:22:18 AM
Thanks, Ghost.

So what do I do?

Do I still need to create a separate module for each category (as I initially planed)?
And then where do I perform the customization?
Can you give me the direct path?
Title: Re: List all products with attributes for each category on main page
Post by: Ghost on April 19, 2016, 10:02:16 AM
Create module's template override and replace its contents with this:


defined ('_JEXEC') or die('Restricted access');
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$prods = array();
$prods[0] = $products;
vmJsApi::jPrice();
echo shopFunctionsF::renderVmSubLayout('products',array('products'=>$prods,'currency'=>$currency,'products_per_row'=>$products_per_row,'showRating'=>$showRating));


You can keep header/footer text, etc. in there.
Title: Re: List all products with attributes for each category on main page
Post by: Apple7 on April 19, 2016, 10:27:30 AM
YES!
It works!

Thanks Ghost!


And how do I make it show all the products in a particular category,
not just filtered with presets (like featured, last seen etc)?
Title: Re: List all products with attributes for each category on main page
Post by: Ghost on April 19, 2016, 10:37:55 AM
For this you would have to modify/fork the module itself. It is possible to do in the layout override as well, but performance would probably be worse because the products would (probably) be loaded twice.

You need to change product query from getProductsListing to getProductsInCategory.
Title: Re: List all products with attributes for each category on main page
Post by: Apple7 on April 19, 2016, 14:41:28 PM
Thank you! It works.

I actually found a little better way.
Without changing the function, you can just add one line in file
Quotemodules/mod_virtuemart_product/mod_virtuemart_product.xml
after line 34
<option value="recent">MOD_VIRTUEMART_PRODUCT_RECENT_PRODUCTS</option>
add
<option value="false">MOD_VIRTUEMART_PRODUCT_ALL_PRODUCTS</option>

And you may want to edit language file correspondingly.
Title: Re: List all products with attributes for each category on main page
Post by: rebelhn on May 04, 2016, 04:37:53 AM
Quote from: Ghost on April 19, 2016, 10:02:16 AM
Create module's template override and replace its contents with this:


defined ('_JEXEC') or die('Restricted access');
$ratingModel = VmModel::getModel('ratings');
$showRating = $ratingModel->showRating();
$prods = array();
$prods[0] = $products;
vmJsApi::jPrice();
echo shopFunctionsF::renderVmSubLayout('products',array('products'=>$prods,'currency'=>$currency,'products_per_row'=>$products_per_row,'showRating'=>$showRating));


You can keep header/footer text, etc. in there.

Could you tell me more detail about this solution?