News:

Looking for documentation? Take a look on our wiki

Main Menu

Display Sku in product details and in category view

Started by ribo, January 20, 2021, 23:22:31 PM

Previous topic - Next topic

ribo

Hello, i added in my template override the code <?php echo $product->product_sku ?> in category view of products and the <?php echo $this->product->product_sku ?> in product details. How can i add in these codes also and the language text of Sku Product?
I use joomla 3.9.24 Virtuemart 3.8.6 10373 and php 7.3.26 .

Jörgen

Search the JOOMLA language override manager and You WILL find the keys to use. Search for SKU in language keys.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

ribo

Yes but where i must put the COM_VIRTUEMART_PRODUCT_SKU in the code ?

ribo

I found the solution for product details here https://forum.virtuemart.net/index.php?topic=129510.msg445722#msg445722
But for products in category it is not work.

Jörgen

If You refer to this line of code:
<?php echo '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> : '.$this->product->product_sku?>

Add only the jText part :)

Presenting the SKU you say you already have figured out.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

ribo

This line is for in product details as <?php echo $this->product->product_sku ?> is work there but in category this is give error.
For category products this line <?php echo $product->product_sku ?> works but i am not able to use correctly the '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> there

Jörgen

You have to brush up your php skills. If in HTML mode then add <?php   ......  ?> and echo the function result.

Please read what echo does in PHP.net

https://www.php.net/manual/en/function.echo.php

This is actually a PHP question nothing with JOOMLA or VM to do.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

ribo in product details view
<?php echo '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> : '.$this->product->product_sku; ?>
In the category
<?php echo '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> : '.$product->product_sku; ?>
The category use sublayouts and need to be in
/templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/products.php
Original virtuemart file is
/components/com_virtuemart/sublayouts/products.php