Author Topic: Additional Product Fields  (Read 6057 times)

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Additional Product Fields
« on: August 28, 2010, 01:03:49 am »
Is it possible have additional product specifications ? So in the same way that we have available fields for length, height, width etc and can have these output in the product flypage ? I need to incorporate approximately 8 others product specs.

I think the solution might involve adding extra fields in the database and amending some VM core files but am not 100% sure. Any advice gratefully accepted :-)

Many thanks in advance.

LeroanZ

  • Beginner
  • *
  • Posts: 35
Re: Additional Product Fields
« Reply #1 on: August 28, 2010, 01:40:07 am »
i want it too

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #2 on: September 13, 2010, 17:27:36 pm »
Hi can anyone help with this please. I'm sure it must be possible...

Thanks in advance.

Vmart 4u

  • Jr. Member
  • **
  • Posts: 78
Re: Additional Product Fields
« Reply #3 on: September 14, 2010, 17:17:42 pm »
yes it is possible well i have not done this but it can be done through making change in (Product Dimensions and Weight)specific page you can jst create table like product_extra_fields having some fields you need and id of that particular product and then you can easily insert data ,and can retrieve it in flypage.tpl ,hope it will help you

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #4 on: September 23, 2010, 13:22:36 pm »
Thanks Vmart 4u for your response. Sorry I don't follow so well. Any chance you can provide clearer instructions, step by step please ? Or if anyone else can assist ?

Much appreciated.

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #5 on: September 27, 2010, 21:58:46 pm »
Can anyone please lend a hand ? Still need to add a few additional custom product fields.

