Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Install grouped product link type
      */
     $data = ['link_type_id' => \Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED, 'code' => 'super'];
     $setup->getConnection()->insertOnDuplicate($setup->getTable('catalog_product_link_type'), $data);
     /**
      * Install grouped product link attributes
      */
     $select = $setup->getConnection()->select()->from(['c' => $setup->getTable('catalog_product_link_attribute')])->where("c.link_type_id=?", \Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED);
     $result = $setup->getConnection()->fetchAll($select);
     if (!$result) {
         $data = [['link_type_id' => \Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED, 'product_link_attribute_code' => 'position', 'data_type' => 'int'], ['link_type_id' => \Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED, 'product_link_attribute_code' => 'qty', 'data_type' => 'decimal']];
         $setup->getConnection()->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);
     }
     /** @var EavSetup $eavSetup */
     $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
     $field = 'country_of_manufacture';
     $applyTo = explode(',', $eavSetup->getAttribute(Product::ENTITY, $field, 'apply_to'));
     if (!in_array('grouped', $applyTo)) {
         $applyTo[] = 'grouped';
         $eavSetup->updateAttribute(Product::ENTITY, $field, 'apply_to', implode(',', $applyTo));
     }
 }
Esempio n. 2
0
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $connection = $setup->getConnection();
     // add Pending Payu.pl status to Pending Payment state
     $connection->insert($setup->getTable('sales_order_status'), ['status' => 'pending_payupl', 'label' => 'Pending Payu.pl']);
     $connection->insert($setup->getTable('sales_order_status_state'), ['status' => 'pending_payupl', 'state' => 'pending_payment', 'is_default' => 0, 'visible_on_front' => 1]);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1') < 0) {
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
         $attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
         $attributeGroup = $categorySetup->getAttributeGroup($entityTypeId, $attributeSetId, 'Images', 'attribute_group_name');
         if (isset($attributeGroup['attribute_group_name']) && $attributeGroup['attribute_group_name'] == 'Images') {
             // update General Group
             $categorySetup->updateAttributeGroup($entityTypeId, $attributeSetId, $attributeGroup['attribute_group_id'], 'attribute_group_name', 'Images and Videos');
         }
     }
     if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) {
         $select = $setup->getConnection()->select()->from($setup->getTable('catalog_product_entity_group_price'), ['entity_id', 'all_groups', 'customer_group_id', new \Zend_Db_Expr('1'), 'value', 'website_id']);
         $select = $setup->getConnection()->insertFromSelect($select, $setup->getTable('catalog_product_entity_tier_price'), ['entity_id', 'all_groups', 'customer_group_id', 'qty', 'value', 'website_id']);
         $setup->getConnection()->query($select);
         $categorySetupManager = $this->categorySetupFactory->create();
         $categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price');
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         // set new resource model paths
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Category');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Category\\Attribute\\Collection');
         $categorySetup->updateAttribute(\Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Product');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection');
     }
     $setup->endSetup();
 }
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var CustomerSetup $customerSetup */
     $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
     $setup->startSetup();
     // insert default customer groups
     $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 0, 'customer_group_code' => 'NOT LOGGED IN', 'tax_class_id' => 3]);
     $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 1, 'customer_group_code' => 'General', 'tax_class_id' => 3]);
     $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 2, 'customer_group_code' => 'Wholesale', 'tax_class_id' => 3]);
     $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 3, 'customer_group_code' => 'Retailer', 'tax_class_id' => 3]);
     $customerSetup->installEntities();
     $customerSetup->installCustomerForms();
     $disableAGCAttribute = $customerSetup->getEavConfig()->getAttribute('customer', 'disable_auto_group_change');
     $disableAGCAttribute->setData('used_in_forms', ['adminhtml_customer']);
     $disableAGCAttribute->save();
     $attributesInfo = ['vat_id' => ['label' => 'VAT number', 'type' => 'static', 'input' => 'text', 'position' => 140, 'visible' => true, 'required' => false], 'vat_is_valid' => ['label' => 'VAT number validity', 'visible' => false, 'required' => false, 'type' => 'static'], 'vat_request_id' => ['label' => 'VAT number validation request ID', 'type' => 'static', 'visible' => false, 'required' => false], 'vat_request_date' => ['label' => 'VAT number validation request date', 'type' => 'static', 'visible' => false, 'required' => false], 'vat_request_success' => ['label' => 'VAT number validation request success', 'visible' => false, 'required' => false, 'type' => 'static']];
     foreach ($attributesInfo as $attributeCode => $attributeParams) {
         $customerSetup->addAttribute('customer_address', $attributeCode, $attributeParams);
     }
     $vatIdAttribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'vat_id');
     $vatIdAttribute->setData('used_in_forms', ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']);
     $vatIdAttribute->save();
     $entities = $customerSetup->getDefaultEntities();
     foreach ($entities as $entityName => $entity) {
         $customerSetup->addEntityType($entityName, $entity);
     }
     $customerSetup->updateAttribute('customer_address', 'street', 'backend_model', 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\DefaultBackend');
     $migrationSetup = $setup->createMigrationSetup();
     $migrationSetup->appendClassAliasReplace('customer_eav_attribute', 'data_model', Migration::ENTITY_TYPE_MODEL, Migration::FIELD_CONTENT_TYPE_PLAIN, ['attribute_id']);
     $migrationSetup->doUpdateClassAliases();
     $setup->endSetup();
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Prepare database for install
      */
     $setup->startSetup();
     /**
      * PagSeguro Order Status
      */
     $statuses = ['pagseguro_iniciado' => __('PagSeguro Iniciado'), 'pagseguro_aguardando_pagamento' => __('PagSeguro Aguardando Pagamento'), 'pagseguro_cancelada' => __('PagSeguro Cancelada'), 'pagseguro_chargeback_debitado' => __('PagSeguro Chargeback Debitado'), 'pagseguro_devolvida' => __('PagSeguro Devolvida'), 'pagseguro_disponivel' => __('PagSeguro Disponível'), 'pagseguro_em_analise' => __('PagSeguro Em Análise'), 'pagseguro_em_contestacao' => __('PagSeguro Em Contestação'), 'pagseguro_em_disputa' => __('PagSeguro Em Disputa'), 'pagseguro_paga' => __('PagSeguro Paga')];
     foreach ($statuses as $code => $info) {
         $status[] = ['status' => $code, 'label' => $info];
         $state[] = ['status' => $code, 'state' => 'new', 'is_default' => 0, 'visible_on_front' => '1'];
     }
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $status);
     /**
      * PagSeguro Order State
      */
     $state[0]['is_default'] = 1;
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status_state'), ['status', 'state', 'is_default', 'visible_on_front'], $state);
     unset($data);
     /**
      * PagSeguro Store Reference
      */
     $data[] = ['scope' => 'default', 'scope_id' => 0, 'path' => 'pagseguro/store/reference', 'value' => \UOL\PagSeguro\Helper\Data::generateStoreReference()];
     $setup->getConnection()->insertArray($setup->getTable('core_config_data'), ['scope', 'scope_id', 'path', 'value'], $data);
     /**
      * Prepare database after install
      */
     $setup->endSetup();
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) {
         $select = $setup->getConnection()->select()->from($setup->getTable('catalog_product_entity_group_price'), ['entity_id', 'all_groups', 'customer_group_id', new \Zend_Db_Expr('1'), 'value', 'website_id']);
         $select = $setup->getConnection()->insertFromSelect($select, $setup->getTable('catalog_product_entity_tier_price'), ['entity_id', 'all_groups', 'customer_group_id', 'qty', 'value', 'website_id']);
         $setup->getConnection()->query($select);
         $categorySetupManager = $this->categorySetupFactory->create();
         $categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price');
     }
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         // set new resource model paths
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Category');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Category\\Attribute\\Collection');
         $categorySetup->updateAttribute(\Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Product');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute');
         $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection');
     }
     if (version_compare($context->getVersion(), '2.0.3') < 0) {
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateAttribute(3, 51, 'default_value', 1);
     }
     if (version_compare($context->getVersion(), '2.0.4') < 0) {
         /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
         $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
         $categorySetup->updateAttribute('catalog_product', 'media_gallery', 'backend_type', 'static');
         $categorySetup->updateAttribute('catalog_product', 'media_gallery', 'backend_model');
     }
     $setup->endSetup();
 }
Esempio n. 7
0
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.1', '<')) {
         /**
          * install vat exempt tax class
          */
         $data = [['class_name' => 'Vatexempt Class', 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT]];
         foreach ($data as $row) {
             $setup->getConnection()->insertForce($setup->getTable('tax_class'), $row);
         }
         /**
          * install vat exempt tax rate
          */
         $data = [['tax_country_id' => 'US', 'tax_region_id' => '*', 'tax_postcode' => '*', 'code' => 'Vat Exempt', 'rate' => '0.00']];
         foreach ($data as $row) {
             $setup->getConnection()->insertForce($setup->getTable('tax_calculation_rate'), $row);
         }
         /**
          * install vat exempt tax rule
          */
         $this->_executor->exec($this->_installer);
     }
     $setup->endSetup();
 }
