1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sunnysideup\EcommerceGoogleShoppingFeed\Extensions; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Forms\CheckboxField; |
6
|
|
|
use SilverStripe\Forms\FieldList; |
7
|
|
|
use SilverStripe\Forms\TextField; |
8
|
|
|
use SilverStripe\ORM\DataExtension; |
9
|
|
|
use Sunnysideup\EcommerceGoogleShoppingFeed\Model\GoogleProductCategory; |
10
|
|
|
use TractorCow\AutoComplete\AutoCompleteField; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class \Sunnysideup\EcommerceGoogleShoppingFeed\Extensions\GoogleShoppingFeedExtension |
14
|
|
|
* |
15
|
|
|
* @property \Sunnysideup\Ecommerce\Pages\Product|\Sunnysideup\EcommerceGoogleShoppingFeed\Extensions\GoogleShoppingFeedExtension $owner |
16
|
|
|
* @property bool $HideFromShoppingFeed |
17
|
|
|
* @property string $MPN |
18
|
|
|
* @property int $GoogleProductCategoryID |
19
|
|
|
* @method \Sunnysideup\EcommerceGoogleShoppingFeed\Model\GoogleProductCategory GoogleProductCategory() |
20
|
|
|
*/ |
21
|
|
|
class GoogleShoppingFeedExtension extends DataExtension |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
private static $db = [ |
27
|
|
|
'HideFromShoppingFeed' => 'Boolean', |
28
|
|
|
'MPN' => 'Varchar(255)', |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
private static $has_one = [ |
32
|
|
|
'GoogleProductCategory' => GoogleProductCategory::class, |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
private static $field_labels = [ |
36
|
|
|
'MPN' => 'MPN / SKU', |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Add the fields to "CMSFields" (if we are not using settings fields). |
41
|
|
|
*/ |
42
|
|
|
public function updateCMSFields(FieldList $fields) |
43
|
|
|
{ |
44
|
|
|
$fields->addFieldsToTab( |
45
|
|
|
'Root.Google', |
46
|
|
|
[ |
47
|
|
|
CheckboxField::create('HideFromShoppingFeed'), |
48
|
|
|
TextField::create('MPN', 'MPN / SKU'), |
49
|
|
|
AutoCompleteField::create( |
50
|
|
|
'GoogleProductCategoryID', |
51
|
|
|
$this->getOwner()->fieldLabel('GoogleProductCategory'), |
52
|
|
|
'', |
53
|
|
|
GoogleProductCategory::class, |
54
|
|
|
'Title' |
55
|
|
|
), |
56
|
|
|
] |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|