(I have looked into product types but these aren't going to serve my purposes)

Many thanks in advance.

Q

soupman

  • Beginner
  • *
  • Posts: 19
Re: Additional Product Fields
« Reply #6 on: September 29, 2010, 19:19:17 pm »
Any resolution to this problem?

I am in the same position - I added fields to the database and have coded them on the details page and they show up. You can see this by the link below:

http://tirepitcrew.com/index.php?page=shop.product_details&flypage=flypage-ask.tpl&product_id=5&category_id=1&option=com_virtuemart&Itemid=54&vmcchk=1&Itemid=54

But on this page the "browse" page the same data does not show up as you can see below:

http://tirepitcrew.com/index.php?page=shop.browse&category_id=1&option=com_virtuemart&Itemid=54

I am calling the same fields for both forms - What am I missing to make the data available in both the "browse" and "Details" page.


qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #7 on: September 30, 2010, 13:29:35 pm »
Soupman, it's great the way you got those additional product specs onto the flypage. That's something I need to get sorted pronto.....Any chance you could talk me through step by step ?  I'd be very very grateful.

Thanks in advance

q

soupman

  • Beginner
  • *
  • Posts: 19
Re: Additional Product Fields
« Reply #8 on: September 30, 2010, 15:49:58 pm »
qme1ster,

The only thing I did to get the product specs on the page was to add them to the database then call them in the template. This is the part that has me baffled, I did not have to modify any other code and they just showed up. Unless somewhere down the line I got lucky and changed something that enabled all of this to work.

Here is the actual code in /product_details/flypage-ask.tpl.php

<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
mm_showMyFileName(__FILE__);
 ?>

<?php echo $buttons_header // The PDF, Email and Print buttons ?>

<?php
if( $this->get_cfg( 'showPathway' )) {
   echo "<div class=\"pathway\">$navigation_pathway</div>";
}
if( $this->get_cfg( 'product_navigation', 1 )) {
   if( !empty( $previous_product )) {
      echo '<a class="previous_page" href="'.$previous_product_url.'">'.shopMakeHtmlSafe($previous_product['product_name']).'</a>';
   }
   if( !empty( $next_product )) {      
      echo '<a class="next_page" href="'.$next_product_url.'">'.shopMakeHtmlSafe($next_product['product_name']).'</a>';
   }
}
?>
<p>&nbsp;</p>
<div class="container">
   <div class="container_head"><span class="headerbrand">&nbsp;<?php echo $b_brand ?>&nbsp;&nbsp;</span>&nbsp;
                        <span class="headerproduct"><?php echo $product_name; echo ' ' . $edit_link; ?></span>
                                <span class="headertype"><?php echo $product_s_desc ?></span></div>
      
      <div class="body_one"><?php echo $product_image ?>
      </div>
      <div class="body_two"><p class="display8"><strong>Size:</strong>&nbsp;<?php echo $b_size ?><br/>
                              <strong>Sidewall Style:</strong>&nbsp;<?php echo $b_sidewallstyling ?><br/>
                              <strong>Service Description:</strong>&nbsp;<?php echo $b_service_desc ?><br/>
                            <strong>Load Range:</strong>&nbsp;<?php echo $b_loadrange ?><br/>
                            <strong>UTQG:</strong>&nbsp;<?php echo $b_UTQG ?></p>
                      
                               
        </div>
      <div class="body_three"><p class="display8"><strong>Price:</strong> <span class="display2"><?php echo $product_price ?></span><span class="display4">(each)</span><br/>
                           <strong>Availability:</strong>&nbsp;In stock<br/>
                          <strong>Manufacture:</strong><span class="display4">&nbsp;<?php echo $manufacturer_link ?></span><br/>
                           <strong>Type:</strong>&nbsp;<?php echo $b_category ?><br/>
                        <strong>Warranty:</strong>&nbsp;<?php echo $b_warranty ?></p>
        </div>
      <div class="body_four"><p>&nbsp;</p><p>&nbsp;</p>
                        <p class="display8"><strong>Quantity</strong></p>
                        <p>&nbsp;</p><p>&nbsp;</p>
       </div>
      <div class="body_five"><p>&nbsp;</p><p>&nbsp;</p>
                        <p class="display8"><strong>PURCHASE BOX</strong></p>
                        <p>&nbsp;</p><p>&nbsp;</p>
      </div>
      


       
      <div class="footer_one"><p class="display8"><strong>Spacer1</strong> </div>
      <div class="footer_two"><p class="display8"><strong>Additional Information</strong>
                              <br/>Product Description | Specifications | Warranty
      </div>
      <div class="footer_three"><p class="display8"><strong>Spacer2</strong> </div>

</div>

<p>&nbsp;</p>


<p><?php echo $product_reviewform ?></p>
<p><?php echo $addtocart ?></p>
<p><?php echo $ask_seller ?></p>
<p><?php echo $product_reviewform ?></p>


<br style="clear:both;" />


<table border="2" align="center" style="width: 100%;" >
           


   
   <tr>
       <td rowspan="1" colspan="2">
            <hr style="width: 100%; height: 0 px;" />
            <strong><?php echo $b_brand ?></strong><br/><?php echo $product_description ?>
           <br/><span style="font-style: italic;"><?php echo $file_list ?></span>
        </td>
   </tr>
   <tr>
       <td colspan="2">
      
       <?php  echo $related_products ?>
       <br />
       </td>
   </tr>
    <tr>
       <td colspan="2">
        <div style="text-align: center;">
                </div>
                <?php echo $navigation_childlist ?><br /></td>
   </tr>
   
   
  <tr>
    
   </tr>
</table><br style="clear:both"/>
<div class="back_button"><a href='javascript:history.go(-1)'> <?php echo $VM_LANG->_('BACK') ?></a></div>



And this is were it gets screwed up because on the Admin side it tells me the flypage ="flypage" and nothing I change on "flypage" has any effect on the display. By process of elimination I found that any changes on "flypage-ask.tpl.php " directly impacted the display. Also the admin panel tells me I am using flypage="browser_1" but I have deleted all of the browse pages except "browse_3" again process of elimination.

PM or send a reply if you have more question. There is just something I am missing or not getting with these templates -ie flypages

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #9 on: September 30, 2010, 16:58:07 pm »
Hi soupman,

Thanks for getting back to me with this info. Is there a particular table into which to add the new additional product fields ? Could you talk me through the database part by any chance ?

In regards to your flypages- it doesnt seem possible that the new information can show up if it's not in the flypage/browsepage that has been allocated - have you double checked what flypage and browsepages have been set for each category just to make sure ? These override the settings in admin panel.


soupman

  • Beginner
  • *
  • Posts: 19
Re: Additional Product Fields
« Reply #10 on: September 30, 2010, 19:25:28 pm »
qme1ster,

Thanks - never looked at the category page and there it is "browse_3" and "flypage-ask" PLAIN AS THE NOSE ON MY FACE - Duh

PM me with a number and I'll walk you through the DB if the follwing does not help;

open up phpAdmin
In the tables column choose ->vm_products
Select - Structure (tabs on top)
on the bottom of the page you will see an input box with a "1" which is how many fields to add to the table -> on the right is a drop down that you can select to insert the new fields within the table.

That's it - define the fields and save

example from above is "b_brand" which is in the DB and to call it use

<?php echo $b_brand ?>

As I said earlier though I followed the instructions in the documentation and I can only get it to appear on the "flypage-ask" and not on the "browse_3 page" and that is where I need help.

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #11 on: September 30, 2010, 21:17:08 pm »
Thanks soupman for the further explanation. I now follow how to setup the additional fields in the database, however how does one get these fields to appear in VM admin, to  be able to populate with data ? Default tab "Product dimensions & weight" - ideally I'd like to see the additional fields appearing in this same format. Did you manage to get this part done ?

soupman

  • Beginner
  • *
  • Posts: 19
Re: Additional Product Fields
« Reply #12 on: September 30, 2010, 21:54:40 pm »
Yes,

/administrator/components/com_virtuemart/languages/product/english.php

This is the label for the page
'PHPSHOP_PRODUCT_FORM_ITEM_DETAILS_TIRE_LBL' => 'Tire Information',

You can add as many fields as you would like
'PHPSHOP_PRODUCT_FORM_BRAND' => 'Brand',
'PHPSHOP_PRODUCT_FORM_B_SIZE' => 'Tire Size',
'PHPSHOP_PRODUCT_FORM_B_WIDTH' => 'Tire Width',
'PHPSHOP_PRODUCT_FORM_B_RATIO' => 'Sidewall Ratio',
'PHPSHOP_PRODUCT_FORM_B_COMPOSITION' => 'Composition',
'PHPSHOP_PRODUCT_FORM_B_DIAMETER' => 'Diameter',
'PHPSHOP_PRODUCT_FORM_B_SERVICE_DESC' => 'Service Description',
'PHPSHOP_PRODUCT_FORM_B_LOADRANGE' => 'Load Range',
'PHPSHOP_PRODUCT_FORM_B_UTQG' => 'UTQG',


To add it to the admin interface:

administrator/components/com_virtuemart/html/product.product_form.php

This is adding a new TAB

$tabs->startTab( $tire_label, "tire-page");

?>
<h2><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_ITEM_DETAILS_TIRE_LBL') ?></h2>

<table class="adminform">
    <tr class="row1">
      <td width="21%" valign="top" >
        <div style="text-align:right;font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_BRAND') ?>:</div>
      </td>
      <td width="79%" >
        <input type="text" class="inputbox"  name="b_brand" value="<?php $db->sp("b_brand"); ?>" size="15" maxlength="15" />
      </td>
    </tr>
    <tr class="row0">
      <td width="21%" valign="top" >
        <div style="text-align:right;font-weight:bold;"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_FORM_B_DESCRIPTION') ?>:</div>
      </td>
      <td width="79%" >
        <input type="text" class="inputbox"  name="b_description" value="<?php $db->sp("b_description"); ?>" size="15" maxlength="15" />
      </td>
    </tr>

</table>
<?php
$tabs->endTab();

There is more work to do as you have to ADD the fields to the DB queries in order to store or retrieve any of the information. There are different queries depending on the function you will be doing.


FILE: administrator/components/com_virtuemart/classes/ps_product.php


To add data - > ADD around line 250

// Insert into DB
      $fields = array ( 'vendor_id' => $vendor_id,
            'product_parent_id' => vmRequest::getInt('product_parent_id'),
            'product_sku' => vmGet($d,'product_sku'),
            'product_name' => vmGet($d,'product_name'),
            'product_desc' => vmRequest::getVar('product_desc', '', 'default', '', VMREQUEST_ALLOWHTML),
            'b_brand' => vmGet($d,'b_brand'),

and so on..... for all the fields you need to ADD

Do the same around line 447 which updates the data in the database

Should look something like this:

   /**
    * Function to update product $d['product_id'] in the product table
    *
    * @param array $d The input vars
    * @return boolean True, when the product was updated, false when not
    */
   function update( &$d ) {
      global $vmLogger, $perm, $VM_LANG;
      require_once(CLASSPATH.'ps_product_attribute.php');
      
      if (!$this->validate($d)) {
         return false;
      }

      if (!vmImageTools::process_images($d)) {
         return false;
      }

      $timestamp = time();
      $db = new ps_DB;
      $ps_vendor_id = $_SESSION["ps_vendor_id"];
      if( $perm->check( 'admin' )) {
         $vendor_id = $d['vendor_id'];
      }
      else {
         $vendor_id = $ps_vendor_id;
      }
      $old_vendor_id = $this->get_field($d['product_id'], 'vendor_id');
      
        // Insert into DB
      $fields = array ( 'vendor_id' => $vendor_id,
                  'product_sku' => vmGet($d,'product_sku'),
                  'b_brand' => vmGet($d,'b_brand'),
                  'product_desc' => vmRequest::getVar('product_desc', '', 'default', '', VMREQUEST_ALLOWHTML),
                  'product_s_desc' => vmRequest::getVar('product_s_desc', '', 'default', '', VMREQUEST_ALLOWHTML),
                  'product_thumb_image' => vmGet($d,'product_thumb_image'),

There you go you can now add or edit from the ADMIN Panel

soupman

  • Beginner
  • *
  • Posts: 19
Re: Additional Product Fields
« Reply #13 on: September 30, 2010, 21:59:22 pm »
Now can some one tell me how top get it on the TEMPLATE to DISPLAY or is it too simple to explain..

qme1ster

  • Jr. Member
  • **
  • Posts: 276
Re: Additional Product Fields
« Reply #14 on: September 30, 2010, 22:49:49 pm »
Thanks soupman, I really really appreciate you taking the time to provide that info. I'm going to give that a go in the morning as I'm calling it a day here. Please paste your browsepage code here and I'll take a look at your template issue for you in the morning.