Esempio n. 8
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $days = (new DataBundle())->get($this->localeResolver->getLocale())['calendar']['gregorian']['dayNames']['format']['abbreviated'];
     $select = $setup->getConnection()->select()->from($setup->getTable('core_config_data'), ['config_id', 'value'])->where('path = ?', 'carriers/dhl/shipment_days');
     foreach ($setup->getConnection()->fetchAll($select) as $configRow) {
         $row = ['value' => implode(',', array_intersect_key(iterator_to_array($days), array_flip(explode(',', $configRow['value']))))];
         $setup->getConnection()->update($setup->getTable('core_config_data'), $row, ['config_id = ?' => $configRow['config_id']]);
     }
 }
 /**
  * Installs data for a module
  *
  * @param ModuleDataSetupInterface $setup
  * @param ModuleContextInterface $context
  * @return void
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $province = ['AG' => 'Agrigento', 'AL' => 'Alessandria', 'AN' => 'Ancona', 'AO' => 'Aosta', 'AR' => 'Arezzo', 'AP' => 'Ascoli Piceno', 'AT' => 'Asti', 'AV' => 'Avellino', 'BA' => 'Bari', 'BT' => 'Barletta-Andria-Trani', 'BL' => 'Belluno', 'BN' => 'Benevento', 'BG' => 'Bergamo', 'BI' => 'Biella', 'BO' => 'Bologna', 'BZ' => 'Bolzano', 'BS' => 'Brescia', 'BR' => 'Brindisi', 'CA' => 'Cagliari', 'CL' => 'Caltanissetta', 'CB' => 'Campobasso', 'CI' => 'Carbonia-Iglesias', 'CE' => 'Caserta', 'CT' => 'Catania', 'CZ' => 'Catanzaro', 'CH' => 'Chieti', 'CO' => 'Como', 'CS' => 'Cosenza', 'CR' => 'Cremona', 'KR' => 'Crotone', 'CN' => 'Cuneo', 'EN' => 'Enna', 'FM' => 'Fermo', 'FE' => 'Ferrara', 'FI' => 'Firenze', 'FG' => 'Foggia', 'FC' => 'Forlì-Cesena', 'FR' => 'Frosinone', 'GE' => 'Genova', 'GO' => 'Gorizia', 'GR' => 'Grosseto', 'IM' => 'Imperia', 'IS' => 'Isernia', 'SP' => 'La Spezia', 'AQ' => 'L\'Aquila', 'LT' => 'Latina', 'LE' => 'Lecce', 'LC' => 'Lecco', 'LI' => 'Livorno', 'LO' => 'Lodi', 'LU' => 'Lucca', 'MC' => 'Macerata', 'MN' => 'Mantova', 'MS' => 'Massa-Carrara', 'MT' => 'Matera', 'ME' => 'Messina', 'MI' => 'Milano', 'MO' => 'Modena', 'MB' => 'Monza e della Brianza', 'NA' => 'Napoli', 'NO' => 'Novara', 'NU' => 'Nuoro', 'OT' => 'Olbia-Tempio', 'OR' => 'Oristano', 'PD' => 'Padova', 'PA' => 'Palermo', 'PR' => 'Parma', 'PV' => 'Pavia', 'PG' => 'Perugia', 'PU' => 'Pesaro e Urbino', 'PE' => 'Pescara', 'PC' => 'Piacenza', 'PI' => 'Pisa', 'PT' => 'Pistoia', 'PN' => 'Pordenone', 'PZ' => 'Potenza', 'PO' => 'Prato', 'RG' => 'Ragusa', 'RA' => 'Ravenna', 'RC' => 'Reggio Calabria', 'RE' => 'Reggio Emilia', 'RI' => 'Rieti', 'RN' => 'Rimini', 'RM' => 'Roma', 'RO' => 'Rovigo', 'SA' => 'Salerno', 'VS' => 'Medio Campidano', 'SS' => 'Sassari', 'SV' => 'Savona', 'SI' => 'Siena', 'SR' => 'Siracusa', 'SO' => 'Sondrio', 'TA' => 'Taranto', 'TE' => 'Teramo', 'TR' => 'Terni', 'TO' => 'Torino', 'OG' => 'Ogliastra', 'TP' => 'Trapani', 'TN' => 'Trento', 'TV' => 'Treviso', 'TS' => 'Trieste', 'UD' => 'Udine', 'VA' => 'Varese', 'VE' => 'Venezia', 'VB' => 'Verbano-Cusio-Ossola', 'VC' => 'Vercelli', 'VR' => 'Verona', 'VV' => 'Vibo Valentia', 'VI' => 'Vicenza', 'VT' => 'Viterbo'];
     foreach ($province as $code => $name) {
         $bind = ['country_id' => 'IT', 'code' => $code, 'default_name' => $name];
         $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
         $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
         $bind = ['locale' => 'it_IT', 'region_id' => $regionId, 'name' => $name];
         $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
     }
     $setup->endSetup();
 }
Esempio n. 10
0
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $countryRegionTable = $setup->getTable("directory_country_region");
     $countryRegionNameTable = $setup->getTable("directory_country_region_name");
     $data = [["ACT", "Australian Capital Territory"], ["NSW", "New South Wales"], ["NT", "Northern Territory"], ["QLD", "Queensland"], ["SA", "South Australia"], ["TAS", "Tasmania"], ["VIC", "Victoria"], ["WA", "Western Australia"]];
     foreach ($data as $row) {
         $bind = ["country_id" => "AU", "code" => $row[0], "default_name" => $row[1]];
         $setup->getConnection()->insert($countryRegionTable, $bind);
         $regionId = $setup->getConnection()->lastInsertId($countryRegionTable);
         $columns = ["locale", "region_id", "name"];
         $values = [["en_AU", $regionId, $row[1]], ["en_US", $regionId, $row[1]]];
         $setup->getConnection()->insertArray($countryRegionNameTable, $columns, $values);
     }
 }
Esempio n. 11
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     /*
      * Report Event Types default data
      */
     $eventTypeData = [['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_VIEW, 'event_name' => 'catalog_product_view'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_SEND, 'event_name' => 'sendfriend_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_COMPARE, 'event_name' => 'catalog_product_compare_add_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_TO_CART, 'event_name' => 'checkout_cart_add_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_TO_WISHLIST, 'event_name' => 'wishlist_add_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_WISHLIST_SHARE, 'event_name' => 'wishlist_share']];
     foreach ($eventTypeData as $row) {
         $setup->getConnection()->insertForce($setup->getTable('report_event_types'), $row);
     }
     /**
      * Prepare database after data upgrade
      */
     $setup->endSetup();
     /**
      * Cms Page  with 'home' identifier page modification for report pages
      */
     /** @var $cms \Magento\Cms\Model\Page */
     $cms = $this->pageFactory->create();
     $cms->load('home', 'identifier');
     $reportLayoutUpdate = '<!--
 <referenceContainer name="right">
     <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.viewed</argument></action>
     <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.compared</argument></action>
 </referenceContainer>-->';
     /*
      * Merge and save old layout update data with report layout data
      */
     $cms->setLayoutUpdateXml($cms->getLayoutUpdateXml() . $reportLayoutUpdate)->save();
 }
Esempio n. 12
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $roleCollection = $this->authFactory->createRoleCollection()->addFieldToFilter('parent_id', 0)->addFieldToFilter('tree_level', 1)->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE)->addFieldToFilter('user_id', 0)->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN)->addFieldToFilter('role_name', 'Administrators');
     if ($roleCollection->count() == 0) {
         $admGroupRole = $this->authFactory->createRole()->setData(['parent_id' => 0, 'tree_level' => 1, 'sort_order' => 1, 'role_type' => RoleGroup::ROLE_TYPE, 'user_id' => 0, 'user_type' => UserContextInterface::USER_TYPE_ADMIN, 'role_name' => 'Administrators'])->save();
     } else {
         foreach ($roleCollection as $item) {
             $admGroupRole = $item;
             break;
         }
     }
     $rulesCollection = $this->authFactory->createRulesCollection()->addFieldToFilter('role_id', $admGroupRole->getId())->addFieldToFilter('resource_id', 'all');
     if ($rulesCollection->count() == 0) {
         $this->authFactory->createRules()->setData(['role_id' => $admGroupRole->getId(), 'resource_id' => 'Magento_Backend::all', 'privileges' => null, 'permission' => 'allow'])->save();
     } else {
         /** @var \Magento\Authorization\Model\Rules $rule */
         foreach ($rulesCollection as $rule) {
             $rule->setData('resource_id', 'Magento_Backend::all')->save();
         }
     }
     /**
      * Delete rows by condition from authorization_rule
      */
     $setup->startSetup();
     $tableName = $setup->getTable('authorization_rule');
     if ($tableName) {
         $setup->getConnection()->delete($tableName, ['resource_id = ?' => 'admin/system/tools/compiler']);
     }
     $setup->endSetup();
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Prepare database for install
      */
     $setup->startSetup();
     $quoteInstaller = $this->quoteSetupFactory->create(['resourceName' => 'quote_setup', 'setup' => $setup]);
     $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
     /**
      * Add paypal attributes to the:
      *  - sales/flat_quote_payment_item table
      *  - sales/flat_order table
      */
     $quoteInstaller->addAttribute('quote_payment', 'paypal_payer_id', []);
     $quoteInstaller->addAttribute('quote_payment', 'paypal_payer_status', []);
     $quoteInstaller->addAttribute('quote_payment', 'paypal_correlation_id', []);
     $salesInstaller->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]);
     $data = [];
     $statuses = ['pending_paypal' => __('Pending PayPal'), 'paypal_reversed' => __('PayPal Reversed'), 'paypal_canceled_reversal' => __('PayPal Canceled Reversal')];
     foreach ($statuses as $code => $info) {
         $data[] = ['status' => $code, 'label' => $info];
     }
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $data);
     /**
      * Prepare database after install
      */
     $setup->endSetup();
 }
Esempio n. 14
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /*
      * Register themes
      */
     $setup->getEventManager()->dispatch('theme_registration_from_filesystem');
     /**
      * Update theme's data
      */
     $fileCollection = $this->createTheme();
     $fileCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     $resourceCollection = $this->createThemeResource();
     $resourceCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     foreach ($resourceCollection as $theme) {
         $themeType = $fileCollection->hasTheme($theme) ? \Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL : \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL;
         $theme->setType($themeType)->save();
     }
     $fileCollection = $this->createTheme();
     $fileCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     $themeDbCollection = $this->createThemeResource();
     $themeDbCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
     /** @var $theme \Magento\Framework\View\Design\ThemeInterface */
     foreach ($fileCollection as $theme) {
         $dbTheme = $themeDbCollection->getThemeByFullPath($theme->getFullPath());
         $dbTheme->setCode($theme->getCode());
         $dbTheme->save();
     }
     /**
      * Update rows in theme
      */
     $setup->getConnection()->update($setup->getTable('theme'), ['area' => 'frontend'], ['area = ?' => '']);
 }
