protected function moveSiteConfigToEcommerceDBConfig_140() { $explanation = "\r\n\t\t\t<h1>140. Move Site Config fields to Ecommerce DB Config</h1>\r\n\t\t\t<p>Moving the general config fields from the SiteConfig to the EcommerceDBConfig.</p>\r\n\t\t"; if ($this->retrieveInfoOnly) { return $explanation; } else { echo $explanation; } $fields = array("ShopClosed", "ShopPricesAreTaxExclusive", "ShopPhysicalAddress", "ReceiptEmail", "PostalCodeURL", "PostalCodeLabel", "NumberOfProductsPerPage", "OnlyShowProductsThatCanBePurchased", "ProductsHaveWeight", "ProductsHaveModelNames", "ProductsHaveQuantifiers", "ProductsAlsoInOtherGroups", "EmailLogoID", "DefaultProductImageID"); $ecomConfig = EcommerceDBConfig::get()->First(); if (!$ecomConfig) { $ecomConfig = EcommerceDBConfig::create(); $ecomConfig->write(); } $sc = SiteConfig::current_site_config(); if ($ecomConfig && $sc) { foreach ($fields as $field) { if ($this->hasTableAndField("SiteConfig", $field)) { if (!$this->hasTableAndField("EcommerceDBConfig", $field)) { $this->DBAlterationMessageNow("Could not find EcommerceDBConfig.{$field} - this is unexpected!", "deleted"); } else { $this->DBAlterationMessageNow("Migrated SiteConfig.{$field}", "created"); $ecomConfig->{$field} = DB::query("SELECT \"{$field}\" FROM \"SiteConfig\" WHERE \"ID\" = " . $sc->ID)->value(); $ecomConfig->write(); $this->makeFieldObsolete("SiteConfig", $field); } } else { $this->DBAlterationMessageNow("SiteConfig.{$field} has been moved"); } } } else { $this->DBAlterationMessageNow("ERROR: SiteConfig or EcommerceDBConfig are not available", "deleted"); } return 0; }
/** * standard SS Method */ public function requireDefaultRecords() { parent::requireDefaultRecords(); if (!self::current_ecommerce_db_config()) { $obj = EcommerceDBConfig::create(); $obj->write(); } DB::alteration_message("\n\t\t\t<hr /><hr /><hr /><hr /><hr />\n\t\t\t<h1 style=\"color: darkRed\">Please make sure to review your <a href=\"/dev/ecommerce/\">e-commerce settings</a>.</h1>\n\t\t\t<hr /><hr /><hr /><hr /><hr />", "edited"); }