News:

Looking for documentation? Take a look on our wiki

Main Menu

Add fields to product list

Started by P Humstad, January 07, 2015, 07:18:32 AM

Previous topic - Next topic

P Humstad

Hi guys

Is there a simple way to add a column to the productlist toolbar. In the toolbar you have ex. Children and Product children of,...... I rather use this column for lets say the stock of my product. I,m sure there is some brains in here that can tell me where and mayby how to do this :)
I have attached a screen shot to explain what I mean for easier understanding

VirtueMart 2.6.12.2

[attachment cleanup by admin]
May U live 2 see the dawn

GJC Web Design

assuming stock level is in the $product object change administrator\components\com_virtuemart\views\product\tmpl\default.php
over rides work in the admin as well
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

P Humstad

Hi,

and thanks a bunch. Would it be to much to ask for a little bit more explanation on howto, mayby a step by step guide. I,m a newbee and just not as good as many of you in here :)
May U live 2 see the dawn

AH



Create an override by  copying the
\administrator\components\com_virtuemart\views\product\tmpl\default.php
into
\administrator\templates\bluestork\html\com_virtuemart\product\default.php

these are the headers for child stuff


<?php if (!$product_parent_id ) { ?>
                <th width="10%"><?php echo $this->sort('product_parent_id','COM_VIRTUEMART_PRODUCT_CHILDREN_OF'); ?></th>
                <?php ?>
                <th width="80px" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_PARENT_LIST_CHILDREN'); ?></th>



Replace with what you want

And then do the same for the detail




                <?php if (!$product_parent_id ) { ?>
<td><?php
if ($product->product_parent_id  ) {
VirtuemartViewProduct::displayLinkToParent($product->product_parent_id);
}
?>
</td>
<!-- Vendor name -->
                                <?php ?>
<td><?php
 VirtuemartViewProduct::displayLinkToChildList($product->virtuemart_product_id $product->product_name);
                                                 
?>

                                </td>


And here is a small stock thing I wrote to help admins easily see stock stuff in the list


<?php
                    
if ($product->published) {
                        
$published;
                        
$available $product->product_in_stock $product->product_ordered;
                        if (
$available 1){
                            echo 
"<div class='stockout'>";
                            echo 
"Out "$available;
                        } elseif (
$available && $available $product->low_stock_notification ) {
                            echo 
"<div class='stocklow'>";
                            echo 
"Low "$available;
                        } else {
                            echo 
"<div class='stockok'>";
                            echo 
"In "$available;
                        }
                        echo 
"</div>";

                        echo 
'Stk: '.$product->product_in_stock;
//                        echo '<br/>Ord: '.$product->product_ordered;
//                        echo '<br/>Lvl: '.$product->low_stock_notification;
                    
}
                        
?>




The classes allow styling of the various stock positions you could code these as inline styles in the above code to simplify things


.stockout {
    font-weight:bold;
    color:red;
}
.stocklow {
    font-weight:bold;
    font-size: 110%;
    color:orange;
}

.stockok {
    font-weight:bold;
    font-size: 110%;
    color:green;
}
Regards
A

Joomla 4.4.5
php 8.1

P Humstad

Thanks a bunch Huston

Your not only a heromember in here right now. You are my hero too :)
Since you know your way around this, please let me ask you one more question ! One thin we always wanted to have in Virtuemart but never figured out how ! A function or a area where we could se the total STOCK VALUE for the whole shop. Is there a way to something like that, or is there a plugin or something already that ads this function.

Thanks for your brilliant help
May U live 2 see the dawn

AH

I do all this type of reporting using ODBC connections to the database or a copy of the dbase

see here

http://forum.virtuemart.net/index.php?topic=124493.msg425712#msg425712  My reply



Regards
A

Joomla 4.4.5
php 8.1

P Humstad

Thanks again Huston

Your code snippet above for showing stock in product list now work like a charm. Thank you very much :) Now, theres one more field I want to show in the product list, product_mpn
I use this field for the wearhouse location of my products.

Is there a code snippet you have that can solve this too ?
May U live 2 see the dawn

AH


<td align ="left>">
                 <div class="adminprod"> <!--<span style="float:left; clear:left"> -->
      <?php echo JHtml::_('link'JRoute::_($link), $product->product_name, array('title' => vmText::_('COM_VIRTUEMART_EDIT').' '.$product->product_name)); ?>
                 </div>
                 <div class="adminsku">
                      <?php echo $product->product_sku;
                      if (!empty(
$product->product_mpn)){
                          echo 
'<span style="font-style: italic;color:green;"><br/>MPN:- ' $product->product_mpn '</span>';
                      }
                      
?>

                 </div>
</td>



This use the product name column and sticks the MPN in there if not empty

You can style the class with CSS
Regards
A

Joomla 4.4.5
php 8.1

P Humstad

Dear Hutson,

Thanks a bunch for helping me out. You are the best.
One question, If I need some custom programming. Can I hire you ? Send me an PM if ok :)

Again, thanks for all your help
May U live 2 see the dawn

AH

Humstad

I do not do custom programming  8)

There are a number of great posters on these boards that will do custom work GJC Web Design is always very helpful
Regards
A

Joomla 4.4.5
php 8.1

P Humstad

Hi Hutson, if your still around,

All you did for me helped a lot. I,m a very happy man. Now, I got one last question for you :)

This is regarding the mpn field. As I told you earlier I use this field for my products location. All got much easier when adding this to my product list like you showed me. But the ultimate thing would be to also add this field to the print sheet, ex replacing the Discount field in the print sheet.

What I want is basicly is print my order and see the location ( mpn field ) on the print sheet instead of ex. the discount table

Can that be done ?
May U live 2 see the dawn

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

P Humstad

Thanks GJC

Some of my brain is possible not working. Thanks for the reminder. Need to get som Red Bull :)
May U live 2 see the dawn