Esempio n. 15
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Fill table directory/country
      */
     $data = [['AD', 'AD', 'AND'], ['AE', 'AE', 'ARE'], ['AF', 'AF', 'AFG'], ['AG', 'AG', 'ATG'], ['AI', 'AI', 'AIA'], ['AL', 'AL', 'ALB'], ['AM', 'AM', 'ARM'], ['AN', 'AN', 'ANT'], ['AO', 'AO', 'AGO'], ['AQ', 'AQ', 'ATA'], ['AR', 'AR', 'ARG'], ['AS', 'AS', 'ASM'], ['AT', 'AT', 'AUT'], ['AU', 'AU', 'AUS'], ['AW', 'AW', 'ABW'], ['AX', 'AX', 'ALA'], ['AZ', 'AZ', 'AZE'], ['BA', 'BA', 'BIH'], ['BB', 'BB', 'BRB'], ['BD', 'BD', 'BGD'], ['BE', 'BE', 'BEL'], ['BF', 'BF', 'BFA'], ['BG', 'BG', 'BGR'], ['BH', 'BH', 'BHR'], ['BI', 'BI', 'BDI'], ['BJ', 'BJ', 'BEN'], ['BL', 'BL', 'BLM'], ['BM', 'BM', 'BMU'], ['BN', 'BN', 'BRN'], ['BO', 'BO', 'BOL'], ['BR', 'BR', 'BRA'], ['BS', 'BS', 'BHS'], ['BT', 'BT', 'BTN'], ['BV', 'BV', 'BVT'], ['BW', 'BW', 'BWA'], ['BY', 'BY', 'BLR'], ['BZ', 'BZ', 'BLZ'], ['CA', 'CA', 'CAN'], ['CC', 'CC', 'CCK'], ['CD', 'CD', 'COD'], ['CF', 'CF', 'CAF'], ['CG', 'CG', 'COG'], ['CH', 'CH', 'CHE'], ['CI', 'CI', 'CIV'], ['CK', 'CK', 'C*K'], ['CL', 'CL', 'CHL'], ['CM', 'CM', 'CMR'], ['CN', 'CN', 'CHN'], ['CO', 'CO', 'COL'], ['CR', 'CR', 'CRI'], ['CU', 'CU', 'CUB'], ['CV', 'CV', 'CPV'], ['CX', 'CX', 'CXR'], ['CY', 'CY', 'CYP'], ['CZ', 'CZ', 'CZE'], ['DE', 'DE', 'DEU'], ['DJ', 'DJ', 'DJI'], ['DK', 'DK', 'DNK'], ['DM', 'DM', 'DMA'], ['DO', 'DO', 'DOM'], ['DZ', 'DZ', 'DZA'], ['EC', 'EC', 'ECU'], ['EE', 'EE', 'EST'], ['EG', 'EG', 'EGY'], ['EH', 'EH', 'ESH'], ['ER', 'ER', 'ERI'], ['ES', 'ES', 'ESP'], ['ET', 'ET', 'ETH'], ['FI', 'FI', 'FIN'], ['FJ', 'FJ', 'FJI'], ['FK', 'FK', 'FLK'], ['FM', 'FM', 'FSM'], ['FO', 'FO', 'FRO'], ['FR', 'FR', 'FRA'], ['GA', 'GA', 'GAB'], ['GB', 'GB', 'GBR'], ['GD', 'GD', 'GRD'], ['GE', 'GE', 'GEO'], ['GF', 'GF', 'GUF'], ['GG', 'GG', 'GGY'], ['GH', 'GH', 'GHA'], ['GI', 'GI', 'GIB'], ['GL', 'GL', 'GRL'], ['GM', 'GM', 'GMB'], ['GN', 'GN', 'GIN'], ['GP', 'GP', 'GLP'], ['GQ', 'GQ', 'GNQ'], ['GR', 'GR', 'GRC'], ['GS', 'GS', 'SGS'], ['GT', 'GT', 'GTM'], ['GU', 'GU', 'GUM'], ['GW', 'GW', 'GNB'], ['GY', 'GY', 'GUY'], ['HK', 'HK', 'HKG'], ['HM', 'HM', 'HMD'], ['HN', 'HN', 'HND'], ['HR', 'HR', 'HRV'], ['HT', 'HT', 'HTI'], ['HU', 'HU', 'HUN'], ['ID', 'ID', 'IDN'], ['IE', 'IE', 'IRL'], ['IL', 'IL', 'ISR'], ['IM', 'IM', 'IMN'], ['IN', 'IN', 'IND'], ['IO', 'IO', 'IOT'], ['IQ', 'IQ', 'IRQ'], ['IR', 'IR', 'IRN'], ['IS', 'IS', 'ISL'], ['IT', 'IT', 'ITA'], ['JE', 'JE', 'JEY'], ['JM', 'JM', 'JAM'], ['JO', 'JO', 'JOR'], ['JP', 'JP', 'JPN'], ['KE', 'KE', 'KEN'], ['KG', 'KG', 'KGZ'], ['KH', 'KH', 'KHM'], ['KI', 'KI', 'KIR'], ['KM', 'KM', 'COM'], ['KN', 'KN', 'KNA'], ['KP', 'KP', 'PRK'], ['KR', 'KR', 'KOR'], ['KW', 'KW', 'KWT'], ['KY', 'KY', 'CYM'], ['KZ', 'KZ', 'KAZ'], ['LA', 'LA', 'LAO'], ['LB', 'LB', 'LBN'], ['LC', 'LC', 'LCA'], ['LI', 'LI', 'LIE'], ['LK', 'LK', 'LKA'], ['LR', 'LR', 'LBR'], ['LS', 'LS', 'LSO'], ['LT', 'LT', 'LTU'], ['LU', 'LU', 'LUX'], ['LV', 'LV', 'LVA'], ['LY', 'LY', 'LBY'], ['MA', 'MA', 'MAR'], ['MC', 'MC', 'MCO'], ['MD', 'MD', 'MDA'], ['ME', 'ME', 'MNE'], ['MF', 'MF', 'MAF'], ['MG', 'MG', 'MDG'], ['MH', 'MH', 'MHL'], ['MK', 'MK', 'MKD'], ['ML', 'ML', 'MLI'], ['MM', 'MM', 'MMR'], ['MN', 'MN', 'MNG'], ['MO', 'MO', 'MAC'], ['MP', 'MP', 'MNP'], ['MQ', 'MQ', 'MTQ'], ['MR', 'MR', 'MRT'], ['MS', 'MS', 'MSR'], ['MT', 'MT', 'MLT'], ['MU', 'MU', 'MUS'], ['MV', 'MV', 'MDV'], ['MW', 'MW', 'MWI'], ['MX', 'MX', 'MEX'], ['MY', 'MY', 'MYS'], ['MZ', 'MZ', 'MOZ'], ['NA', 'NA', 'NAM'], ['NC', 'NC', 'NCL'], ['NE', 'NE', 'NER'], ['NF', 'NF', 'NFK'], ['NG', 'NG', 'NGA'], ['NI', 'NI', 'NIC'], ['NL', 'NL', 'NLD'], ['NO', 'NO', 'NOR'], ['NP', 'NP', 'NPL'], ['NR', 'NR', 'NRU'], ['NU', 'NU', 'NIU'], ['NZ', 'NZ', 'NZL'], ['OM', 'OM', 'OMN'], ['PA', 'PA', 'PAN'], ['PE', 'PE', 'PER'], ['PF', 'PF', 'PYF'], ['PG', 'PG', 'PNG'], ['PH', 'PH', 'PHL'], ['PK', 'PK', 'PAK'], ['PL', 'PL', 'POL'], ['PM', 'PM', 'SPM'], ['PN', 'PN', 'PCN'], ['PS', 'PS', 'PSE'], ['PT', 'PT', 'PRT'], ['PW', 'PW', 'PLW'], ['PY', 'PY', 'PRY'], ['QA', 'QA', 'QAT'], ['RE', 'RE', 'REU'], ['RO', 'RO', 'ROU'], ['RS', 'RS', 'SRB'], ['RU', 'RU', 'RUS'], ['RW', 'RW', 'RWA'], ['SA', 'SA', 'SAU'], ['SB', 'SB', 'SLB'], ['SC', 'SC', 'SYC'], ['SD', 'SD', 'SDN'], ['SE', 'SE', 'SWE'], ['SG', 'SG', 'SGP'], ['SH', 'SH', 'SHN'], ['SI', 'SI', 'SVN'], ['SJ', 'SJ', 'SJM'], ['SK', 'SK', 'SVK'], ['SL', 'SL', 'SLE'], ['SM', 'SM', 'SMR'], ['SN', 'SN', 'SEN'], ['SO', 'SO', 'SOM'], ['SR', 'SR', 'SUR'], ['ST', 'ST', 'STP'], ['SV', 'SV', 'SLV'], ['SY', 'SY', 'SYR'], ['SZ', 'SZ', 'SWZ'], ['TC', 'TC', 'TCA'], ['TD', 'TD', 'TCD'], ['TF', 'TF', 'ATF'], ['TG', 'TG', 'TGO'], ['TH', 'TH', 'THA'], ['TJ', 'TJ', 'TJK'], ['TK', 'TK', 'TKL'], ['TL', 'TL', 'TLS'], ['TM', 'TM', 'TKM'], ['TN', 'TN', 'TUN'], ['TO', 'TO', 'TON'], ['TR', 'TR', 'TUR'], ['TT', 'TT', 'TTO'], ['TV', 'TV', 'TUV'], ['TW', 'TW', 'TWN'], ['TZ', 'TZ', 'TZA'], ['UA', 'UA', 'UKR'], ['UG', 'UG', 'UGA'], ['UM', 'UM', 'UMI'], ['US', 'US', 'USA'], ['UY', 'UY', 'URY'], ['UZ', 'UZ', 'UZB'], ['VA', 'VA', 'VAT'], ['VC', 'VC', 'VCT'], ['VE', 'VE', 'VEN'], ['VG', 'VG', 'VGB'], ['VI', 'VI', 'VIR'], ['VN', 'VN', 'VNM'], ['VU', 'VU', 'VUT'], ['WF', 'WF', 'WLF'], ['WS', 'WS', 'WSM'], ['YE', 'YE', 'YEM'], ['YT', 'YT', 'MYT'], ['ZA', 'ZA', 'ZAF'], ['ZM', 'ZM', 'ZMB'], ['ZW', 'ZW', 'ZWE']];
     $columns = ['country_id', 'iso2_code', 'iso3_code'];
     $setup->getConnection()->insertArray($setup->getTable('directory_country'), $columns, $data);
     /**
      * Fill table directory/country_region
      * Fill table directory/country_region_name for en_US locale
      */
     $data = [['US', 'AL', 'Alabama'], ['US', 'AK', 'Alaska'], ['US', 'AS', 'American Samoa'], ['US', 'AZ', 'Arizona'], ['US', 'AR', 'Arkansas'], ['US', 'AE', 'Armed Forces Africa'], ['US', 'AA', 'Armed Forces Americas'], ['US', 'AE', 'Armed Forces Canada'], ['US', 'AE', 'Armed Forces Europe'], ['US', 'AE', 'Armed Forces Middle East'], ['US', 'AP', 'Armed Forces Pacific'], ['US', 'CA', 'California'], ['US', 'CO', 'Colorado'], ['US', 'CT', 'Connecticut'], ['US', 'DE', 'Delaware'], ['US', 'DC', 'District of Columbia'], ['US', 'FM', 'Federated States Of Micronesia'], ['US', 'FL', 'Florida'], ['US', 'GA', 'Georgia'], ['US', 'GU', 'Guam'], ['US', 'HI', 'Hawaii'], ['US', 'ID', 'Idaho'], ['US', 'IL', 'Illinois'], ['US', 'IN', 'Indiana'], ['US', 'IA', 'Iowa'], ['US', 'KS', 'Kansas'], ['US', 'KY', 'Kentucky'], ['US', 'LA', 'Louisiana'], ['US', 'ME', 'Maine'], ['US', 'MH', 'Marshall Islands'], ['US', 'MD', 'Maryland'], ['US', 'MA', 'Massachusetts'], ['US', 'MI', 'Michigan'], ['US', 'MN', 'Minnesota'], ['US', 'MS', 'Mississippi'], ['US', 'MO', 'Missouri'], ['US', 'MT', 'Montana'], ['US', 'NE', 'Nebraska'], ['US', 'NV', 'Nevada'], ['US', 'NH', 'New Hampshire'], ['US', 'NJ', 'New Jersey'], ['US', 'NM', 'New Mexico'], ['US', 'NY', 'New York'], ['US', 'NC', 'North Carolina'], ['US', 'ND', 'North Dakota'], ['US', 'MP', 'Northern Mariana Islands'], ['US', 'OH', 'Ohio'], ['US', 'OK', 'Oklahoma'], ['US', 'OR', 'Oregon'], ['US', 'PW', 'Palau'], ['US', 'PA', 'Pennsylvania'], ['US', 'PR', 'Puerto Rico'], ['US', 'RI', 'Rhode Island'], ['US', 'SC', 'South Carolina'], ['US', 'SD', 'South Dakota'], ['US', 'TN', 'Tennessee'], ['US', 'TX', 'Texas'], ['US', 'UT', 'Utah'], ['US', 'VT', 'Vermont'], ['US', 'VI', 'Virgin Islands'], ['US', 'VA', 'Virginia'], ['US', 'WA', 'Washington'], ['US', 'WV', 'West Virginia'], ['US', 'WI', 'Wisconsin'], ['US', 'WY', 'Wyoming'], ['CA', 'AB', 'Alberta'], ['CA', 'BC', 'British Columbia'], ['CA', 'MB', 'Manitoba'], ['CA', 'NL', 'Newfoundland and Labrador'], ['CA', 'NB', 'New Brunswick'], ['CA', 'NS', 'Nova Scotia'], ['CA', 'NT', 'Northwest Territories'], ['CA', 'NU', 'Nunavut'], ['CA', 'ON', 'Ontario'], ['CA', 'PE', 'Prince Edward Island'], ['CA', 'QC', 'Quebec'], ['CA', 'SK', 'Saskatchewan'], ['CA', 'YT', 'Yukon Territory'], ['DE', 'NDS', 'Niedersachsen'], ['DE', 'BAW', 'Baden-Württemberg'], ['DE', 'BAY', 'Bayern'], ['DE', 'BER', 'Berlin'], ['DE', 'BRG', 'Brandenburg'], ['DE', 'BRE', 'Bremen'], ['DE', 'HAM', 'Hamburg'], ['DE', 'HES', 'Hessen'], ['DE', 'MEC', 'Mecklenburg-Vorpommern'], ['DE', 'NRW', 'Nordrhein-Westfalen'], ['DE', 'RHE', 'Rheinland-Pfalz'], ['DE', 'SAR', 'Saarland'], ['DE', 'SAS', 'Sachsen'], ['DE', 'SAC', 'Sachsen-Anhalt'], ['DE', 'SCN', 'Schleswig-Holstein'], ['DE', 'THE', 'Thüringen'], ['AT', 'WI', 'Wien'], ['AT', 'NO', 'Niederösterreich'], ['AT', 'OO', 'Oberösterreich'], ['AT', 'SB', 'Salzburg'], ['AT', 'KN', 'Kärnten'], ['AT', 'ST', 'Steiermark'], ['AT', 'TI', 'Tirol'], ['AT', 'BL', 'Burgenland'], ['AT', 'VB', 'Vorarlberg'], ['CH', 'AG', 'Aargau'], ['CH', 'AI', 'Appenzell Innerrhoden'], ['CH', 'AR', 'Appenzell Ausserrhoden'], ['CH', 'BE', 'Bern'], ['CH', 'BL', 'Basel-Landschaft'], ['CH', 'BS', 'Basel-Stadt'], ['CH', 'FR', 'Freiburg'], ['CH', 'GE', 'Genf'], ['CH', 'GL', 'Glarus'], ['CH', 'GR', 'Graubünden'], ['CH', 'JU', 'Jura'], ['CH', 'LU', 'Luzern'], ['CH', 'NE', 'Neuenburg'], ['CH', 'NW', 'Nidwalden'], ['CH', 'OW', 'Obwalden'], ['CH', 'SG', 'St. Gallen'], ['CH', 'SH', 'Schaffhausen'], ['CH', 'SO', 'Solothurn'], ['CH', 'SZ', 'Schwyz'], ['CH', 'TG', 'Thurgau'], ['CH', 'TI', 'Tessin'], ['CH', 'UR', 'Uri'], ['CH', 'VD', 'Waadt'], ['CH', 'VS', 'Wallis'], ['CH', 'ZG', 'Zug'], ['CH', 'ZH', 'Zürich'], ['ES', 'A Coruсa', 'A Coruña'], ['ES', 'Alava', 'Alava'], ['ES', 'Albacete', 'Albacete'], ['ES', 'Alicante', 'Alicante'], ['ES', 'Almeria', 'Almeria'], ['ES', 'Asturias', 'Asturias'], ['ES', 'Avila', 'Avila'], ['ES', 'Badajoz', 'Badajoz'], ['ES', 'Baleares', 'Baleares'], ['ES', 'Barcelona', 'Barcelona'], ['ES', 'Burgos', 'Burgos'], ['ES', 'Caceres', 'Caceres'], ['ES', 'Cadiz', 'Cadiz'], ['ES', 'Cantabria', 'Cantabria'], ['ES', 'Castellon', 'Castellon'], ['ES', 'Ceuta', 'Ceuta'], ['ES', 'Ciudad Real', 'Ciudad Real'], ['ES', 'Cordoba', 'Cordoba'], ['ES', 'Cuenca', 'Cuenca'], ['ES', 'Girona', 'Girona'], ['ES', 'Granada', 'Granada'], ['ES', 'Guadalajara', 'Guadalajara'], ['ES', 'Guipuzcoa', 'Guipuzcoa'], ['ES', 'Huelva', 'Huelva'], ['ES', 'Huesca', 'Huesca'], ['ES', 'Jaen', 'Jaen'], ['ES', 'La Rioja', 'La Rioja'], ['ES', 'Las Palmas', 'Las Palmas'], ['ES', 'Leon', 'Leon'], ['ES', 'Lleida', 'Lleida'], ['ES', 'Lugo', 'Lugo'], ['ES', 'Madrid', 'Madrid'], ['ES', 'Malaga', 'Malaga'], ['ES', 'Melilla', 'Melilla'], ['ES', 'Murcia', 'Murcia'], ['ES', 'Navarra', 'Navarra'], ['ES', 'Ourense', 'Ourense'], ['ES', 'Palencia', 'Palencia'], ['ES', 'Pontevedra', 'Pontevedra'], ['ES', 'Salamanca', 'Salamanca'], ['ES', 'Santa Cruz de Tenerife', 'Santa Cruz de Tenerife'], ['ES', 'Segovia', 'Segovia'], ['ES', 'Sevilla', 'Sevilla'], ['ES', 'Soria', 'Soria'], ['ES', 'Tarragona', 'Tarragona'], ['ES', 'Teruel', 'Teruel'], ['ES', 'Toledo', 'Toledo'], ['ES', 'Valencia', 'Valencia'], ['ES', 'Valladolid', 'Valladolid'], ['ES', 'Vizcaya', 'Vizcaya'], ['ES', 'Zamora', 'Zamora'], ['ES', 'Zaragoza', 'Zaragoza'], ['FR', 1, 'Ain'], ['FR', 2, 'Aisne'], ['FR', 3, 'Allier'], ['FR', 4, 'Alpes-de-Haute-Provence'], ['FR', 5, 'Hautes-Alpes'], ['FR', 6, 'Alpes-Maritimes'], ['FR', 7, 'Ardèche'], ['FR', 8, 'Ardennes'], ['FR', 9, 'Ariège'], ['FR', 10, 'Aube'], ['FR', 11, 'Aude'], ['FR', 12, 'Aveyron'], ['FR', 13, 'Bouches-du-Rhône'], ['FR', 14, 'Calvados'], ['FR', 15, 'Cantal'], ['FR', 16, 'Charente'], ['FR', 17, 'Charente-Maritime'], ['FR', 18, 'Cher'], ['FR', 19, 'Corrèze'], ['FR', '2A', 'Corse-du-Sud'], ['FR', '2B', 'Haute-Corse'], ['FR', 21, 'Côte-d\'Or'], ['FR', 22, 'Côtes-d\'Armor'], ['FR', 23, 'Creuse'], ['FR', 24, 'Dordogne'], ['FR', 25, 'Doubs'], ['FR', 26, 'Drôme'], ['FR', 27, 'Eure'], ['FR', 28, 'Eure-et-Loir'], ['FR', 29, 'Finistère'], ['FR', 30, 'Gard'], ['FR', 31, 'Haute-Garonne'], ['FR', 32, 'Gers'], ['FR', 33, 'Gironde'], ['FR', 34, 'Hérault'], ['FR', 35, 'Ille-et-Vilaine'], ['FR', 36, 'Indre'], ['FR', 37, 'Indre-et-Loire'], ['FR', 38, 'Isère'], ['FR', 39, 'Jura'], ['FR', 40, 'Landes'], ['FR', 41, 'Loir-et-Cher'], ['FR', 42, 'Loire'], ['FR', 43, 'Haute-Loire'], ['FR', 44, 'Loire-Atlantique'], ['FR', 45, 'Loiret'], ['FR', 46, 'Lot'], ['FR', 47, 'Lot-et-Garonne'], ['FR', 48, 'Lozère'], ['FR', 49, 'Maine-et-Loire'], ['FR', 50, 'Manche'], ['FR', 51, 'Marne'], ['FR', 52, 'Haute-Marne'], ['FR', 53, 'Mayenne'], ['FR', 54, 'Meurthe-et-Moselle'], ['FR', 55, 'Meuse'], ['FR', 56, 'Morbihan'], ['FR', 57, 'Moselle'], ['FR', 58, 'Nièvre'], ['FR', 59, 'Nord'], ['FR', 60, 'Oise'], ['FR', 61, 'Orne'], ['FR', 62, 'Pas-de-Calais'], ['FR', 63, 'Puy-de-Dôme'], ['FR', 64, 'Pyrénées-Atlantiques'], ['FR', 65, 'Hautes-Pyrénées'], ['FR', 66, 'Pyrénées-Orientales'], ['FR', 67, 'Bas-Rhin'], ['FR', 68, 'Haut-Rhin'], ['FR', 69, 'Rhône'], ['FR', 70, 'Haute-Saône'], ['FR', 71, 'Saône-et-Loire'], ['FR', 72, 'Sarthe'], ['FR', 73, 'Savoie'], ['FR', 74, 'Haute-Savoie'], ['FR', 75, 'Paris'], ['FR', 76, 'Seine-Maritime'], ['FR', 77, 'Seine-et-Marne'], ['FR', 78, 'Yvelines'], ['FR', 79, 'Deux-Sèvres'], ['FR', 80, 'Somme'], ['FR', 81, 'Tarn'], ['FR', 82, 'Tarn-et-Garonne'], ['FR', 83, 'Var'], ['FR', 84, 'Vaucluse'], ['FR', 85, 'Vendée'], ['FR', 86, 'Vienne'], ['FR', 87, 'Haute-Vienne'], ['FR', 88, 'Vosges'], ['FR', 89, 'Yonne'], ['FR', 90, 'Territoire-de-Belfort'], ['FR', 91, 'Essonne'], ['FR', 92, 'Hauts-de-Seine'], ['FR', 93, 'Seine-Saint-Denis'], ['FR', 94, 'Val-de-Marne'], ['FR', 95, 'Val-d\'Oise'], ['RO', 'AB', 'Alba'], ['RO', 'AR', 'Arad'], ['RO', 'AG', 'Argeş'], ['RO', 'BC', 'Bacău'], ['RO', 'BH', 'Bihor'], ['RO', 'BN', 'Bistriţa-Năsăud'], ['RO', 'BT', 'Botoşani'], ['RO', 'BV', 'Braşov'], ['RO', 'BR', 'Brăila'], ['RO', 'B', 'Bucureşti'], ['RO', 'BZ', 'Buzău'], ['RO', 'CS', 'Caraş-Severin'], ['RO', 'CL', 'Călăraşi'], ['RO', 'CJ', 'Cluj'], ['RO', 'CT', 'Constanţa'], ['RO', 'CV', 'Covasna'], ['RO', 'DB', 'Dâmboviţa'], ['RO', 'DJ', 'Dolj'], ['RO', 'GL', 'Galaţi'], ['RO', 'GR', 'Giurgiu'], ['RO', 'GJ', 'Gorj'], ['RO', 'HR', 'Harghita'], ['RO', 'HD', 'Hunedoara'], ['RO', 'IL', 'Ialomiţa'], ['RO', 'IS', 'Iaşi'], ['RO', 'IF', 'Ilfov'], ['RO', 'MM', 'Maramureş'], ['RO', 'MH', 'Mehedinţi'], ['RO', 'MS', 'Mureş'], ['RO', 'NT', 'Neamţ'], ['RO', 'OT', 'Olt'], ['RO', 'PH', 'Prahova'], ['RO', 'SM', 'Satu-Mare'], ['RO', 'SJ', 'Sălaj'], ['RO', 'SB', 'Sibiu'], ['RO', 'SV', 'Suceava'], ['RO', 'TR', 'Teleorman'], ['RO', 'TM', 'Timiş'], ['RO', 'TL', 'Tulcea'], ['RO', 'VS', 'Vaslui'], ['RO', 'VL', 'Vâlcea'], ['RO', 'VN', 'Vrancea'], ['FI', 'Lappi', 'Lappi'], ['FI', 'Pohjois-Pohjanmaa', 'Pohjois-Pohjanmaa'], ['FI', 'Kainuu', 'Kainuu'], ['FI', 'Pohjois-Karjala', 'Pohjois-Karjala'], ['FI', 'Pohjois-Savo', 'Pohjois-Savo'], ['FI', 'Etelä-Savo', 'Etelä-Savo'], ['FI', 'Etelä-Pohjanmaa', 'Etelä-Pohjanmaa'], ['FI', 'Pohjanmaa', 'Pohjanmaa'], ['FI', 'Pirkanmaa', 'Pirkanmaa'], ['FI', 'Satakunta', 'Satakunta'], ['FI', 'Keski-Pohjanmaa', 'Keski-Pohjanmaa'], ['FI', 'Keski-Suomi', 'Keski-Suomi'], ['FI', 'Varsinais-Suomi', 'Varsinais-Suomi'], ['FI', 'Etelä-Karjala', 'Etelä-Karjala'], ['FI', 'Päijät-Häme', 'Päijät-Häme'], ['FI', 'Kanta-Häme', 'Kanta-Häme'], ['FI', 'Uusimaa', 'Uusimaa'], ['FI', 'Itä-Uusimaa', 'Itä-Uusimaa'], ['FI', 'Kymenlaakso', 'Kymenlaakso'], ['FI', 'Ahvenanmaa', 'Ahvenanmaa'], ['EE', 'EE-37', 'Harjumaa'], ['EE', 'EE-39', 'Hiiumaa'], ['EE', 'EE-44', 'Ida-Virumaa'], ['EE', 'EE-49', 'Jõgevamaa'], ['EE', 'EE-51', 'Järvamaa'], ['EE', 'EE-57', 'Läänemaa'], ['EE', 'EE-59', 'Lääne-Virumaa'], ['EE', 'EE-65', 'Põlvamaa'], ['EE', 'EE-67', 'Pärnumaa'], ['EE', 'EE-70', 'Raplamaa'], ['EE', 'EE-74', 'Saaremaa'], ['EE', 'EE-78', 'Tartumaa'], ['EE', 'EE-82', 'Valgamaa'], ['EE', 'EE-84', 'Viljandimaa'], ['EE', 'EE-86', 'Võrumaa'], ['LV', 'LV-DGV', 'Daugavpils'], ['LV', 'LV-JEL', 'Jelgava'], ['LV', 'Jēkabpils', 'Jēkabpils'], ['LV', 'LV-JUR', 'Jūrmala'], ['LV', 'LV-LPX', 'Liepāja'], ['LV', 'LV-LE', 'Liepājas novads'], ['LV', 'LV-REZ', 'Rēzekne'], ['LV', 'LV-RIX', 'Rīga'], ['LV', 'LV-RI', 'Rīgas novads'], ['LV', 'Valmiera', 'Valmiera'], ['LV', 'LV-VEN', 'Ventspils'], ['LV', 'Aglonas novads', 'Aglonas novads'], ['LV', 'LV-AI', 'Aizkraukles novads'], ['LV', 'Aizputes novads', 'Aizputes novads'], ['LV', 'Aknīstes novads', 'Aknīstes novads'], ['LV', 'Alojas novads', 'Alojas novads'], ['LV', 'Alsungas novads', 'Alsungas novads'], ['LV', 'LV-AL', 'Alūksnes novads'], ['LV', 'Amatas novads', 'Amatas novads'], ['LV', 'Apes novads', 'Apes novads'], ['LV', 'Auces novads', 'Auces novads'], ['LV', 'Babītes novads', 'Babītes novads'], ['LV', 'Baldones novads', 'Baldones novads'], ['LV', 'Baltinavas novads', 'Baltinavas novads'], ['LV', 'LV-BL', 'Balvu novads'], ['LV', 'LV-BU', 'Bauskas novads'], ['LV', 'Beverīnas novads', 'Beverīnas novads'], ['LV', 'Brocēnu novads', 'Brocēnu novads'], ['LV', 'Burtnieku novads', 'Burtnieku novads'], ['LV', 'Carnikavas novads', 'Carnikavas novads'], ['LV', 'Cesvaines novads', 'Cesvaines novads'], ['LV', 'Ciblas novads', 'Ciblas novads'], ['LV', 'LV-CE', 'Cēsu novads'], ['LV', 'Dagdas novads', 'Dagdas novads'], ['LV', 'LV-DA', 'Daugavpils novads'], ['LV', 'LV-DO', 'Dobeles novads'], ['LV', 'Dundagas novads', 'Dundagas novads'], ['LV', 'Durbes novads', 'Durbes novads'], ['LV', 'Engures novads', 'Engures novads'], ['LV', 'Garkalnes novads', 'Garkalnes novads'], ['LV', 'Grobiņas novads', 'Grobiņas novads'], ['LV', 'LV-GU', 'Gulbenes novads'], ['LV', 'Iecavas novads', 'Iecavas novads'], ['LV', 'Ikšķiles novads', 'Ikšķiles novads'], ['LV', 'Ilūkstes novads', 'Ilūkstes novads'], ['LV', 'Inčukalna novads', 'Inčukalna novads'], ['LV', 'Jaunjelgavas novads', 'Jaunjelgavas novads'], ['LV', 'Jaunpiebalgas novads', 'Jaunpiebalgas novads'], ['LV', 'Jaunpils novads', 'Jaunpils novads'], ['LV', 'LV-JL', 'Jelgavas novads'], ['LV', 'LV-JK', 'Jēkabpils novads'], ['LV', 'Kandavas novads', 'Kandavas novads'], ['LV', 'Kokneses novads', 'Kokneses novads'], ['LV', 'Krimuldas novads', 'Krimuldas novads'], ['LV', 'Krustpils novads', 'Krustpils novads'], ['LV', 'LV-KR', 'Krāslavas novads'], ['LV', 'LV-KU', 'Kuldīgas novads'], ['LV', 'Kārsavas novads', 'Kārsavas novads'], ['LV', 'Lielvārdes novads', 'Lielvārdes novads'], ['LV', 'LV-LM', 'Limbažu novads'], ['LV', 'Lubānas novads', 'Lubānas novads'], ['LV', 'LV-LU', 'Ludzas novads'], ['LV', 'Līgatnes novads', 'Līgatnes novads'], ['LV', 'Līvānu novads', 'Līvānu novads'], ['LV', 'LV-MA', 'Madonas novads'], ['LV', 'Mazsalacas novads', 'Mazsalacas novads'], ['LV', 'Mālpils novads', 'Mālpils novads'], ['LV', 'Mārupes novads', 'Mārupes novads'], ['LV', 'Naukšēnu novads', 'Naukšēnu novads'], ['LV', 'Neretas novads', 'Neretas novads'], ['LV', 'Nīcas novads', 'Nīcas novads'], ['LV', 'LV-OG', 'Ogres novads'], ['LV', 'Olaines novads', 'Olaines novads'], ['LV', 'Ozolnieku novads', 'Ozolnieku novads'], ['LV', 'LV-PR', 'Preiļu novads'], ['LV', 'Priekules novads', 'Priekules novads'], ['LV', 'Priekuļu novads', 'Priekuļu novads'], ['LV', 'Pārgaujas novads', 'Pārgaujas novads'], ['LV', 'Pāvilostas novads', 'Pāvilostas novads'], ['LV', 'Pļaviņu novads', 'Pļaviņu novads'], ['LV', 'Raunas novads', 'Raunas novads'], ['LV', 'Riebiņu novads', 'Riebiņu novads'], ['LV', 'Rojas novads', 'Rojas novads'], ['LV', 'Ropažu novads', 'Ropažu novads'], ['LV', 'Rucavas novads', 'Rucavas novads'], ['LV', 'Rugāju novads', 'Rugāju novads'], ['LV', 'Rundāles novads', 'Rundāles novads'], ['LV', 'LV-RE', 'Rēzeknes novads'], ['LV', 'Rūjienas novads', 'Rūjienas novads'], ['LV', 'Salacgrīvas novads', 'Salacgrīvas novads'], ['LV', 'Salas novads', 'Salas novads'], ['LV', 'Salaspils novads', 'Salaspils novads'], ['LV', 'LV-SA', 'Saldus novads'], ['LV', 'Saulkrastu novads', 'Saulkrastu novads'], ['LV', 'Siguldas novads', 'Siguldas novads'], ['LV', 'Skrundas novads', 'Skrundas novads'], ['LV', 'Skrīveru novads', 'Skrīveru novads'], ['LV', 'Smiltenes novads', 'Smiltenes novads'], ['LV', 'Stopiņu novads', 'Stopiņu novads'], ['LV', 'Strenču novads', 'Strenču novads'], ['LV', 'Sējas novads', 'Sējas novads'], ['LV', 'LV-TA', 'Talsu novads'], ['LV', 'LV-TU', 'Tukuma novads'], ['LV', 'Tērvetes novads', 'Tērvetes novads'], ['LV', 'Vaiņodes novads', 'Vaiņodes novads'], ['LV', 'LV-VK', 'Valkas novads'], ['LV', 'LV-VM', 'Valmieras novads'], ['LV', 'Varakļānu novads', 'Varakļānu novads'], ['LV', 'Vecpiebalgas novads', 'Vecpiebalgas novads'], ['LV', 'Vecumnieku novads', 'Vecumnieku novads'], ['LV', 'LV-VE', 'Ventspils novads'], ['LV', 'Viesītes novads', 'Viesītes novads'], ['LV', 'Viļakas novads', 'Viļakas novads'], ['LV', 'Viļānu novads', 'Viļānu novads'], ['LV', 'Vārkavas novads', 'Vārkavas novads'], ['LV', 'Zilupes novads', 'Zilupes novads'], ['LV', 'Ādažu novads', 'Ādažu novads'], ['LV', 'Ērgļu novads', 'Ērgļu novads'], ['LV', 'Ķeguma novads', 'Ķeguma novads'], ['LV', 'Ķekavas novads', 'Ķekavas novads'], ['LT', 'LT-AL', 'Alytaus Apskritis'], ['LT', 'LT-KU', 'Kauno Apskritis'], ['LT', 'LT-KL', 'Klaipėdos Apskritis'], ['LT', 'LT-MR', 'Marijampolės Apskritis'], ['LT', 'LT-PN', 'Panevėžio Apskritis'], ['LT', 'LT-SA', 'Šiaulių Apskritis'], ['LT', 'LT-TA', 'Tauragės Apskritis'], ['LT', 'LT-TE', 'Telšių Apskritis'], ['LT', 'LT-UT', 'Utenos Apskritis'], ['LT', 'LT-VL', 'Vilniaus Apskritis'], ['BR', 'AC', 'Acre'], ['BR', 'AL', 'Alagoas'], ['BR', 'AP', 'Amapá'], ['BR', 'AM', 'Amazonas'], ['BR', 'BA', 'Bahia'], ['BR', 'CE', 'Ceará'], ['BR', 'ES', 'Espírito Santo'], ['BR', 'GO', 'Goiás'], ['BR', 'MA', 'Maranhão'], ['BR', 'MT', 'Mato Grosso'], ['BR', 'MS', 'Mato Grosso do Sul'], ['BR', 'MG', 'Minas Gerais'], ['BR', 'PA', 'Pará'], ['BR', 'PB', 'Paraíba'], ['BR', 'PR', 'Paraná'], ['BR', 'PE', 'Pernambuco'], ['BR', 'PI', 'Piauí'], ['BR', 'RJ', 'Rio de Janeiro'], ['BR', 'RN', 'Rio Grande do Norte'], ['BR', 'RS', 'Rio Grande do Sul'], ['BR', 'RO', 'Rondônia'], ['BR', 'RR', 'Roraima'], ['BR', 'SC', 'Santa Catarina'], ['BR', 'SP', 'São Paulo'], ['BR', 'SE', 'Sergipe'], ['BR', 'TO', 'Tocantins'], ['BR', 'DF', 'Distrito Federal']];
     foreach ($data as $row) {
         $bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
         $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
         $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
         $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
         $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
     }
     /**
      * Fill table directory/currency_rate
      */
     $data = [['EUR', 'EUR', 1], ['EUR', 'USD', 1.415], ['USD', 'EUR', 0.7067], ['USD', 'USD', 1]];
     $columns = ['currency_from', 'currency_to', 'rate'];
     $setup->getConnection()->insertArray($setup->getTable('directory_currency_rate'), $columns, $data);
     $setup->getConnection()->insert($setup->getTable('core_config_data'), ['scope' => 'default', 'scope_id' => 0, 'path' => Data::XML_PATH_DISPLAY_ALL_STATES, 'value' => 1]);
     $countries = $this->directoryData->getCountryCollection()->getCountriesWithRequiredStates();
     $setup->getConnection()->insert($setup->getTable('core_config_data'), ['scope' => 'default', 'scope_id' => 0, 'path' => Data::XML_PATH_STATES_REQUIRED, 'value' => implode(',', array_keys($countries))]);
 }
