News:

Looking for documentation? Take a look on our wiki

Main Menu

Save virtuemart_product_id in product_sku field

Started by Alexikakos, January 30, 2019, 12:48:25 PM

Previous topic - Next topic

Alexikakos

Hi,
Is any way to save virtuemart_product_id of a product in product_sku field, in same time?

I tried to find where sql query "INSERT" is, but i finded Nothing!

Any idea?

GJC Web Design

There is no insert for the pid as it is just the cumulative next increment id....

I would build an onsave triggered plugin that copies the pid to the sku field - since around VM3.4 there is a flag for first save as well so it wouldn't be called every time you updated etc
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

PRO

OVERRIDE THE PRODUCT FORM

administrator/views/product/product_edit_information.php


         <td>
            <input type="text" class="inputbox" name="product_sku" id="product_sku" value="<?php echo $this->product->product_sku; ?>" size="32" maxlength="255" />
         </td>


to
         <td>
            <input type="text" class="inputbox" name="product_sku" id="product_sku" value="<?php echo $this->product->virtuemart_product_id; ?>" size="32" maxlength="255" />
         </td>

GJC Web Design

the above  will only work after the initial save though...
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

Alexikakos

Thank you PRO
I used your solution with a little modification because I needed to add a few more digits for the date and it worked perfectly.

I give the modification I did in case someone else will need it.


<?php
  
// get current date
   
$Y date('y');
   
$M date('m');
?>


<input type="text" class="inputbox disabled" name="product_sku" id="product_sku" value="<?php echo $this->product->virtuemart_product_id $Y $M?>" size="32" maxlength="255" />


So now, the product sku has the product id plus a four digit number for the date it was created or editted.