Difference between revisions of "How to add fields to a product"

From aMember Pro Documentation
Jump to: navigation, search
Line 11: Line 11:
 
* Am_CustomFieldRadio
 
* Am_CustomFieldRadio
 
* Am_CustomFieldCheckbox
 
* Am_CustomFieldCheckbox
 +
 +
To retrieve value of such field for specific product from product record you can use the following code:
 +
<source>
 +
$product = Am_Di::getInstance()->productTable->load(1); //retrieve product record with id = 1
 +
$product->data()->get('field_name');
 +
</source>

Revision as of 01:55, 6 August 2015

Add this code to site.php file:

<?php 
Am_Di::getInstance()->productTable->customFields()->add(new Am_CustomFieldText('field_name', 'Field Title'));

List of available additional field types:

  • Am_CustomFieldHidden
  • Am_CustomFieldText
  • Am_CustomFieldSelect
  • Am_CustomFieldRadio
  • Am_CustomFieldCheckbox

To retrieve value of such field for specific product from product record you can use the following code:

$product = Am_Di::getInstance()->productTable->load(1); //retrieve product record with id = 1
$product->data()->get('field_name');