Esempio n. 16
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var \Magento\Sales\Setup\SalesSetup $salesSetup */
     $salesSetup = $this->salesSetupFactory->create();
     /**
      * Install eav entity types to the eav/entity_type table
      */
     $salesSetup->installEntities();
     /**
      * Install order statuses from config
      */
     $data = [];
     $statuses = ['pending' => __('Pending'), 'pending_payment' => __('Pending Payment'), 'processing' => __('Processing'), 'holded' => __('On Hold'), 'complete' => __('Complete'), 'closed' => __('Closed'), 'canceled' => __('Canceled'), 'fraud' => __('Suspected Fraud'), 'payment_review' => __('Payment Review')];
     foreach ($statuses as $code => $info) {
         $data[] = ['status' => $code, 'label' => $info];
     }
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $data);
     /**
      * Install order states from config
      */
     $data = [];
     $states = ['new' => ['label' => __('New'), 'statuses' => ['pending' => ['default' => '1']], 'visible_on_front' => true], 'pending_payment' => ['label' => __('Pending Payment'), 'statuses' => ['pending_payment' => ['default' => '1']]], 'processing' => ['label' => __('Processing'), 'statuses' => ['processing' => ['default' => '1'], 'fraud' => []], 'visible_on_front' => true], 'complete' => ['label' => __('Complete'), 'statuses' => ['complete' => ['default' => '1']], 'visible_on_front' => true], 'closed' => ['label' => __('Closed'), 'statuses' => ['closed' => ['default' => '1']], 'visible_on_front' => true], 'canceled' => ['label' => __('Canceled'), 'statuses' => ['canceled' => ['default' => '1']], 'visible_on_front' => true], 'holded' => ['label' => __('On Hold'), 'statuses' => ['holded' => ['default' => '1']], 'visible_on_front' => true], 'payment_review' => ['label' => __('Payment Review'), 'statuses' => ['payment_review' => ['default' => '1'], 'fraud' => []], 'visible_on_front' => true]];
     foreach ($states as $code => $info) {
         if (isset($info['statuses'])) {
             foreach ($info['statuses'] as $status => $statusInfo) {
                 $data[] = ['status' => $status, 'state' => $code, 'is_default' => is_array($statusInfo) && isset($statusInfo['default']) ? 1 : 0];
             }
         }
     }
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status_state'), ['status', 'state', 'is_default'], $data);
     $entitiesToAlter = ['order_address'];
     $attributes = ['vat_id' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT], 'vat_is_valid' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT], 'vat_request_id' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT], 'vat_request_date' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT], 'vat_request_success' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT]];
     foreach ($entitiesToAlter as $entityName) {
         foreach ($attributes as $attributeCode => $attributeParams) {
             $salesSetup->addAttribute($entityName, $attributeCode, $attributeParams);
         }
     }
     /** Update visibility for states */
     $states = ['new', 'processing', 'complete', 'closed', 'canceled', 'holded', 'payment_review'];
     foreach ($states as $state) {
         $setup->getConnection()->update($setup->getTable('sales_order_status_state'), ['visible_on_front' => 1], ['state = ?' => $state]);
     }
 }
