VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: gpessoa on February 27, 2021, 20:47:22 PM

Title: show categored products on product detail page
Post by: gpessoa on February 27, 2021, 20:47:22 PM
Hi ppl
I want to show categored products on product detail page...
I already create a few unpublished categories and  assembled a products to them...
Created a module to show de products and added it to the category (Modules Anywhere)
Now, please, I need, a cut and past code to add to my product detail template in order to call unpublished categories, filter by assigned products...
Can someone help me?
Thanks in advanced!
Title: Re: show categored products on product detail page
Post by: pinochico on February 27, 2021, 21:06:18 PM
I don;t understand really, but if you need show module on prouctdetail you can do it step by step by tutorial:
https://regularlabs.com/extensions/modulesanywhere/tutorial
and add module inside productdetail.php layout in your template override.

And the best option is use with togetther https://regularlabs.com/extensions/advancedmodulemanager and setup "show on product detail"
Title: Re: show categored products on product detail page
Post by: gpessoa on February 27, 2021, 22:04:56 PM
I already use "Modules anywhere" and was this that I already set up on my umpublished categories!

The idea is to have this categories to show product related colours...
and, by clicking on it, the product changes to selected one!

I don't use custom fields, as they are very difficult to handle with CSVI.
Title: Re: show categored products on product detail page
Post by: pinochico on February 28, 2021, 05:32:06 AM
I am not a native speaker of English.
Unfortunately, if you use exclamation points ("!"), my google translate will not improve and will not translate what you thinking - but I accept your apology :D.
Attaching images is much better and it fully complies with the rules for creating a request on this forum.

I can imagine that using CSVImproved can be a bit difficult to import parameters (I've been using it since VM1), but for the whole functionality of the e-shop for customers, the use of customfields is much better.
Because customers don't want to create many clicks and redirects, they want information right away - you'll know in GA how long a customer stays on one page - if they don't buy by then, they're going to another e-shop.

Therefore, for choosing a color variant, it is best if the price, main picture, description and the product itself change in real time (ajax) on the product detail using custom files or using child products and the customer is not redirected anywhere.
There are many ways to do this, described here on the forum or in the virtuemart documentation and you can also find them on the virtuemart demo (of course there is no product display using an image, but a dropdown - but even so it is still a much better option to create an eshop, because the main image you can change in real time and your customers will be grateful).

Or, you can display color variants as related products and move the code for related products in the product detail template and place it in the productdetail.php template after the sublayout price.php to match your image.

But I can also imagine that you want to display products as your idea and display color variants using your displaying products from the non published category.

Then what I wrote earlier is that after sublayout price.php you place the code to display the module for displaying products from the category (I assume you use the virtuemart product module) according to the documentation on RegularLabs - generally something like

{module 241}

Try and test the final solution self pls.

Or you can use a paid extension (breakdesign.com, shop42.fr) to display the required information.
Title: Re: show categored products on product detail page
Post by: gpessoa on February 28, 2021, 16:31:37 PM
Using unpublished categories (for me) is the best way as it shows every detail of the selected product (stock, maybe different related products or a popup, etc)
and to manage it, you only have to assign the category to the desire product on your local DB, and let CSVI do the rest....
also, when a product is unpublished, it automatically disappear from it, means zero work.

About display a module in product details template:
It can't be done that way, unless I create a different template override to each one hidden category, and they are a lot (more than 100).... and then assign each one to the respective products.

Maybe the best way is create a sublayout (related-colours.php) to do this, without modules.
Title: Re: show categored products on product detail page
Post by: pinochico on February 28, 2021, 18:17:57 PM
If I had to deal with this at the customer's e-shop and wanted to use the display of products from the unpulled category on the product detail,
I would use the virtuemart product extended module, add a condition for displaying products from an unpublished category and then for each product I would enter the ID of the unpublished category in the administration with a customfield.

So the module would load me only those products that I want to display on the product detail and which would be from the relevant unpublished category.

But it would mean:
- add products to an unpublished category
- create unpublished categories
- add an unpublished category ID to each product using a customfield
- using PHP directly in the file productdetail.php or using the module Virtuemart Product Extended to complete the condition for displaying products from the category

Isn't it a lot of work as opposed to a solution if I used related products?
Title: Re: show categored products on product detail page
Post by: gpessoa on February 28, 2021, 21:30:04 PM
That's almost what I asked for on my initial post.
The only thing I don't want is using custom fields...

So, to do this I only need a condition php code to echo {module related-colours}
Something like:

<div class="related-colours">
  <?php //shows related unpublished category products

php code with a Condition to relevant unpublished category where the product is assigned, to show below module.


  {module related-colours}
  ?>
</div>

Title: Re: show categored products on product detail page
Post by: pinochico on February 28, 2021, 21:53:45 PM
ok, send me info on skype :)
Title: Re: show categored products on product detail page
Post by: GJC Web Design on March 01, 2021, 19:28:23 PM
try


