migrations/Version20230105114520.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\BaseBundle\SystemConfiguration;
  5. use App\CMSBundle\Entity\DynamicPage;
  6. use App\CMSBundle\Entity\SiteSetting;
  7. use App\CMSBundle\Enum\SiteSettingTypeEnum;
  8. use App\ContentBundle\Entity\Post;
  9. use App\OnlinePaymentBundle\Enum\PaymentMethodEnum;
  10. use App\SeoBundle\Entity\Seo;
  11. use Doctrine\DBAL\Schema\Schema;
  12. use Doctrine\Migrations\AbstractMigration;
  13. use PN\SeoBundle\Entity\SeoBaseRoute;
  14. use PN\SeoBundle\Entity\SeoPage;
  15. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  16. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  17. /**
  18. * Auto-generated Migration: Please modify to your needs!
  19. */
  20. final class Version20230105114520 extends AbstractMigration implements ContainerAwareInterface
  21. {
  22. use ContainerAwareTrait;
  23. public function getDescription(): string
  24. {
  25. return 'Initial Values for E-Commerce';
  26. }
  27. public function up(Schema $schema): void
  28. {
  29. //LANGUAGE ARABIC
  30. if (SystemConfiguration::ENABLE_ARABIC_LANG) {
  31. $this->addSql("INSERT INTO `language` (`id`, `locale`, `title`, `flag_asset`) VALUES (1, 'ar', 'Arabic', 'admin/images/flags/eg.png')");
  32. }
  33. //PAYMENT METHODS
  34. $this->addSql("INSERT INTO `payment_method` (`title`, `note`, `type`, `active`, `fees`, `deleted`, `deleted_by`, `created`, `creator`, `modified`, `modified_by`) VALUES ('Cash on delivery', NULL, :type, '1', '0', NULL, NULL, NOW(), 'System', NOW(), 'System')",
  35. ["type" => PaymentMethodEnum::CASH_ON_DELIVERY->value]
  36. );
  37. $this->addSql("INSERT INTO `payment_method` (`title`, `note`, `type`, `active`, `fees`, `deleted`, `deleted_by`, `created`, `creator`, `modified`, `modified_by`) VALUES ('Credit Card', NULL, :type, '1', '0', NULL, NULL, NOW(), 'System', NOW(), 'System')",
  38. ["type" => PaymentMethodEnum::CREDIT_CARD->value]
  39. );
  40. // CURRENCIES
  41. $this->addSql("INSERT INTO `currency` (`id`, `code`, `symbol`, `title`, `default`, `deleted`, `deleted_by`, `created`, `creator`, `modified`, `modified_by`) VALUES (1, 'EGP', 'EGP', 'Egyptian Pound', '1', NULL, NULL, NOW(), 'System', NOW(), 'System')");
  42. $this->addSql("INSERT INTO `exchange_rate` (`source_currency_id`, `target_currency_id`, `ratio`, `created`, `creator`, `modified`, `modified_by`) VALUES ( 1, 1, 1, NOW(), 'System', NOW(), 'System');");
  43. //IMAGE TYPE
  44. $this->addSql("INSERT INTO `image_type` (`id`, `name`) VALUES (1, 'Main Image')");
  45. $this->addSql("INSERT INTO `image_type` (`id`, `name`) VALUES (2, 'Gallery')");
  46. $this->addSql("INSERT INTO `image_type` (`id`, `name`) VALUES (3, 'Cover Photo')");
  47. // IMAGE SETTINGS
  48. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (1, 'Product', 'product_edit', 'product/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  49. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1000, 1000, NULL, NULL, 0, 1, 1, 1);");
  50. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (0, 1000, 1000, NULL, NULL, 0, 1, 2, 1);");
  51. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (2, 'Blog', 'blog_edit', 'blog/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  52. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1000, 1000, NULL, NULL, 0, 1, 1, 2);");
  53. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1400, 500, NULL, NULL, 0, 1, 3, 2);");
  54. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (3, 'DynamicPage', 'dynamic_page_edit', 'dynamic-page/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  55. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (4, 'Category', 'category_edit', 'category/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  56. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1920, 300, NULL, NULL, 0, 1, 3, 4);");
  57. if (SystemConfiguration::ENABLE_COLLECTION) {
  58. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (5, 'Collection', 'collection_edit', 'collection/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  59. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1000, 1000, NULL, NULL, 0, 1, 1, 5);");
  60. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1920, 300, NULL, NULL, 0, 1, 3, 5);");
  61. }
  62. if (SystemConfiguration::ENABLE_OCCASION) {
  63. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (6, 'Occasion', 'occasion_edit', 'occasion/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  64. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1920, 300, NULL, NULL, 0, 1, 3, 6);");
  65. }
  66. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (7, 'Project', 'project_edit', 'project/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  67. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1000, 1000, NULL, NULL, 0, 1, 1, 7);");
  68. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (0, 1000, 1000, NULL, NULL, 0, 1, 2, 7);");
  69. // DYNAMIC CONTENT
  70. $this->addSql("INSERT INTO `dynamic_content` (`id`, `title`) VALUES (1, 'General Info')");
  71. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (1, 1, 'Email', 'info@ecommerce.com', 1, NULL, NULL, NULL);");
  72. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (2, 1, 'Address', 'Address, ALexandria', 2, NULL, NULL, NULL);");
  73. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (3, 1, 'Facebook Page Link', 'http://facebook.com', 3, NULL, NULL, NULL);");
  74. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (4, 1, 'Instagram Page Link', 'http://Instagram.com', 3, NULL, NULL, NULL);");
  75. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (5, 1, 'Twitter Page Link', 'http://Twitter.com', 3, NULL, NULL, NULL);");
  76. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (6, 1, 'Linkedin Page Link', 'http://Linkedin.com', 3, NULL, NULL, NULL);");
  77. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (7, 1, 'Youtube Channel Link', 'http://Youtube.com', 3, NULL, NULL, NULL);");
  78. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (8, 1, 'Header Image', NULL, 4, '1920px * 350px', 1920, 350);");
  79. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (9, 1, 'Login page image aside', NULL, 4, '780px * 1000px', 780, 1000)");
  80. //SITE SETTINGS
  81. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Head Tags', :type, '0', '', 'System', NOW(), NOW(), 'System')",
  82. ["constant_name" => SiteSetting::WEBSITE_HEAD_TAGS, "type" => SiteSettingTypeEnum::HTML_TAG->value]
  83. );
  84. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Google Tag Manager Id', :type, '0', '', 'System', NOW(), NOW(), 'System')",
  85. ["constant_name" => SiteSetting::GOOGLE_TAG_MANAGER_ID, "type" => SiteSettingTypeEnum::TEXT->value]
  86. );
  87. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Facebook Chat Page Id', :type, '0', '', 'System', NOW(), NOW(), 'System')",
  88. ["constant_name" => SiteSetting::FACEBOOK_CHAT_PAGE_ID, "type" => SiteSettingTypeEnum::TEXT->value]
  89. );
  90. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Facebook Pixel Id', :type, '0', '', 'System', NOW(), NOW(), 'System')",
  91. ["constant_name" => SiteSetting::FACEBOOK_PIXEL_ID, "type" => SiteSettingTypeEnum::TEXT->value]
  92. );
  93. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Primary Color', :type, '1', '#79BBC3', 'System', NOW(), NOW(), 'System')",
  94. ["constant_name" => "website-primary-color", "type" => SiteSettingTypeEnum::COLOR_CODE->value]
  95. );
  96. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Header Color', :type, '1', '#79BBC3', 'System', NOW(), NOW(), 'System')",
  97. ["constant_name" => "website-header-color", "type" => SiteSettingTypeEnum::COLOR_CODE->value]
  98. );
  99. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Header Text Color', :type, '1', '#3f3f3f', 'System', NOW(), NOW(), 'System')",
  100. ["constant_name" => "website-header-text-color", "type" => SiteSettingTypeEnum::COLOR_CODE->value]
  101. );
  102. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Footer Color', :type, '1', '#79BBC3', 'System', NOW(), NOW(), 'System')",
  103. ["constant_name" => "website-footer-color", "type" => SiteSettingTypeEnum::COLOR_CODE->value]
  104. );
  105. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Footer Text Color', :type, '1', '#686868', 'System', NOW(), NOW(), 'System')",
  106. ["constant_name" => "website-footer-text-color", "type" => SiteSettingTypeEnum::COLOR_CODE->value]
  107. );
  108. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Logo', :type, '1', null, 'System', NOW(), NOW(), 'System')",
  109. ["constant_name" => "website-logo", "type" => SiteSettingTypeEnum::SVG_CODE->value]
  110. );
  111. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Mailchimp List ID', :type, '1', '', 'System', NOW(), NOW(), 'System')",
  112. ["constant_name" => "mailchimp-list-id", "type" => SiteSettingTypeEnum::TEXT->value]
  113. );
  114. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Mailchimp API Key', :type, '1', '', 'System', NOW(), NOW(), 'System')",
  115. ["constant_name" => "mailchimp-api-key", "type" => SiteSettingTypeEnum::TEXT->value]
  116. );
  117. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Contact us map coordinate', :type, '1', '30.0690556, 31.219615', 'System', NOW(), NOW(), 'System')",
  118. ["constant_name" => "contact-us-map-coordinate", "type" => SiteSettingTypeEnum::TEXT->value]
  119. );
  120. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Google map API Key', :type, '1', 'AIzaSyD6Xwank3PinQcm0dxXUTAzvn15cdD9Y84', 'System', NOW(), NOW(), 'System')",
  121. ["constant_name" => "google-map-api-key", "type" => SiteSettingTypeEnum::TEXT->value]
  122. );
  123. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Website Title', :type, '1', 'E-Commerce', 'System', NOW(), NOW(), 'System')",
  124. ["constant_name" => "website-title", "type" => SiteSettingTypeEnum::TEXT->value]
  125. );
  126. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Send Emails from', :type, '1', 'no-reply@e-commerce.com', 'System', NOW(), NOW(), 'System')",
  127. ["constant_name" => "email-from", "type" => SiteSettingTypeEnum::EMAIL->value]
  128. );
  129. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Admin Email', :type, '0', 'info@e-commerce.com', 'System', NOW(), NOW(), 'System')",
  130. ["constant_name" => "admin-email", "type" => SiteSettingTypeEnum::EMAIL->value]
  131. );
  132. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Facebook Conversion API - Access token', :type, '0', NULL, 'System', NOW(), NOW(), 'System')",
  133. ["constant_name" => "facebook-conversion-api-access-token", "type" => SiteSettingTypeEnum::TEXT->value]
  134. );
  135. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Facebook Conversion API - Pixel ID', :type, '0', NULL, 'System', NOW(), NOW(), 'System')",
  136. ["constant_name" => "facebook-conversion-api-pixel-id", "type" => SiteSettingTypeEnum::TEXT->value]
  137. );
  138. $this->addSql("INSERT INTO site_setting (`constant_name`, `title`, `type`, `manage_by_super_admin_only`, `value`, `creator`, `created`, `modified`, `modified_by`) VALUES (:constant_name, 'Facebook Conversion API - Test Event Code', :type, '1', NULL, 'System', NOW(), NOW(), 'System')",
  139. ["constant_name" => "facebook-conversion-api-test-event-code", "type" => SiteSettingTypeEnum::TEXT->value]
  140. );
  141. }
  142. public function postUp(Schema $schema): void
  143. {
  144. //SEO BASE ROUTES
  145. $this->newSeoBaseRoute(SeoPage::class, "seo_page");
  146. $this->newSeoBaseRoute(DynamicPage::class, "page");
  147. // SEO
  148. $this->newSeo('Home Page', 'Home Page', 'home-page', 'home-page');
  149. $this->newSeo('On Sale', 'On Sale', 'sale', 'sale');
  150. $this->newSeo('Products', 'Products', 'products', 'products');
  151. $this->newSeo('Categories List Page', 'Categories', 'categories', 'categories');
  152. if (SystemConfiguration::ENABLE_COLLECTION) {
  153. $this->newSeo('Collections List Page', 'Collections', 'collections', 'collections');
  154. }
  155. if (SystemConfiguration::ENABLE_OCCASION) {
  156. $this->newSeo('Occasions List Page', 'Occasions', 'occasions', 'occasions');
  157. }
  158. $this->newSeo('Blogs List Page', 'Blogs', 'blogs', 'blogs');
  159. $this->newSeo('FAQs Page', 'FAQs', 'faq', 'faq');
  160. $this->newSeo('Projects List Page', 'Projects', 'projects', 'project');
  161. $this->newSeo('Contact Us Page', 'Contact Us', 'contact-us', 'contact-us');
  162. $this->createDynamicPage("Terms and Conditions", "Terms and Conditions", "terms-and-conditions");
  163. }
  164. private function newSeoBaseRoute(string $entityName, $baseRoute): void
  165. {
  166. $em = $this->container->get('doctrine.orm.entity_manager');
  167. $seoBaseRoute = new SeoBaseRoute();
  168. $seoBaseRoute->setEntityName($entityName);
  169. $seoBaseRoute->setBaseRoute($baseRoute);
  170. $seoBaseRoute->setCreated(new \DateTime());
  171. $seoBaseRoute->setCreator("System");
  172. $seoBaseRoute->setModified(new \DateTime());
  173. $seoBaseRoute->setModifiedBy("System");
  174. $em->persist($seoBaseRoute);
  175. $em->flush();
  176. }
  177. private function newSeo($seoPageTitle, $seoTitle, $seoPageType, $seoSlug): void
  178. {
  179. //getting entity manager
  180. $em = $this->container->get('doctrine.orm.entity_manager');
  181. $seoPage = new SeoPage();
  182. $seoPage->setTitle($seoPageTitle);
  183. $seoPage->setType($seoPageType);
  184. $seoPage->setCreated(new \DateTime());
  185. $seoPage->setCreator('System');
  186. $seoPage->setModified(new \DateTime());
  187. $seoPage->setModifiedBy('System');
  188. $seo = new Seo();
  189. $seo->setSeoBaseRoute($em->getRepository(SeoBaseRoute::class)->findByEntity($seoPage));
  190. $seo->setTitle($seoTitle);
  191. $seo->setSlug($seoSlug);
  192. $seo->setState(1);
  193. $seo->setLastModified(new \DateTime());
  194. $seoPage->setSeo($seo);
  195. $em->persist($seoPage);
  196. $em->persist($seo);
  197. $em->flush();
  198. }
  199. private function createDynamicPage($dynamicPageTitle, $seoTitle, $seoSlug): void
  200. {
  201. //getting entity manager
  202. $em = $this->container->get('doctrine.orm.entity_manager');
  203. //setting seo pages values
  204. $dynamicPage = new DynamicPage();
  205. $dynamicPage->setTitle($dynamicPageTitle);
  206. $dynamicPage->setCreated(new \DateTime());
  207. $dynamicPage->setCreator('System');
  208. $dynamicPage->setModified(new \DateTime());
  209. $dynamicPage->setModifiedBy('System');
  210. $post = new Post();
  211. $post->setContent(["description"=>"", "brief"=>""]);
  212. $dynamicPage->setPost($post);
  213. $seo = new Seo();
  214. $seo->setSeoBaseRoute($em->getRepository(SeoBaseRoute::class)->findByEntity($dynamicPage));
  215. $seo->setTitle($seoTitle);
  216. $seo->setSlug($seoSlug);
  217. $seo->setState(1);
  218. $seo->setLastModified(new \DateTime());
  219. $dynamicPage->setSeo($seo);
  220. $em->persist($dynamicPage);
  221. $em->flush();
  222. }
  223. public function down(Schema $schema): void
  224. {
  225. // this down() migration is auto-generated, please modify it to your needs
  226. }
  227. }