Esempio n. 17
0
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     $data = [];
     $statuses = ['riskified_holded' => __('Under Review (Riskified)'), 'riskified_trans_error' => __('Transport Error (Riskified)'), 'riskified_declined' => __('Declined (Riskified)'), 'riskified_approved' => __('Approved (Riskified)')];
     foreach ($statuses as $code => $info) {
         $data[] = ['status' => $code, 'label' => $info];
     }
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $data);
     $stateData = [];
     $stateData[] = ['status' => 'riskified_approved', 'state' => 'holded', 'is_default' => 0, 'visible_on_front' => 0];
     $stateData[] = ['status' => 'riskified_declined', 'state' => 'canceled', 'is_default' => 0, 'visible_on_front' => 0];
     $stateData[] = ['status' => 'riskified_trans_error', 'state' => 'holded', 'is_default' => 0, 'visible_on_front' => 0];
     $stateData[] = ['status' => 'riskified_declined', 'state' => 'holded', 'is_default' => 0, 'visible_on_front' => 0];
     $stateData[] = ['status' => 'riskified_holded', 'state' => 'holded', 'is_default' => 0, 'visible_on_front' => 0];
     $stateData[] = ['status' => 'riskified_approved', 'state' => 'processing', 'is_default' => 0, 'visible_on_front' => 0];
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status_state'), ['status', 'state', 'is_default', 'visible_on_front'], $stateData);
     $setup->endSetup();
 }
