Skip to content

Commit 8e5c7bf

Browse files
authored
SilverStripe 4 and migration updates (#334)
1 parent 57a0cea commit 8e5c7bf

16 files changed

+101
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Features include:
2323
* Two-way Single Sign On with FoxyCart
2424
* HMAC Product Validation
2525

26-
Read more about [Using FoxyStripe](docs/en/Use.MD) and [Advanced Features](docs/en/Features.MD)
26+
Read more about [Using FoxyStripe](docs/en/userguide/index.md), [Advanced Features](docs/en/userguide/features.md) and [Migrating from SilverStripe 3.x to 4.x](docs/en/userguide/migration.md)
2727

2828

2929
## Installation

docs/en/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ See the [using FoxyStripe](userguide/index.md) document.
1212

1313
See the [advanced features](userguide/features.md) document.
1414

15+
### Migrating from SilverStripe 3.x to 4.x
16+
17+
See the [SilverStripe 4 migration](userguide/migration.md) document.
18+
1519
### Recommended Add-Ons
1620

1721
The following add-ons are optional, but will enhance FoxyStripe when installed:

docs/en/userguide/migration.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# FoxyStripe
2+
3+
## Migration
4+
5+
### Migrate your settings from SilverStripe 3.x to 4.x
6+
7+
FoxyStripe 4 introduces a new class `FoxyStripeSetting` to store your FoxyCart store settings. To migrate your settings from `SiteConfig` to `FoxyStripeSetting`, do the following:
8+
9+
1. Apply the `SiteConfigMigration` DataExtension to `SiteConfig`
10+
11+
```
12+
SilverStripe\SiteConfig\SiteConfig:
13+
extensions:
14+
- Dynamic\FoxyStripe\ORM\SiteConfigMigration
15+
```
16+
2. Open Settings in the CMS - [http://example.com/admin/settings](http://example.com/admin/settings)
17+
3. Hit 'Save'. The data will save to the current `FoxyStripeSetting` via `onAfterWrite()` on `SiteConfig`
18+
4. Remove the `SiteConfigMigration` DataExtension from `SiteConfig`
19+
20+
Your FoxyCart settings should now be viewable in the FoxyStripe admin.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Dynamic\FoxyStripe\ORM;
4+
5+
use Dynamic\FoxyStripe\Model\FoxyStripeSetting;
6+
use SilverStripe\Forms\CheckboxField;
7+
use SilverStripe\Forms\FieldList;
8+
use SilverStripe\Forms\HeaderField;
9+
use SilverStripe\Forms\LiteralField;
10+
use SilverStripe\Forms\ReadonlyField;
11+
use SilverStripe\Forms\TextField;
12+
use SilverStripe\ORM\DataExtension;
13+
14+
/**
15+
* Class SiteConfigMigration
16+
*
17+
* Apply this DataExtension to SiteConfig and hit Save. Data will be migrated to FoxyStripeSetting
18+
* via the onAfterWrite() function.
19+
*
20+
* @package Dynamic\FoxyStripe\ORM
21+
*/
22+
class SiteConfigMigration extends DataExtension
23+
{
24+
/**
25+
* @var array
26+
*/
27+
private static $db = array(
28+
'StoreName' => 'Varchar(255)',
29+
'StoreKey' => 'Varchar(60)',
30+
'MultiGroup' => 'Boolean',
31+
'ProductLimit' => 'Int',
32+
'CartValidation' => 'Boolean',
33+
'MaxQuantity' => 'Int',
34+
'CustomSSL' => 'Boolean',
35+
'RemoteDomain' => 'Varchar(255)',
36+
);
37+
38+
/**
39+
*
40+
*/
41+
public function onAfterWrite()
42+
{
43+
parent::onAfterWrite();
44+
45+
$config = FoxyStripeSetting::current_foxystripe_setting();
46+
47+
$config->StoreName = $this->owner->StoreName;
48+
$config->StoreKey = $this->owner->StoreKey;
49+
$config->MultiGroup = $this->owner->MultiGroup;
50+
$config->ProductLimit = $this->owner->ProductLimit;
51+
$config->CartValidation = $this->owner->CartValidation;
52+
$config->MaxQuantity = $this->owner->MaxQuantity;
53+
$config->CustomSSL = $this->owner->CustomSSL;
54+
$config->RemoteDomain = $this->owner->RemoteDomain;
55+
56+
$config->write();
57+
}
58+
}

src/Model/FoxyStripeSetting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class FoxyStripeSetting extends DataObject implements PermissionProvider, Templa
116116
/**
117117
* @var string
118118
*/
119-
private static $table_name = 'FS_FoxyStripeSetting';
119+
private static $table_name = 'FoxyStripeSetting';
120120

121121
/**
122122
* Default permission to check for 'LoggedInUsers' to create or edit pages.

src/Model/OptionGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class OptionGroup extends DataObject
4949
/**
5050
* @var string
5151
*/
52-
private static $table_name = 'FS_OptionGroup';
52+
private static $table_name = 'OptionGroup';
5353

5454
/**
5555
* @throws \SilverStripe\ORM\ValidationException

src/Model/OptionItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class OptionItem extends DataObject
106106
/**
107107
* @var string
108108
*/
109-
private static $table_name = 'FS_OptionItem';
109+
private static $table_name = 'OptionItem';
110110

111111
/**
112112
* @return FieldList

src/Model/Order.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Order extends DataObject implements PermissionProvider
8787
*/
8888
private static $summary_fields = array(
8989
'Order_ID',
90-
'TransactionDate.NiceUS',
90+
'TransactionDate.Nice',
9191
'Member.Name',
9292
'ProductTotal.Nice',
9393
'ShippingTotal.Nice',
@@ -127,7 +127,7 @@ class Order extends DataObject implements PermissionProvider
127127
/**
128128
* @var string
129129
*/
130-
private static $table_name = 'FS_Order';
130+
private static $table_name = 'Order';
131131

132132
/**
133133
* @param bool $includerelations

src/Model/OrderDetail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class OrderDetail extends DataObject
8989
/**
9090
* @var string
9191
*/
92-
private static $table_name = 'FS_OrderDetail';
92+
private static $table_name = 'OrderDetail';
9393

9494
/**
9595
* @return FieldList

src/Model/OrderOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ class OrderOption extends DataObject
4242
/**
4343
* @var string
4444
*/
45-
private static $table_name = 'FS_OrderOption';
45+
private static $table_name = 'OrderOption';
4646
}

0 commit comments

Comments
 (0)