<?php
if (VmConfig::get('category', 0) == 0) {   
if (!empty($this->product->category)){   

echo '{module related-colours}';

}
}
?>

though I haven't read the whole thread at least this syntax is correct
Title: Re: show categored products on product detail page
Post by: gpessoa on March 01, 2021, 20:16:00 PM
It doesn't filter properly!
it shows the products on the category you are in , even on the product that doesn't have any unpublished category assigned!
Should be only products from the assigned unpublished category.
Title: Re: show categored products on product detail page
Post by: Studio 42 on March 02, 2021, 10:39:58 AM
Why aren't you using the child variants?
For more complex case, i have this product customfield plugin in my shop https://shop.st42.fr/en/products/extra-product.htm
Title: Re: show categored products on product detail page
Post by: pinochico on March 02, 2021, 12:05:41 PM
to patrik:

QuoteWhy aren't you using the child variants?

I think I send recommendation about child product:
http://forum.virtuemart.net/index.php?topic=146401.msg520912#msg520912
Title: Re: show categored products on product detail page
Post by: gpessoa on March 02, 2021, 12:54:19 PM
I don't use Childs and I don't want to change my all structure to do this...

About extra products, It looks like a cross selling, it seems a good future for later analyses and update!

Now, I just need a php help to created relationship between products and unpublished category this products are in!
So far, I get this:

<div class="related-colours">
<?php //shows related colours by unpublished category products
if (VmConfig::get('category'0) == 0) {   
if (!empty(
$this->product->category)){   

 echo 
'{module related-colours}';

}
}
?>


it gives me the related products from the category you are in,
but I need it to be from the unpublished category that the product belongs!
and also, if there are no unpublished category shows nothing.

EDITED:
now, I need it to be from the last category tree that the product belongs!
Title: Re: show categored products on product detail page
Post by: pinochico on March 02, 2021, 16:26:33 PM
we are connected by skype and

I figured out how to do it, I just need to check it out and we agreed to look into it on Thursday as part of paid support, because the work schedule for this week has already been created and I have to serve many clients every day and they are waiting for corrections and results - I can't be a "friend on the phone" for everyone (as in the American game "risk is profit" - when someone calls and I quit my job and devote myself to it immediately).

And yes, we know about it, we won't use children to not have to redo the whole eshop.
Title: Re: show categored products on product detail page
Post by: gpessoa on March 02, 2021, 16:50:58 PM
Quote from: pinochico on March 02, 2021, 16:26:33 PM
we are connected by skype and

yes, we are ...
to know if your module does the job without any change!
but, if it doesn't, I need other solution...
Title: Re: show categored products on product detail page
Post by: gpessoa on March 02, 2021, 18:50:53 PM
Is there a way to echo this module to show products filter from the last category tree that the product is in?

This it will do for me!
Maybe better then using unpublished categories condition.
Title: Re: show categored products on product detail page
Post by: Studio 42 on March 03, 2021, 11:52:05 AM
Quote from: gpessoa on March 02, 2021, 18:50:53 PM
Is there a way to echo this module to show products filter from the last category tree that the product is in?

Have you try to show the standard product module ? You can choose to show product from current category, so it should work
Title: Re: show categored products on product detail page
Post by: gpessoa on January 04, 2022, 19:20:18 PM
QuoteHave you try to show the standard product module ? You can choose to show product from current category, so it should work


Yes, I'm using standard Virtuemart Module "mod_virtuemart_product" but I need a condition  to only show products from the last category tree that product belongs!
and in the module Category filter, there are not that item to select;

only Top Level Category and also all categories on the system...

The solution could be:
-   Add php code to "mod_virtuemart_product" to allow also filtering by Last Category Level

-   Or a code condition to only echo the Last Category Level products
        (this code need to be completed)
<div class="related-colours">
<?php //shows related colours by last category level
if (VmConfig::get('category'0) == 1) {   
if (!empty(
$this->product->category)){   

 echo 
'{module related-colours}';

}
}
?>