Esempio n. 18
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     $data = ['title' => 'title', 'link' => 'link', 'status' => 'status', 'image_link' => 'image_link', 'thumbnail_label' => 'thumbnail_label', 'rating' => 'rating', 'short_description' => 'short_description', 'mag_id' => 'mag_id', 'visible' => 'visible', 'store_id' => 'store_id', 'is_in_stock' => 'is_in_stock', 'sku' => 'sku', 'category' => 'category', 'websites' => 'websites', 'news_from_date' => 'news_from_date', 'news_to_date' => 'news_to_date'];
     $id = 1;
     foreach ($data as $xml_field => $code_field) {
         $setup->getConnection()->insertForce($setup->getTable('celebros_mapping'), ['id' => $id, 'xml_field' => $xml_field, 'code_field' => $code_field]);
         $id++;
     }
     $setup->endSetup();
 }
Esempio n. 19
0
 /**
  * Install Data
  *
  * @param ModuleDataSetupInterface $setup   Module Data Setup
  * @param ModuleContextInterface   $context Module Context
  *
  * @return void
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Fill table directory/country_region
      * Fill table directory/country_region_name for en_US locale
      */
     $data = [['JP', '01', 'Hokkaido', '北海道'], ['JP', '02', 'Aomori', '青森県'], ['JP', '03', 'Iwate', '岩手県'], ['JP', '04', 'Miyagi', '宮城県'], ['JP', '05', 'Akita', '秋田県'], ['JP', '06', 'Yamagata', '山形県'], ['JP', '07', 'Fukushima', '福島県'], ['JP', '08', 'Ibaraki', '茨城県'], ['JP', '09', 'Tochigi', '栃木県'], ['JP', '10', 'Gunma', '群馬県'], ['JP', '11', 'Saitama', '埼玉県'], ['JP', '12', 'Chiba', '千葉県'], ['JP', '13', 'Tokyo', '東京都'], ['JP', '14', 'Kanagawa', '神奈川県'], ['JP', '15', 'Niigata', '新潟県'], ['JP', '16', 'Toyama', '富山県'], ['JP', '17', 'Ishikawa', '石川県'], ['JP', '18', 'Fukui', '福井県'], ['JP', '19', 'Yamanashi', '山梨県'], ['JP', '20', 'Nagano', '長野県'], ['JP', '21', 'Gifu', '岐阜県'], ['JP', '22', 'Shizuoka', '静岡県'], ['JP', '23', 'Aichi', '愛知県'], ['JP', '24', 'Mie', '三重県'], ['JP', '25', 'Shiga', '滋賀県'], ['JP', '26', 'Kyoto', '京都府'], ['JP', '27', 'Osaka', '大阪府'], ['JP', '28', 'Hyogo', '兵庫県'], ['JP', '29', 'Nara', '奈良県'], ['JP', '30', 'Wakayama', '和歌山県'], ['JP', '31', 'Tottori', '鳥取県'], ['JP', '32', 'Shimane', '島根県'], ['JP', '33', 'Okayama', '岡山県'], ['JP', '34', 'Hiroshima', '広島県'], ['JP', '35', 'Yamaguchi', '山口県'], ['JP', '36', 'Tokushima', '徳島県'], ['JP', '37', 'Kagawa', '香川県'], ['JP', '38', 'Ehime', '愛媛県'], ['JP', '39', 'Kochi', '高知県'], ['JP', '40', 'Fukuoka', '福岡県'], ['JP', '41', 'Saga', '佐賀県'], ['JP', '42', 'Nagasaki', '長崎県'], ['JP', '43', 'Kumamoto', '熊本県'], ['JP', '44', 'Oita', '大分県'], ['JP', '45', 'Miyazaki', '宮崎県'], ['JP', '46', 'Kagoshima', '鹿児島県'], ['JP', '47', 'Okinawa', '沖縄県']];
     $connection = $setup->getConnection();
     $regionTable = $setup->getTable('directory_country_region');
     $regionNameTable = $setup->getTable('directory_country_region_name');
     foreach ($data as $row) {
         $bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
         $connection->insertOnDuplicate($regionTable, $bind);
         $regionId = $connection->lastInsertId($regionTable);
         $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
         $connection->insertOnDuplicate($regionNameTable, $bind);
         $bind = ['locale' => 'ja_JP', 'region_id' => $regionId, 'name' => $row[3]];
         $connection->insertOnDuplicate($regionNameTable, $bind);
     }
 }
Esempio n. 20
0
 /**
  * Upgrade the module data.
  *
  * @param ModuleDataSetupInterface $setup   The setup interface
  * @param ModuleContextInterface   $context The module Context
  *
  * @return void
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     $this->eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
     if (version_compare($context->getVersion(), '1.2.0', '<')) {
         $this->updateCategorySearchableAttributes();
     }
     if (version_compare($context->getVersion(), '1.2.1', '<')) {
         $productImageAttributeId = $this->eavSetup->getAttributeId(\Magento\Catalog\Model\Product::ENTITY, 'image');
         $setup->getConnection()->update($setup->getTable('catalog_eav_attribute'), ['is_searchable' => 1], $setup->getConnection()->quoteInto('attribute_id = ?', $productImageAttributeId));
     }
     $setup->endSetup();
 }
Esempio n. 21
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var TaxSetup $taxSetup */
     $taxSetup = $this->taxSetupFactory->create(['resourceName' => 'tax_setup', 'setup' => $setup]);
     /**
      * Add tax_class_id attribute to the 'eav_attribute' table
      */
     $taxSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'tax_class_id', ['group' => 'Product Details', 'sort_order' => 40, 'type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'Tax Class', 'input' => 'select', 'class' => '', 'source' => 'Magento\\Tax\\Model\\TaxClass\\Source\\Product', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '2', 'searchable' => true, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'visible_in_advanced_search' => false, 'used_in_product_listing' => true, 'unique' => false, 'apply_to' => implode(',', $taxSetup->getTaxableItems()), 'is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true]);
     /**
      * install tax classes
      */
     $data = [['class_id' => 2, 'class_name' => 'Taxable Goods', 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT], ['class_id' => 3, 'class_name' => 'Retail Customer', 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER]];
     foreach ($data as $row) {
         $setup->getConnection()->insertForce($setup->getTable('tax_class'), $row);
     }
     /**
      * install tax calculation rates
      */
     $data = [['tax_calculation_rate_id' => 1, 'tax_country_id' => 'US', 'tax_region_id' => 12, 'tax_postcode' => '*', 'code' => 'US-CA-*-Rate 1', 'rate' => '8.2500'], ['tax_calculation_rate_id' => 2, 'tax_country_id' => 'US', 'tax_region_id' => 43, 'tax_postcode' => '*', 'code' => 'US-NY-*-Rate 1', 'rate' => '8.3750']];
     foreach ($data as $row) {
         $setup->getConnection()->insertForce($setup->getTable('tax_calculation_rate'), $row);
     }
 }
Esempio n. 22
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->getConnection()->insertForce($setup->getTable('cataloginventory_stock'), ['stock_id' => 1, 'stock_name' => 'Default']);
     /** @var EavSetup $eavSetup */
     $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
     $groupName = 'Product Details';
     $entityTypeId = $eavSetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
     $attributeSetId = $eavSetup->getAttributeSetId($entityTypeId, 'Default');
     $attribute = $eavSetup->getAttribute($entityTypeId, 'quantity_and_stock_status');
     if ($attribute) {
         $eavSetup->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, $attribute['attribute_id'], 60);
         $eavSetup->updateAttribute($entityTypeId, $attribute['attribute_id'], 'default_value', 1);
     }
 }
Esempio n. 23
0
 /**
  * Migration from 1.0.0 to 1.1.0 :
  *   - Updating the attribute virtual_category_root from type varchar to type int
  *   - Updating the value of the attribute from 'category/13' to '13.
  *
  * @param ModuleDataSetupInterface $setup Setup.
  *
  * @return $this
  */
 private function updateVirtualCategoryRootTypeToInt(ModuleDataSetupInterface $setup)
 {
     /**
      * @var \Magento\Eav\Setup\EavSetup $eavSetup
      */
     $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
     // Fix the attribute type.
     $eavSetup->updateAttribute(Category::ENTITY, 'virtual_category_root', 'backend_type', 'int');
     // Retrieve information about the attribute and storage config.
     $virtualRootAttributeId = $eavSetup->getAttribute(Category::ENTITY, 'virtual_category_root', 'attribute_id');
     $originalTable = $setup->getTable('catalog_category_entity_varchar');
     $targetTable = $setup->getTable('catalog_category_entity_int');
     $baseFields = array_slice(array_keys($setup->getConnection()->describeTable($originalTable)), 1, -1);
     // Select old value.
     $valueSelect = $setup->getConnection()->select();
     $valueSelect->from($setup->getTable('catalog_category_entity_varchar'), $baseFields)->where('attribute_id = ?', $virtualRootAttributeId)->columns(['value' => new \Zend_Db_Expr('REPLACE(value, "category/", "")')]);
     // Insert old values into the new table.
     $query = $setup->getConnection()->insertFromSelect($valueSelect, $targetTable, array_merge($baseFields, ['value']), AdapterInterface::INSERT_IGNORE);
     $setup->getConnection()->query($query);
     // Delete old value.
     $setup->getConnection()->delete($originalTable, "attribute_id = {$virtualRootAttributeId}");
     return $this;
 }
