News:

Looking for documentation? Take a look on our wiki

Main Menu

List all products with attributes for each category on main page

Started by Apple7, April 14, 2016, 23:27:39 PM

Previous topic - Next topic

Apple7

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.

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Apple7

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?

Ghost

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.

Apple7

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?

Ghost

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.

Apple7

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)?

Ghost

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.

Apple7

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.

rebelhn

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?