Author Topic: Display Sku in product details and in category view  (Read 419 times)

ribo

  • Beginner
  • *
  • Posts: 20
Display Sku in product details and in category view
« on: January 20, 2021, 23:22:31 pm »
Hello, i added in my template override the code
Code: [Select]
<?php echo $product->product_sku ?> in category view of products and the
Code: [Select]
<?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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3350
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Display Sku in product details and in category view
« Reply #1 on: January 21, 2021, 02:12:35 am »
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

  • Beginner
  • *
  • Posts: 20
Re: Display Sku in product details and in category view
« Reply #2 on: January 21, 2021, 05:54:55 am »
Yes but where i must put the COM_VIRTUEMART_PRODUCT_SKU in the code ?

ribo

  • Beginner
  • *
  • Posts: 20
Re: Display Sku in product details and in category view
« Reply #3 on: January 21, 2021, 06:20:54 am »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3350
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Display Sku in product details and in category view
« Reply #4 on: January 21, 2021, 09:26:24 am »
If You refer to this line of code:
Code: [Select]
<?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

  • Beginner
  • *
  • Posts: 20
Re: Display Sku in product details and in category view
« Reply #5 on: January 21, 2021, 10:42:34 am »
This line is for in product details as
Code: [Select]
<?php echo $this->product->product_sku ?> is work there but in category this is give error.
For category products this line
Code: [Select]
<?php echo $product->product_sku ?> works but i am not able to use correctly the
Code: [Select]
'<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> there

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3350
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Display Sku in product details and in category view
« Reply #6 on: January 21, 2021, 11:33:49 am »
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4417
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Display Sku in product details and in category view
« Reply #7 on: January 22, 2021, 09:38:23 am »
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