News:

Looking for documentation? Take a look on our wiki

Main Menu

VM2 - Databases, codes (ps_product.php) and costum fields

Started by belsaas, September 26, 2012, 14:23:53 PM

Previous topic - Next topic

belsaas

Hi!

I have VM2 and have some questions about databases, codes and costume fields.

On my webshop I sell mp3-files.
I need to give some information about the product like composer, arranger and lyrics.
On VM1 I manage to make the product form by my self. But in VM2 the structure is different.

So how can I make more fields in the page "product_edit_information.php" like

   Composer: "FIELD"
   Arranger: "FIELD"
   

1. I have made this columns in the "virtumarte_products" table.
   
   product_arranger
   product_composer
   product_lyrics
   product_choir
   product_subtitle
   product_url_norskkors
   product_url_spotify
   product_url_wiki
   product_melodi

   In VM1 I hade to add this in the file ps_product.php at both the section "Function to add" and "Function to update"
   
// Insert into DB
      $fields = array ( 'vendor_id' => $vendor_id,
                  'product_sku' => vmGet($d,'product_sku'),
                  'product_name' => vmGet($d,'product_name'),

/////******************************* Ketil Belsaas *****************************/////
                  'product_voice' => vmGet($d,'product_voice'), // 'stemme' Ketil Belsaas 22. juli 2011
                  'product_arranger' => vmGet($d,'product_arranger'), //'durata' Ketil Belsaas 22. juli 2011
                  'product_composer' => vmGet($d, 'product_composer'), // NY Ketil Belsaas 22. juli 2011
                  'product_lyrics' => vmGet($d, 'product_lyrics'), // NY Ketil Belsaas 22. juli 2011
                  'product_choir' => vmGet($d, 'product_choir'), // NY Ketil Belsaas 22. juli 2011
                  'product_subtitle' => vmGet($d, 'product_subtitle'), // NY Ketil Belsaas 22. juli 2011
                  'product_url_norskkors' => vmGet($d, 'product_url_norskkors'), //NY Ketil Belsaas 27. juli 2011
                  'product_url_spotify' => vmGet($d, 'product_url_spotify'), //NY Ketil Belsaas 27. juli 2011
                  'product_url_itunes' => vmGet($d, 'product_url_itunes'), //NY Ketil Belsaas 27. juli 2011
                  'product_url_wiki' => vmGet($d, 'product_url_wiki'), //NY Ketil Belsaas 27. juli 2011
                  'product_melodi' => vmGet($d, 'product_melodi'), //NY Ketil Belsaas 27. juli 2011
                  'product_lyrics2' => vmGet($d, 'product_lyrics2'), //NY Ketil Belsaas 27. juli 2011
/////***************************************************************************/////

Ii think I need to get some help here, or some hints.

When I add filed in the page "product_edit_information.php" i wrote:
<?php echo $this->product->product_composer; ?>

But when I load the form I can't see no text in the field. How can I code this so I can get contact with my database and columns?
What file(s) are instead of ps_product.php?

My second question is:
Can I do this with costume fields?

The challenge is url_fields i the database.
The code I use for this in my product details is:

      <?php
                        if ($product_url_spotify == TRUE)
                            echo "<a target='_blank' href='$product_url_spotify'> $img_spotify</a>"
                    ?>

This will show a image of Spotify logo with an link.
If this i possible with the costume fields i would like to get some information how I can manage that.

If you want to see a product on my website, you can click this link:
http://www.korpedagogen.no/index.php?page=shop.product_details&flypage=ccfirst.tpl&product_id=1863&category_id=674&option=com_virtuemart&Itemid=148&lang=no

Regards
Ketil

-------------------------------
Joomla 3.8.1
Virtuemart 3.2.4
PHP 7.1
-------------------------------

PRO

you should be using "custom fields" and not hacking the core

belsaas

OK!
Thanx!

But how can I set up a costum field that have an image/logo (ex. Spotify) and then ad a link to that image/logo so I on the productpage can click on the image/logo and get redirected to the spesific product on Spotify?

I tried with an image costum field. Could it be possible to make a field in this where I can write the spesific lick?

-------------------------------
Joomla 3.8.1
Virtuemart 3.2.4
PHP 7.1
-------------------------------