VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: suffering on March 04, 2016, 11:03:27 AM

Title: Display SKU in all modules of Virtuemart
Post by: suffering on March 04, 2016, 11:03:27 AM
Hello

I use VM 3
I want to display in all modules of virtuemart under product_name the product_sku.
What i have to do because all existing tutorials are for old versions of VM.
I managed to add sku and weight in product page but i cannot add sku in
Featured products
Random products
Top sellers etc.
Title: Re: Display SKU in all modules of Virtuemart
Post by: Ghost on March 04, 2016, 11:12:53 AM
If you mean mod_virtuemart_product module, create a template override of /modules/mod_virtuemart_product/tmpl/default.php. If you meant VirtueMart frontpage and/or category pages, create an override of products.php sublayout http://docs.virtuemart.net/tutorials/templating-layouts/199-sublayouts.html
Title: Re: Display SKU in all modules of Virtuemart
Post by: suffering on March 04, 2016, 12:44:06 PM
Thanks for immidiate reply but i will need some step by step help in this matter if you can please.
Title: Re: Display SKU in all modules of Virtuemart
Post by: suffering on March 04, 2016, 13:16:07 PM
Hello

I managed to enter the sku in categories by edditing
templates\YOUR_TEMPLATE\html\com_virtuemart\sublayouts\products.php

adding
<?php // Product Sku
                    if (!empty($product->product_sku)) { ?>

                        <p class="product_sku">
                     <?php echo $product->product_sku; ?>
                     </p>

Now i only need to find where and what i must edit to display sku in
eg Random products module.
eg latest products module.
There it displays only product name and image.
I need to add SKU also.
Title: Re: Display SKU in all modules of Virtuemart
Post by: Ghost on March 04, 2016, 18:54:14 PM
Create a template override of /modules/mod_virtuemart_product/tmpl/default.php. It should be placed in templates\YOUR_TEMPLATE\html\mod_virtuemart_product\default.php.
Title: Re: Display SKU in all modules of Virtuemart
Post by: suffering on March 07, 2016, 20:35:23 PM
hello

Can you please explain how to do this?

Create a template override of /modules/mod_virtuemart_product/tmpl/default.php. It should be placed in templates\YOUR_TEMPLATE\html\mod_virtuemart_product\default.php.
Title: Re: Display SKU in all modules of Virtuemart
Post by: Ghost on March 07, 2016, 20:57:42 PM
Open /modules/mod_virtuemart_product/tmpl/default.php and copy its contents to /templates/YOUR_TEMPLATE/html/mod_virtuemart_product/default.php.
Title: Re: Display SKU in all modules of Virtuemart
Post by: jenkinhill on March 07, 2016, 22:35:58 PM
Maybe this will help. It's old but still valid for modules:  http://www.ostraining.com/blog/joomla/overrides
Title: Re: Display SKU in all modules of Virtuemart
Post by: suffering on March 08, 2016, 15:04:48 PM
I did this
Open /modules/mod_virtuemart_product/tmpl/default.php and copy its contents to /templates/YOUR_TEMPLATE/html/mod_virtuemart_product/default.php.
I changed in product_name to product_sku in 4 fields and no change happened.
Title: Re: Display SKU in all modules of Virtuemart
Post by: stula on March 15, 2016, 10:05:44 AM
I can confirm this bug... No matter what I add/remove to templates/mytemplate/html/mod_virtuemart_product/default.php file it doesn't work... On the other hand... if I try same thing in original file (not override) it works fine... Its like override for this module doesn't work.
Title: Re: Display SKU in all modules of Virtuemart
Post by: Ghost on March 15, 2016, 10:46:49 AM
This is probably because the override is disabled. Go to your product module settings and change Layout from 'No override' to 'default'.
Title: Re: Display SKU in all modules of Virtuemart
Post by: stula on March 15, 2016, 14:52:59 PM
Quote from: Ghost on March 15, 2016, 10:46:49 AM
This is probably because the override is disabled. Go to your product module settings and change Layout from 'No override' to 'default'.

This helped! Thank you!  ;)
Title: Re: Display SKU in all modules of Virtuemart
Post by: suffering on March 16, 2016, 10:11:56 AM
Hello

I managed to solve this matter by adding

<?php echo $product->product_sku ?>

next to
php echo $product->product_name ?>

in
/public_html/templates/yourtemplate/html/mod_virtuemart_product/default.php

If you use overide then add also in overide php.