VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: driver_wedge on July 25, 2017, 18:32:32 PM

Title: Product page URL
Post by: driver_wedge on July 25, 2017, 18:32:32 PM
Hi guys...

On the category pages for my site, you can click on either the product image or a Product Details button to visit the product page. The image is linked to www.mysite.com/menu-item-alias/product-alias-detail - whereas the Product Details button goes to www.mysite.com/component/virtuemart/product-alias-detail?Itemid=100

The button is created via this code in /template/html/com_virtuemart/sublayouts/addtocartbar.php

<a class="btn btn-default" href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id); ?>"><?php echo vmText::_ ('VIEW PRODUCT') ?></a>

Can anyone advise on the route I should add to the button so as to achieve the same URL as the product image?

Hope that makes sense.

Thanks!
Title: Re: Product page URL
Post by: jenkinhill on July 25, 2017, 19:17:33 PM
IN the default VM template sublayouts the URLS are the same, so suggest you compare your override with that.
Title: Re: Product page URL
Post by: driver_wedge on July 25, 2017, 19:30:32 PM
Ok, awesome.....good suggestion! Many thanks!
Title: Re: Product page URL
Post by: driver_wedge on July 25, 2017, 21:47:21 PM
Sorry! Back again...

I can't work it out unfortunately. Do you know which file controls the product image on the Category page? Maybe I can locate that within the template and add the same link format to the 'Product Details' button.
Title: Re: Product page URL
Post by: jenkinhill on July 25, 2017, 23:13:08 PM
components/com_virtuemart/sublayouts/products.php
Title: Re: Product page URL
Post by: driver_wedge on July 27, 2017, 11:48:13 AM
I finally managed to sort this with the following code from the products.php file.

Thanks for your help!

-------------------------------------------

<div class="vm-details-button">
            <?php // Product Details Button
            $link = empty($product->link)? $product->canonical:$product->link;
            echo JHtml::link($link.$ItemidStr,vmText::_ ( 'COM_VIRTUEMART_PRODUCT_DETAILS' ), array ('title' => $product->product_name, 'class' => 'product-details' ) );
            //echo JHtml::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id , FALSE), vmText::_ ( 'COM_VIRTUEMART_PRODUCT_DETAILS' ), array ('title' => $product->product_name, 'class' => 'product-details' ) );
            ?>
</div>