-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SilverStripe 4 and migration updates (#334)
- Loading branch information
Showing
16 changed files
with
101 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# FoxyStripe | ||
|
||
## Migration | ||
|
||
### Migrate your settings from SilverStripe 3.x to 4.x | ||
|
||
FoxyStripe 4 introduces a new class `FoxyStripeSetting` to store your FoxyCart store settings. To migrate your settings from `SiteConfig` to `FoxyStripeSetting`, do the following: | ||
|
||
1. Apply the `SiteConfigMigration` DataExtension to `SiteConfig` | ||
|
||
``` | ||
SilverStripe\SiteConfig\SiteConfig: | ||
extensions: | ||
- Dynamic\FoxyStripe\ORM\SiteConfigMigration | ||
``` | ||
2. Open Settings in the CMS - [http://example.com/admin/settings](http://example.com/admin/settings) | ||
3. Hit 'Save'. The data will save to the current `FoxyStripeSetting` via `onAfterWrite()` on `SiteConfig` | ||
4. Remove the `SiteConfigMigration` DataExtension from `SiteConfig` | ||
|
||
Your FoxyCart settings should now be viewable in the FoxyStripe admin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Dynamic\FoxyStripe\ORM; | ||
|
||
use Dynamic\FoxyStripe\Model\FoxyStripeSetting; | ||
use SilverStripe\Forms\CheckboxField; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\HeaderField; | ||
use SilverStripe\Forms\LiteralField; | ||
use SilverStripe\Forms\ReadonlyField; | ||
use SilverStripe\Forms\TextField; | ||
use SilverStripe\ORM\DataExtension; | ||
|
||
/** | ||
* Class SiteConfigMigration | ||
* | ||
* Apply this DataExtension to SiteConfig and hit Save. Data will be migrated to FoxyStripeSetting | ||
* via the onAfterWrite() function. | ||
* | ||
* @package Dynamic\FoxyStripe\ORM | ||
*/ | ||
class SiteConfigMigration extends DataExtension | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private static $db = array( | ||
'StoreName' => 'Varchar(255)', | ||
'StoreKey' => 'Varchar(60)', | ||
'MultiGroup' => 'Boolean', | ||
'ProductLimit' => 'Int', | ||
'CartValidation' => 'Boolean', | ||
'MaxQuantity' => 'Int', | ||
'CustomSSL' => 'Boolean', | ||
'RemoteDomain' => 'Varchar(255)', | ||
); | ||
|
||
/** | ||
* | ||
*/ | ||
public function onAfterWrite() | ||
{ | ||
parent::onAfterWrite(); | ||
|
||
$config = FoxyStripeSetting::current_foxystripe_setting(); | ||
|
||
$config->StoreName = $this->owner->StoreName; | ||
$config->StoreKey = $this->owner->StoreKey; | ||
$config->MultiGroup = $this->owner->MultiGroup; | ||
$config->ProductLimit = $this->owner->ProductLimit; | ||
$config->CartValidation = $this->owner->CartValidation; | ||
$config->MaxQuantity = $this->owner->MaxQuantity; | ||
$config->CustomSSL = $this->owner->CustomSSL; | ||
$config->RemoteDomain = $this->owner->RemoteDomain; | ||
|
||
$config->write(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters