News:

Looking for documentation? Take a look on our wiki

Main Menu

Add extra product stock option

Started by 2cool, January 31, 2018, 21:07:16 PM

Previous topic - Next topic

2cool

Wonder if anyone knows how to add an extra product stock to vm inventory.
We want to add total warehouse stock next to the product shop stock to keep all in one screen.
This could be just a static field which will be changed manually.

Attached a sketched layout.

Using joomla 3.8.4 and vm 3.2.12

Thanks,

Pas

Studio 42

YOu can hack the core view, or add an override to display this column.
For the DB, you can add a customfield or hack the product table(or use an existing unused field)
Free XML sitemap generator [url="http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm"]http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm[/url]  , Free Unused Image cleaner [url="http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm"]http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm[/url]
Language Switch in product & category [url="http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm"]http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm[/url]
More extentions [url="http://shop.st42.fr/en/"]http://shop.st42.fr/en/[/url]

2cool

Thank for your suggestions, an override should be a nice way to do this.

Can you tell me how this works and what files should override?  (administrator/components/com_virtuemart/inventory/)
Should this be copied to same location in my template?

How can I add a customfield? vm, joomla or mysql?

Thanks.
Pas

Studio 42

to overide file in
administrator/components/com_virtuemart/views/inventory/
templates folder is
administrator/templates/isis/html/com_virtuemart/inventory/
If you want a customfield, you have to modify the sql, so try to use an existing field eg. url, vm do not check if url is valid and do not display it.
You can perhaps use a field in statut tab on edit product? if you dont use all
If you manually add a field in the product table, this is the poorest way and cause problem with the time.
Free XML sitemap generator [url="http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm"]http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm[/url]  , Free Unused Image cleaner [url="http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm"]http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm[/url]
Language Switch in product & category [url="http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm"]http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm[/url]
More extentions [url="http://shop.st42.fr/en/"]http://shop.st42.fr/en/[/url]

2cool

I copied files from 'administrator/components/com_virtuemart/views/inventory/' to 'administrator/templates/isis/html/com_virtuemart/inventory/'
Tested to switch position of 'product name' and 'sku' but this doesn't work?

Is this all to override the admin template or did I forget something.

Thank you,
Pas

Studio 42

Free XML sitemap generator [url="http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm"]http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm[/url]  , Free Unused Image cleaner [url="http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm"]http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm[/url]
Language Switch in product & category [url="http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm"]http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm[/url]
More extentions [url="http://shop.st42.fr/en/"]http://shop.st42.fr/en/[/url]

2cool

Yes isis - Default is set for Administrator templates

Studio 42

Original file is YOURSITE/administrator/components/com_virtuemart/views/inventory/tmpl/default.php
to save in YOURSITE/administrator/templates/isis/html/com_virtuemart/inventory/default.php
Free XML sitemap generator [url="http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm"]http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm[/url]  , Free Unused Image cleaner [url="http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm"]http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm[/url]
Language Switch in product & category [url="http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm"]http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm[/url]
More extentions [url="http://shop.st42.fr/en/"]http://shop.st42.fr/en/[/url]

2cool

Yes now the override works, thanks!

Since I don't use 'products in box' field I tried code below. (product_box)

This is visible but gives an error on sorting?
An error has occurred.
    1054 Unknown column 'product_box' in 'order clause'

Guess it's wrong code in last part: <td><?php echo $product?> <?php echo $this->product->product_box?></td>

Hope you can help to get this fixed.

Thanks,
Pas

<thead>
<tr>
<th class="admin-checkbox"><input type="checkbox" name="toggle" value="" onclick="Joomla.checkAll(this)" /></th>
<th><?php echo $this->sort('product_name'?></th>
<th><?php echo $this->sort('product_sku')?></th>
<th><?php echo $this->sort('product_in_stock','COM_VIRTUEMART_PRODUCT_FORM_IN_STOCK'?></th>
<th><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ORDERED_STOCK'?> </th>
<th><?php echo $this->sort('product_box','COM_VIRTUEMART_PRODUCT_BOX'?></th>
<th><?php echo $this->sort('product_price','COM_VIRTUEMART_PRODUCT_FORM_PRICE_COST'?></th>
<th><?php echo $this->sort('product_price''COM_VIRTUEMART_PRODUCT_INVENTORY_PRICE'?></th>
<th><?php echo $this->sort('product_weight','COM_VIRTUEMART_PRODUCT_INVENTORY_WEIGHT'?></th>
<th><?php echo $this->sort('published')?></th>
</tr>
</thead>
<tbody>
<?php
if (
count($this->inventorylist) > 0) {
$i 0;
$k 0;
$keyword vRequest::uword ('keyword'""' ,-,+,.,_,#,/');
foreach ($this->inventorylist as $key => $product) {
$checked JHtml::_('grid.id'$i $product->virtuemart_product_id);
$published $this->gridPublished$product$i );

//<!-- low_stock_notification  -->
if ( $product->product_in_stock $product->product_ordered 1$stockstatut ="out";
elseif ( $product->product_in_stock $product->product_ordered $product->low_stock_notification $stockstatut ="low";
else $stockstatut "normal";

$stockstatut='class="stock-'.$stockstatut.'" title="'.vmText::_('COM_VIRTUEMART_STOCK_LEVEL_'.$stockstatut).'"';
?>

<tr class="row<?php echo $k ?>">
<!-- Checkbox -->
<td class="admin-checkbox"><?php echo $checked?></td>
<!-- Product name -->
<?php
$link 'index.php?option=com_virtuemart&view=product&task=edit&virtuemart_product_id='.$product->virtuemart_product_id.'&product_parent_id='.$product->product_parent_id;
?>

<td><?php echo JHtml::_('link'JRoute::_($linkFALSE), $product->product_name, array('title' => vmText::_('COM_VIRTUEMART_EDIT').' '.htmlentities($product->product_name))); ?></td>
<td><?php echo $product->product_sku?></td>
<td <?php echo $stockstatut?>><?php echo $product->product_in_stock?></td>
<td <?php echo $stockstatut?> width="5%"><?php echo $product->product_ordered?></td>
<td><?php echo $product?> <?php echo $this->product->product_box?></td>
<td><?php echo $product->product_price_display?></td>
<td><?php echo $product->product_instock_value?></td>
<td><?php echo $product->product_weight." "$product->weigth_unit_display?></td>
<td><?php echo $published?></td>
</tr>



Studio 42

If you want to sort, you have to hack the core(or add a plugin to do it for you). product_box is not a valid sorting in back-end
Free XML sitemap generator [url="http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm"]http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm[/url]  , Free Unused Image cleaner [url="http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm"]http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm[/url]
Language Switch in product & category [url="http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm"]http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm[/url]
More extentions [url="http://shop.st42.fr/en/"]http://shop.st42.fr/en/[/url]