/
ProductCategory.php
executable file
·58 lines (53 loc) · 1.09 KB
/
ProductCategory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
*
* @package FoxyStripe
*
*/
class ProductCategory extends DataObject {
public static $singular_name='Foxycart Category';
public static $plural_name='Foxycart Categories';
static $db = array(
'Title' => 'Text',
'Code' => 'Text'
);
function getCMSFields() {
$fields = array();
$fields[] = new TextField('Title', "FoxyCart 'Category Description'");
$fields[] = new TextField('Code', "Foxycart 'Category Code'");
$set = new FieldSet($fields);
$this->extend('updateCMSFields', $set);
return $set;
}
public function requireDefaultRecords() {
parent::requireDefaultRecords();
if(!DataObject::get_one('ProductCategory', "`Code` = 'DEFAULT'")) {
$do = new ProductCategory();
$do->Title = "Default Product";
$do->Code = "DEFAULT";
$do->write();
}
}
function canDelete(){
switch($this->Code){
case 'DEFAULT':
return false;
break;
default:
return true;
break;
}
return true;
}
function canEdit(){
switch($this->Code){
case 'DEFAULT':
return false;
break;
default:
return true;
break;
}
return true;
}
}