Esempio n. 24
0
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '1.0.1') < 0) {
         $tableName = $setup->getTable('rapidmage_rules');
         if ($setup->getConnection()->isTableExists($tableName) == true) {
             // Declare data
             $data = [['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT', 'what' => '(?:\\.{2}[\\/]{1,4}){2}\\b', 'why' => 'Directory traversal', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|REQUEST_URI|PHP_SELF|PATH_INFO', 'what' => '%00|\\x00', 'why' => 'NULL byte character', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT', 'what' => '[.\\/]/(?:proc/self/|etc/passwd)\\b', 'why' => 'Local file inclusion', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT', 'what' => '^(?i:https?|ftp)://.+/[^&/]+\\?$', 'why' => 'Remote file inclusion', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT', 'what' => '^(?i:https?)://\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}', 'why' => 'Remote file inclusion (URL IP)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT', 'what' => '\\b(?i:include|require)(?i:_once)?\\s*\\([^)]*(?i:https?|ftp)://', 'why' => 'Remote file inclusion (via require/include)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT', 'what' => '^(?i:ftp)://(?:.+?:.+?\\@)?[^/]+/.', 'why' => 'Remote file inclusion (FTP)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|REQUEST_URI|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '<\\s*/?(?i:applet|div|embed|i?frame(?:set)?|img|meta|marquee|object|script|textarea)\\b.*?>', 'why' => 'XSS (HTML tag)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\W(?:background(-image)?|-moz-binding)\\s*:[^}]*?\\burl\\s*\\([^)]+?://', 'why' => 'XSS (remote background URI)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '(?i:<[^>]+?(?:data|href|src)\\s*=\\s*[\'\\"]?(?:https?|data|php|(?:java|vb)script):)', 'why' => 'XSS (remote URI)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\b(?i:on(?i:abort|blur|(?:dbl)?click|dragdrop|error|focus|key(?:up|down|press)|(?:un)?load|mouse(?:down|out|over|up)|move|res(?:et|ize)|select|submit))\\b\\s*=', 'why' => 'XSS (HTML event)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '[:=\\]]\\s*[\'\\"]?(?:alert|confirm|eval|expression|prompt|String\\.fromCharCode|url)\\s*\\(', 'why' => 'XSS (JS function)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\bdocument\\.(?:body|cookie|location|open|write(?:ln)?)\\b', 'why' => 'XSS (document object)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\blocation\\.(?:href|replace)\\b', 'why' => 'XSS (location object)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\bwindow\\.(?:open|location)\\b', 'why' => 'XSS (window object)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '(?i:style)\\s*=\\s*[\'"]?[^/\'"]+/\\*', 'why' => 'XSS (obfuscated style)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '^/?>', 'why' => 'XSS (leading greater-than sign)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING', 'what' => '(?:%%\\d\\d%\\d\\d){5}', 'why' => 'XSS (double nibble)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|REQUEST_URI|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '(\\+|\\%2B)A(Dw|ACIAPgA8)-.+?(\\+|\\%2B)AD4(APAAi)?-', 'why' => 'XSS (UTF-7)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '[\\n\\r]\\s*\\b(?:(?:reply-)?to|b?cc|content-[td]\\w)\\b\\s*:.*?\\@', 'why' => 'Mail header injection', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '^[\\x0d\\x0a]{1,2}[-a-zA-Z0-9]+:\\s*\\w+', 'why' => 'HTTP header injection', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '[\\x0d\\x0a]', 'why' => 'HTTP header injection (CR/LF)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '<!--#(?:config|echo|exec|flastmod|fsize|include)\\b.+?-->', 'why' => 'SSI command injection', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '(?s:<\\?.+)|#!/(?:usr|bin)/.+?\\s', 'why' => 'Code Injection', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?s:<\\?(?![Xx][Mm][Ll]).*?(?:\\$_?(?:COOKIE|ENV|FILES|GLOBALS|(?:GE|POS|REQUES)T|SE(RVER|SSION))\\s*[=\\[)]|\\b(?i:array_map|assert|base64_(?:de|en)code|curl_exec|eval|file(?:_get_contents)?|fsockopen|gzinflate|move_uploaded_file|passthru|preg_replace|phpinfo|stripslashes|strrev|system|(?:shell_)?exec)\\s*\\()|\\x60.+?\\x60)|#!/(?:usr|bin)/.+?\\s|\\W\\$\\{\\s*[\'"]\\w+[\'"]', 'why' => 'Code Injection', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '\\b(?i:eval)\\s*\\(\\s*(?i:base64_decode|exec|file_get_contents|gzinflate|passthru|shell_exec|stripslashes|system)\\s*\\(', 'why' => 'Code Injection #2', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:fltr', 'what' => ';', 'why' => 'Code injection (phpThumb)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:file_to_serve', 'what' => 'flowplayer/3\\.1\\.1/flowplayer-3\\.1\\.1\\.min.js', 'why' => 'Code injection (OpenX backdoor)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:phpThumbDebug', 'what' => '.', 'why' => 'phpThumb debug mode (potential SSRF)', 'level' => '1', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE', 'what' => '^(?i:admin(?:istrator)?)[\'"].*?(?:--|#|/\\*)', 'why' => 'SQL injection (admin login attempt)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '\\b(?i:[-\\w]+@(?:[-a-z0-9]+\\.)+[a-z]{2,8}\'.{0,20}\\band\\b.{0,20}=[\\s/*]*\')', 'why' => 'SQL injection (user login attempt)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:username|POST:username', 'what' => '[#\'"=(),<>/\\*\\x60]', 'why' => 'SQL injection (username)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\b(?i:and|or|having)\\b.+?[\'"]?(\\w+)[\'"]?\\s*=\\s*[\'"]?\\1', 'why' => 'SQL injection (equal operator)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\bfrom\\b.+?information_schema\\b)', 'why' => 'SQL injection (information_schema)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '/\\*\\*/(?i:and|from|limit|or|select|union|request)/\\*\\*/', 'why' => 'SQL injection (comment obfuscation)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '^[-\\d\';].+\\w.+(?:--|#|/\\*)\\s*$', 'why' => 'SQL injection (trailing comment)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\b(?:alter|create|delete|drop|grant|information_schema|insert|load|rename|select|truncate|update)[^-\\w])', 'why' => 'SQL injection', 'level' => '1', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?(?:\\ball\\b.+?)?\\bselect\\b.+?\\b(?:and\\b|from\\b|limit\\b|request\\b|\\@?\\@?version\\b|(?:user|benchmark|char|count|database|(?:group_)?concat(?:_ws)?|floor|md5|rand|substring|version)\\s*\\(|--|/\\*|#$))', 'why' => 'SQL injection (select)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?(?:\\ball\\b.+?)?\\binsert\\b.+?\\binto\\b.*?\\([^)]+\\).+?values.*?\\()', 'why' => 'SQL injection (insert)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\bupdate\\b.+?\\bset\\b.+?=)', 'why' => 'SQL injection (update)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\bgrant\\b.+?\\bon\\b.+?to\\s+)', 'why' => 'SQL injection (grant)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\bdelete\\b.+?\\bfrom\\b.+)', 'why' => 'SQL injection (delete)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\b(alter|create|drop)\\b.+?(?:DATABASE|FUNCTION|INDEX|PROCEDURE|SCHEMA|TABLE|TRIGGER|VIEW)\\b.+?)', 'why' => 'SQL injection (alter/create/drop)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\b(?:rename|truncate)\\b.+?table)', 'why' => 'SQL injection (rename/truncate)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?\\bselect\\b.+?\\b(?:into\\b.+?(?:(?:dump|out)file|\\@[\'"\\x60]?\\w+)|load_file))\\b', 'why' => 'SQL injection (select into/load_file)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '(?i:(?:\\b(?:and|or|union)\\b|;|\').*?load\\b.+?\\bdata\\b.+?\\binfile\\b.+?\\binto)\\b', 'why' => 'SQL injection (load)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_HOST', 'what' => '[^-a-zA-Z0-9._:\\[\\]]', 'why' => 'Malformed Host header', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET|POST', 'what' => '^[\'"]', 'why' => 'Leading quote', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET', 'what' => '^[\\x09\\x20]', 'why' => 'Leading space', 'level' => '1', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING|PATH_INFO', 'what' => '\\bHTTP_RAW_POST_DATA|HTTP_(?:POS|GE)T_VARS\\b', 'why' => 'PHP variable', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'SCRIPT_NAME', 'what' => 'phpinfo\\.php', 'why' => 'Attempt to access phpinfo.php', 'level' => '1', 'enabled' => '1'], ['who' => 'generic', 'request' => 'SCRIPT_NAME', 'what' => '/scripts/(?:setup|signon)\\.php', 'why' => 'phpMyAdmin hacking attempt', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'SCRIPT_NAME', 'what' => '\\.ph(?:p[2-6]?|tml)\\..+?', 'why' => 'PHP handler obfuscation', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:mosConfig_absolute_path|POST:mosConfig_absolute_path', 'what' => '.', 'why' => 'mosConfig_absolute_path override attempt', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:mosConfig_live_site|POST:mosConfig_live_site', 'what' => '.', 'why' => 'mosConfig_live_site override attempt', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:mosConfig_cachepath|POST:mosConfig_cachepath', 'what' => '.', 'why' => 'mosConfig_cachepath override attempt', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING|PATH_INFO|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\b(?:\\$?_(COOKIE|ENV|FILES|(?:GE|POS|REQUES)T|SE(RVER|SSION))|HTTP_(?:(?:POST|GET)_VARS|RAW_POST_DATA)|GLOBALS)\\s*[=\\[]|\\W\\$\\{\\s*[\'"]\\w+[\'"]', 'why' => 'PHP predefined variables', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_USER_AGENT', 'what' => '(?i:acunetix|analyzer|AhrefsBot|backdoor|bandit|blackwidow|BOT for JCE|collect|core-project|dts agent|emailmagnet|ex(ploit|tract)|flood|grabber|harvest|httrack|havij|hunter|indy library|inspect|LoadTimeBot|Microsoft URL Control|mj12bot|morfeus|nessus|pmafind|scanner|siphon|sqlmap|survey|teleport)', 'why' => 'Bad User-agent', 'level' => '1', 'enabled' => '1'], ['who' => 'generic', 'request' => 'SCRIPT_NAME', 'what' => '/tiny_?mce/plugins/spellchecker/classes/', 'why' => 'TinyMCE path disclosure', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_X_FORWARDED_FOR', 'what' => '[^.0-9a-f:\\x20,unkow]', 'why' => 'Non-compliant X_FORWARDED_FOR', 'level' => '1', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING', 'what' => '^-[bcndfiswzT]', 'why' => 'PHP-CGI exploit (CVE-2012-1823)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'SCRIPT_NAME', 'what' => '(?i:bypass|c99(?:madShell|ud)?|c100|cookie_(?:usage|setup)|diagnostics|dump|endix|gifimg|goog[l1]e.+[\\da-f]{10}|imageth|imlog|r5[47]|safe0ver|sniper|(?:jpe?g|gif|png))\\.ph(?:p[2-6]?|tml)', 'why' => 'Shell/backdoor', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:nixpasswd|POST:nixpasswd', 'what' => '^.?', 'why' => 'Shell/backdoor (nixpasswd)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING', 'what' => '\\bact=img&img=\\w', 'why' => 'Shell/backdoor (img)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING', 'what' => '\\bc=img&name=\\w', 'why' => 'Shell/backdoor (name)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING', 'what' => '^image=(?:arrow|file|folder|smiley)$', 'why' => 'Shell/backdoor (image)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_COOKIE', 'what' => '\\buname=.+?;\\ssysctl=', 'why' => 'Shell/backdoor (cookie)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'POST:sql_passwd|GET:sql_passwd', 'what' => '.', 'why' => 'Shell/backdoor (sql_passwd)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'POST:nowpath', 'what' => '^.?', 'why' => 'Shell/backdoor (nowpath)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'POST:view_writable', 'what' => '^.?', 'why' => 'Shell/backdoor (view_writable)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'HTTP_COOKIE', 'what' => '\\bphpspypass='******'why' => 'Shell/backdoor (phpspy)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'POST:a', 'what' => '^(?:Bruteforce|Console|Files(?:Man|Tools)|Network|Php|SecInfo|SelfRemove|Sql|StringTools)$', 'why' => 'Shell/backdoor (a)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'POST:nst_cmd', 'what' => '^.', 'why' => 'Shell/backdoor (nstview)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'POST:cmd', 'what' => '^(?:c(?:h_|URL)|db_query|echo\\s\\.*|(?:edit|download|save)_file|find(?:_text|\\s.+)|ftp_(?:brute|file_(?:down|up))|mail_file|mk|mysql(?:b|_dump)|php_eval|ps\\s.*|search_text|safe_dir|sym[1-2]|test[1-8]|zend)$', 'why' => 'Shell/backdoor (cmd)', 'level' => '2', 'enabled' => '1'], ['who' => 'generic', 'request' => 'GET:p', 'what' => '^(?:chmod|cmd|edit|eval|delete|headers|md5|mysql|phpinfo|rename)$', 'why' => 'Shell/backdoor (p)', 'level' => '3', 'enabled' => '1'], ['who' => 'generic', 'request' => 'QUERY_STRING', 'what' => '^act=(?:bind|cmd|encoder|eval|feedback|ftpquickbrute|gofile|ls|mkdir|mkfile|processes|ps_aux|search|security|sql|tools|update|upload)&d=%2F', 'why' => 'Shell/backdoor (act)', 'level' => '3', 'enabled' => '1'], ['who' => 'option', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '[\\x01-\\x08\\x0e-\\x1f]', 'why' => 'Disallowed ASCII characters', 'level' => '2', 'enabled' => '1'], ['who' => 'option', 'request' => 'GET|POST|HTTP_COOKIE|HTTP_USER_AGENT|HTTP_REFERER', 'what' => '\\b(?i:php://[a-z].+?|\\bdata:.*?;base64,)', 'why' => 'PHP wrappers', 'level' => '3', 'enabled' => '1'], ['who' => 'magento', 'request' => 'SCRIPT_NAME', 'what' => '/(?:[Cc]onfig|install)\\.php', 'why' => 'Magento: unauthorised access to a PHP script', 'level' => '2', 'enabled' => '1'], ['who' => 'magento', 'request' => 'SCRIPT_NAME', 'what' => '/(?:app|cache|includes|js(?!/index\\.php)|lib|media|pkginfo|var)/', 'why' => 'Magento: unauthorised access to a PHP script', 'level' => '2', 'enabled' => '1'], ['who' => 'magento', 'request' => 'GET|POST', 'what' => '\\badmin_user\\b', 'why' => 'Magento: SQL injection (admin_user)', 'level' => '2', 'enabled' => '1']];
             // Insert data to table
             foreach ($data as $item) {
                 $setup->getConnection()->insert($tableName, $item);
             }
         }
     }
     $setup->endSetup();
 }
Esempio n. 25
0
 /**
  * {@inheritdoc}
  */
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
         $newBackendModel = 'Magento\\Catalog\\Model\\Attribute\\Backend\\Startdate';
         $connection = $setup->getConnection();
         $connection->startSetup();
         $connection->update($setup->getTable('eav_attribute'), ['backend_model' => $newBackendModel], ['backend_model = ?' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Startdate']);
         /** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
         foreach ($this->category->getAttributes() as $attribute) {
             if ($attribute->getAttributeCode() == 'custom_design_from') {
                 $attribute->setBackendModel($newBackendModel);
                 $attribute->save();
                 break;
             }
         }
         $connection->endSetup();
     }
 }
Esempio n. 26
0
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '0.1.1') < 0) {
         // Get tutorial_simplenews table
         $tableName = $setup->getTable('sampletable');
         // Check if the table already exists
         if ($setup->getConnection()->isTableExists($tableName) == true) {
             // Declare data
             $data = [['name' => 'Name1', 'description' => 'The description1', 'is_active' => 1, 'created_at' => date('Y-m-d H:i:s'), 'update_time' => date('Y-m-d H:i:s')], ['name' => 'Name2', 'description' => 'The description2', 'is_active' => 1, 'created_at' => date('Y-m-d H:i:s'), 'update_time' => date('Y-m-d H:i:s')]];
             // Insert data to table
             foreach ($data as $item) {
                 $setup->getConnection()->insert($tableName, $item);
             }
         }
     }
     $setup->endSetup();
 }
Esempio n. 27
0
 /**
  * @param ModuleDataSetupInterface $setup
  * @return void
  */
 private function upgradeHash($setup)
 {
     $customerEntityTable = $setup->getTable('admin_user');
     $select = $setup->getConnection()->select()->from($customerEntityTable, ['user_id', 'password']);
     $customers = $setup->getConnection()->fetchAll($select);
     foreach ($customers as $customer) {
         list($hash, $salt) = explode(Encryptor::DELIMITER, $customer['password']);
         $newHash = $customer['password'];
         if (strlen($hash) === 32) {
             $newHash = implode(Encryptor::DELIMITER, [$hash, $salt, Encryptor::HASH_VERSION_MD5]);
         } elseif (strlen($hash) === 64) {
             $newHash = implode(Encryptor::DELIMITER, [$hash, $salt, Encryptor::HASH_VERSION_SHA256]);
         }
         $bind = ['password' => $newHash];
         $where = ['user_id = ?' => (int) $customer['user_id']];
         $setup->getConnection()->update($customerEntityTable, $bind, $where);
     }
 }
Esempio n. 28
0
 public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $setup->startSetup();
     if (version_compare($context->getVersion(), '2.0.2') < 0) {
         // Get tutorial_simplenews table
         $tableName = $setup->getTable('ktpl_blog');
         // Check if the table already exists
         if ($setup->getConnection()->isTableExists($tableName) == true) {
             // Declare data
             $data = ['banner' => ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => false, 'comment' => 'Banner']];
             // Insert data to table
             $connection = $setup->getConnection();
             foreach ($data as $name => $definition) {
                 $connection->addColumn($tableName, $name, $definition);
             }
             //  $installer->endSetup();
         }
     }
     $setup->endSetup();
 }
Esempio n. 29
0
 /**
  * Insert attribute additional data
  *
  * @param int|string $entityTypeId
  * @param array $data
  * @return $this
  */
 private function _insertAttributeAdditionalData($entityTypeId, array $data)
 {
     $additionalTable = $this->getEntityType($entityTypeId, 'additional_attribute_table');
     if (!$additionalTable) {
         return $this;
     }
     $additionalTableExists = $this->setup->getConnection()->isTableExists($this->setup->getTable($additionalTable));
     if ($additionalTable && $additionalTableExists) {
         $bind = [];
         $fields = $this->setup->getConnection()->describeTable($this->setup->getTable($additionalTable));
         foreach ($data as $k => $v) {
             if (isset($fields[$k])) {
                 $bind[$k] = $this->setup->getConnection()->prepareColumnValue($fields[$k], $v);
             }
         }
         if (!$bind) {
             return $this;
         }
         $this->setup->getConnection()->insert($this->setup->getTable($additionalTable), $bind);
     }
     return $this;
 }
Esempio n. 30
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     if ($this->moduleManager->isEnabled('Magento_GoogleBase')) {
         $typesInsert = $setup->getConnection()->select()->from($setup->getTable('googlebase_types'), ['type_id', 'attribute_set_id', 'target_country', 'category' => new \Zend_Db_Expr('NULL')])->insertFromSelect($setup->getTable('googleshopping_types'));
         $itemsInsert = $setup->getConnection()->select()->from($setup->getTable('googlebase_items'), ['item_id', 'type_id', 'product_id', 'gbase_item_id', 'store_id', 'published', 'expires'])->insertFromSelect($setup->getTable('googleshopping_items'));
         $attributes = '';
         foreach ($this->configFactory->create()->getAttributes() as $destAttribtues) {
             $keys = array_keys($destAttribtues);
             foreach ($keys as $code) {
                 $attributes .= "'{$code}',";
             }
         }
         $attributes = rtrim($attributes, ',');
         $attributesInsert = $setup->getConnection()->select()->from($setup->getTable('googlebase_attributes'), ['id', 'attribute_id', 'gbase_attribute' => new \Zend_Db_Expr("IF(gbase_attribute IN ({$attributes}), gbase_attribute, '')"), 'type_id'])->insertFromSelect($setup->getTable('googleshopping_attributes'));
         $setup->run($typesInsert);
         $setup->run($attributesInsert);
         $setup->run($itemsInsert);
     }
 }