diff --git a/.htaccess.sample b/.htaccess.sample index 8e6e702ced716..3c412725f2134 100644 --- a/.htaccess.sample +++ b/.htaccess.sample @@ -111,7 +111,8 @@ ############################################ ## enable rewrites - Options +FollowSymLinks + # The following line has better security but add some performance overhead - see https://httpd.apache.org/docs/2.4/en/misc/perf-tuning.html + Options -FollowSymLinks +SymLinksIfOwnerMatch RewriteEngine on ############################################ diff --git a/COPYING.txt b/COPYING.txt index d2cbcd01539dd..2ba7d78d58a25 100644 --- a/COPYING.txt +++ b/COPYING.txt @@ -1,4 +1,4 @@ -Copyright © 2013-2017 Magento, Inc. +Copyright © 2013-2018 Magento, Inc. Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license diff --git a/README.md b/README.md index 9b1aa1b7b3e28..c72357db26d16 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results. ## Magento system requirements -[Magento system requirements](http://devdocs.magento.com/magento-system-requirements.html) +[Magento system requirements](http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements2.html) ## Install Magento To install Magento, see either: * [Magento DevBox](https://magento.com/tech-resources/download), the easiest way to get started with Magento. -* [Installation guide](http://devdocs.magento.com/guides/v2.0/install-gde/bk-install-guide.html) +* [Installation guide](http://devdocs.magento.com/guides/v2.2/install-gde/bk-install-guide.html)

Contributing to the Magento 2 code base

Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions. @@ -22,8 +22,8 @@ To learn about issues, click [here][2]. To open an issue, click [here][3]. To suggest documentation improvements, click [here][4]. -[1]: -[2]: +[1]: +[2]: [3]: [4]: @@ -38,8 +38,10 @@ To suggest documentation improvements, click [here][4]. | ![reject](http://devdocs.magento.com/common/images/github_reject.png) | The pull request has been rejected and will not be merged into mainline code. Possible reasons can include but are not limited to: issue has already been fixed in another code contribution, or there is an issue with the code contribution. | | ![bug report](http://devdocs.magento.com/common/images/github_bug.png) | The Magento Team has confirmed that this issue contains the minimum required information to reproduce. | | ![acknowledged](http://devdocs.magento.com/common/images/gitHub_acknowledged.png) | The Magento Team has validated the issue and an internal ticket has been created. | -| ![acknowledged](http://devdocs.magento.com/common/images/github_inProgress.png) | The internal ticket is currently in progress, fix is scheduled to be delivered. | -| ![acknowledged](http://devdocs.magento.com/common/images/github_needsUpdate.png) | The Magento Team needs additional information from the reporter to properly prioritize and process the issue or pull request. | +| ![in progress](http://devdocs.magento.com/common/images/github_inProgress.png) | The internal ticket is currently in progress, fix is scheduled to be delivered. | +| ![needs update](http://devdocs.magento.com/common/images/github_needsUpdate.png) | The Magento Team needs additional information from the reporter to properly prioritize and process the issue or pull request. | + +To learn more about issue gate labels click [here](https://github.com/magento/magento2/wiki/Magento-Issue-Gates)

Reporting security issues

diff --git a/app/bootstrap.php b/app/bootstrap.php index 6701a9f4dd51e..ba62b296bd49c 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -14,12 +14,12 @@ if (!defined('PHP_VERSION_ID') || !(PHP_VERSION_ID === 70002 || PHP_VERSION_ID === 70004 || PHP_VERSION_ID >= 70006)) { if (PHP_SAPI == 'cli') { echo 'Magento supports 7.0.2, 7.0.4, and 7.0.6 or later. ' . - 'Please read http://devdocs.magento.com/guides/v1.0/install-gde/system-requirements.html'; + 'Please read http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements.html'; } else { echo <<

Magento supports PHP 7.0.2, 7.0.4, and 7.0.6 or later. Please read - + Magento System Requirements. HTML; @@ -49,12 +49,13 @@ unset($_SERVER['ORIG_PATH_INFO']); } -if (!empty($_SERVER['MAGE_PROFILER']) +if ( + (!empty($_SERVER['MAGE_PROFILER']) || file_exists(BP . '/var/profiler.flag')) && isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false ) { \Magento\Framework\Profiler::applyConfig( - $_SERVER['MAGE_PROFILER'], + (isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])) ? $_SERVER['MAGE_PROFILER'] : trim(file_get_contents(BP . '/var/profiler.flag')), BP, !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ); diff --git a/app/code/Magento/AdminNotification/Model/Feed.php b/app/code/Magento/AdminNotification/Model/Feed.php index 1766425fb19b1..d3b0b8501c864 100644 --- a/app/code/Magento/AdminNotification/Model/Feed.php +++ b/app/code/Magento/AdminNotification/Model/Feed.php @@ -214,9 +214,6 @@ public function getFeedData() ); $curl->write(\Zend_Http_Client::GET, $this->getFeedUrl(), '1.0'); $data = $curl->read(); - if ($data === false) { - return false; - } $data = preg_split('/^\r?$/m', $data, 2); $data = trim($data[1]); $curl->close(); diff --git a/app/code/Magento/AdminNotification/Setup/InstallSchema.php b/app/code/Magento/AdminNotification/Setup/InstallSchema.php deleted file mode 100644 index 081be974dc809..0000000000000 --- a/app/code/Magento/AdminNotification/Setup/InstallSchema.php +++ /dev/null @@ -1,124 +0,0 @@ -startSetup(); - /** - * Create table 'adminnotification_inbox' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('adminnotification_inbox') - )->addColumn( - 'notification_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Notification id' - )->addColumn( - 'severity', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Problem type' - )->addColumn( - 'date_added', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Create date' - )->addColumn( - 'title', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => false], - 'Title' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'url', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Url' - )->addColumn( - 'is_read', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Flag if notification read' - )->addColumn( - 'is_remove', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Flag if notification might be removed' - )->addIndex( - $installer->getIdxName('adminnotification_inbox', ['severity']), - ['severity'] - )->addIndex( - $installer->getIdxName('adminnotification_inbox', ['is_read']), - ['is_read'] - )->addIndex( - $installer->getIdxName('adminnotification_inbox', ['is_remove']), - ['is_remove'] - )->setComment( - 'Adminnotification Inbox' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'admin_system_messages' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('admin_system_messages') - )->addColumn( - 'identity', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 100, - ['nullable' => false, 'primary' => true], - 'Message id' - )->addColumn( - 'severity', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Problem type' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Create date' - )->setComment( - 'Admin System Messages' - ); - $installer->getConnection()->createTable($table); - - $installer->endSetup(); - } -} diff --git a/app/code/Magento/AdminNotification/etc/db_schema.xml b/app/code/Magento/AdminNotification/etc/db_schema.xml new file mode 100644 index 0000000000000..6d969b3f0090a --- /dev/null +++ b/app/code/Magento/AdminNotification/etc/db_schema.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
diff --git a/app/code/Magento/AdminNotification/etc/db_schema_whitelist.json b/app/code/Magento/AdminNotification/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..df5e14e066636 --- /dev/null +++ b/app/code/Magento/AdminNotification/etc/db_schema_whitelist.json @@ -0,0 +1,32 @@ +{ + "adminnotification_inbox": { + "column": { + "notification_id": true, + "severity": true, + "date_added": true, + "title": true, + "description": true, + "url": true, + "is_read": true, + "is_remove": true + }, + "index": { + "ADMINNOTIFICATION_INBOX_SEVERITY": true, + "ADMINNOTIFICATION_INBOX_IS_READ": true, + "ADMINNOTIFICATION_INBOX_IS_REMOVE": true + }, + "constraint": { + "PRIMARY": true + } + }, + "admin_system_messages": { + "column": { + "identity": true, + "severity": true, + "created_at": true + }, + "constraint": { + "PRIMARY": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php index 23829d3725119..0e8acb37104e6 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php @@ -394,7 +394,7 @@ protected function saveAndReplaceAdvancedPrices() ? $rowData[self::COL_TIER_PRICE] : 0, 'percentage_value' => $rowData[self::COL_TIER_PRICE_TYPE] === self::TIER_PRICE_TYPE_PERCENT ? $rowData[self::COL_TIER_PRICE] : null, - 'website_id' => $this->getWebsiteId($rowData[self::COL_TIER_PRICE_WEBSITE]) + 'website_id' => $this->getWebSiteId($rowData[self::COL_TIER_PRICE_WEBSITE]) ]; } } diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php index 5111b4932d7a8..9a380ff75da24 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php @@ -27,7 +27,7 @@ class WebsiteTest extends \PHPUnit\Framework\TestCase protected function setUp() { - $this->webSiteModel = $this->getMockBuilder(\Magento\Store\Model\WebSite::class) + $this->webSiteModel = $this->getMockBuilder(\Magento\Store\Model\Website::class) ->setMethods(['getBaseCurrency']) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Analytics/Model/Connector/Http/JsonConverter.php b/app/code/Magento/Analytics/Model/Connector/Http/JsonConverter.php index 600c192a262bd..44c54f67da759 100644 --- a/app/code/Magento/Analytics/Model/Connector/Http/JsonConverter.php +++ b/app/code/Magento/Analytics/Model/Connector/Http/JsonConverter.php @@ -22,6 +22,9 @@ class JsonConverter implements ConverterInterface */ private $serializer; + /** + * @param Json $serializer + */ public function __construct(Json $serializer) { $this->serializer = $serializer; diff --git a/app/code/Magento/Authorization/Setup/InstallSchema.php b/app/code/Magento/Authorization/Setup/InstallSchema.php deleted file mode 100644 index 9471b448ea3b4..0000000000000 --- a/app/code/Magento/Authorization/Setup/InstallSchema.php +++ /dev/null @@ -1,150 +0,0 @@ -startSetup(); - - if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_role'))) { - /** - * Create table 'authorization_role' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('authorization_role') - )->addColumn( - 'role_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Role ID' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Parent Role ID' - )->addColumn( - 'tree_level', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Role Tree Level' - )->addColumn( - 'sort_order', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Role Sort Order' - )->addColumn( - 'role_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 1, - ['nullable' => false, 'default' => '0'], - 'Role Type' - )->addColumn( - 'user_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'User ID' - )->addColumn( - 'user_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 16, - ['nullable' => true, 'default' => null], - 'User Type' - )->addColumn( - 'role_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - ['nullable' => true, 'default' => null], - 'Role Name' - )->addIndex( - $installer->getIdxName('authorization_role', ['parent_id', 'sort_order']), - ['parent_id', 'sort_order'] - )->addIndex( - $installer->getIdxName('authorization_role', ['tree_level']), - ['tree_level'] - )->setComment( - 'Admin Role Table' - ); - $installer->getConnection()->createTable($table); - } - - if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_rule'))) { - /** - * Create table 'authorization_rule' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('authorization_rule') - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Rule ID' - )->addColumn( - 'role_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Role ID' - )->addColumn( - 'resource_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => true, 'default' => null], - 'Resource ID' - )->addColumn( - 'privileges', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 20, - ['nullable' => true], - 'Privileges' - )->addColumn( - 'permission', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 10, - [], - 'Permission' - )->addIndex( - $installer->getIdxName('authorization_rule', ['resource_id', 'role_id']), - ['resource_id', 'role_id'] - )->addIndex( - $installer->getIdxName('authorization_rule', ['role_id', 'resource_id']), - ['role_id', 'resource_id'] - )->addForeignKey( - $installer->getFkName('authorization_rule', 'role_id', 'authorization_role', 'role_id'), - 'role_id', - $installer->getTable('authorization_role'), - 'role_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Admin Rule Table' - ); - $installer->getConnection()->createTable($table); - } - - $installer->endSetup(); - } -} diff --git a/app/code/Magento/Authorization/etc/db_schema.xml b/app/code/Magento/Authorization/etc/db_schema.xml new file mode 100644 index 0000000000000..ef615b4508a89 --- /dev/null +++ b/app/code/Magento/Authorization/etc/db_schema.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+
diff --git a/app/code/Magento/Authorization/etc/db_schema_whitelist.json b/app/code/Magento/Authorization/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..eb9256e415593 --- /dev/null +++ b/app/code/Magento/Authorization/etc/db_schema_whitelist.json @@ -0,0 +1,38 @@ +{ + "authorization_role": { + "column": { + "role_id": true, + "parent_id": true, + "tree_level": true, + "sort_order": true, + "role_type": true, + "user_id": true, + "user_type": true, + "role_name": true + }, + "index": { + "AUTHORIZATION_ROLE_PARENT_ID_SORT_ORDER": true, + "AUTHORIZATION_ROLE_TREE_LEVEL": true + }, + "constraint": { + "PRIMARY": true + } + }, + "authorization_rule": { + "column": { + "rule_id": true, + "role_id": true, + "resource_id": true, + "privileges": true, + "permission": true + }, + "index": { + "AUTHORIZATION_RULE_RESOURCE_ID_ROLE_ID": true, + "AUTHORIZATION_RULE_ROLE_ID_RESOURCE_ID": true + }, + "constraint": { + "PRIMARY": true, + "AUTHORIZATION_RULE_ROLE_ID_AUTHORIZATION_ROLE_ROLE_ID": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php index bdd0c4a424e99..ea73b4b734569 100644 --- a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php @@ -122,7 +122,7 @@ public function execute() /** * Place order for checkout flow * - * @return string + * @return void */ protected function placeCheckoutOrder() { diff --git a/app/code/Magento/Backend/Block/Cache.php b/app/code/Magento/Backend/Block/Cache.php index e14358396aa70..82c36bf3a1fe4 100644 --- a/app/code/Magento/Backend/Block/Cache.php +++ b/app/code/Magento/Backend/Block/Cache.php @@ -22,24 +22,29 @@ protected function _construct() $this->_headerText = __('Cache Storage Management'); parent::_construct(); $this->buttonList->remove('add'); - $this->buttonList->add( - 'flush_magento', - [ - 'label' => __('Flush Magento Cache'), - 'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')', - 'class' => 'primary flush-cache-magento' - ] - ); - $message = __('The cache storage may contain additional data. Are you sure that you want to flush it?'); - $this->buttonList->add( - 'flush_system', - [ - 'label' => __('Flush Cache Storage'), - 'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')', - 'class' => 'flush-cache-storage' - ] - ); + if ($this->_authorization->isAllowed('Magento_Backend::flush_magento_cache')) { + $this->buttonList->add( + 'flush_magento', + [ + 'label' => __('Flush Magento Cache'), + 'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')', + 'class' => 'primary flush-cache-magento' + ] + ); + } + + if ($this->_authorization->isAllowed('Magento_Backend::flush_cache_storage')) { + $message = __('The cache storage may contain additional data. Are you sure that you want to flush it?'); + $this->buttonList->add( + 'flush_system', + [ + 'label' => __('Flush Cache Storage'), + 'onclick' => 'confirmSetLocation(\'' . $message . '\', \'' . $this->getFlushStorageUrl() . '\')', + 'class' => 'flush-cache-storage' + ] + ); + } } /** diff --git a/app/code/Magento/Backend/Block/Cache/Permissions.php b/app/code/Magento/Backend/Block/Cache/Permissions.php new file mode 100644 index 0000000000000..272a603145f09 --- /dev/null +++ b/app/code/Magento/Backend/Block/Cache/Permissions.php @@ -0,0 +1,62 @@ +authorization = $authorization; + } + + /** + * @return bool + */ + public function hasAccessToFlushCatalogImages() + { + return $this->authorization->isAllowed('Magento_Backend::flush_catalog_images'); + } + /** + * @return bool + */ + public function hasAccessToFlushJsCss() + { + return $this->authorization->isAllowed('Magento_Backend::flush_js_css'); + } + /** + * @return bool + */ + public function hasAccessToFlushStaticFiles() + { + return $this->authorization->isAllowed('Magento_Backend::flush_static_files'); + } + /** + * @return bool + */ + public function hasAccessToAdditionalActions() + { + return ($this->hasAccessToFlushCatalogImages() + || $this->hasAccessToFlushJsCss() + || $this->hasAccessToFlushStaticFiles()); + } +} diff --git a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php index 9d9409fba093b..50279786c0a5b 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php +++ b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php @@ -92,7 +92,7 @@ protected function _prepareCollection() protected function _afterLoadCollection() { foreach ($this->getCollection() as $item) { - $item->getCustomer() ?: $item->setCustomer('Guest'); + $item->getCustomer() ?: $item->setCustomer($item->getBillingAddress()->getName()); } return $this; } diff --git a/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php b/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php index f19799d2e4939..034887c67d1ee 100644 --- a/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php +++ b/app/code/Magento/Backend/Block/System/Store/Edit/AbstractForm.php @@ -37,7 +37,7 @@ protected function _prepareForm() ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] ); - $this->_prepareStoreFieldSet($form); + $this->_prepareStoreFieldset($form); $form->addField( 'store_type', diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php index d9b00d2ba2503..662cbedaed8db 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php @@ -3,8 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Backend\Block\Widget\Grid; +use Magento\Backend\Block\Template\Context; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\AuthorizationInterface; +use Magento\Framework\DataObject; +use Magento\Framework\Json\EncoderInterface; + /** * Grid widget massaction default block * @@ -14,4 +21,72 @@ */ class Massaction extends \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction { + /** + * @var AuthorizationInterface + */ + private $authorization; + + /** + * Map bind item id to a particular acl type + * itemId => acl + * + * @var array + */ + private $restrictions = [ + 'enable' => 'Magento_Backend::toggling_cache_type', + 'disable' => 'Magento_Backend::toggling_cache_type', + 'refresh' => 'Magento_Backend::refresh_cache_type', + ]; + + /** + * Massaction constructor. + * + * @param Context $context + * @param EncoderInterface $jsonEncoder + * @param array $data + * @param AuthorizationInterface $authorization + */ + public function __construct( + Context $context, + EncoderInterface $jsonEncoder, + array $data = [], + AuthorizationInterface $authorization = null + ) { + $this->authorization = $authorization ?: ObjectManager::getInstance()->get(AuthorizationInterface::class); + + parent::__construct($context, $jsonEncoder, $data); + } + + /** + * {@inheritdoc} + * + * @param string $itemId + * @param array|DataObject $item + * + * @return $this + */ + public function addItem($itemId, $item) + { + if (!$this->isRestricted($itemId)) { + parent::addItem($itemId, $item); + } + + return $this; + } + + /** + * Check if access to action restricted + * + * @param string $itemId + * + * @return bool + */ + private function isRestricted(string $itemId): bool + { + if (!key_exists($itemId, $this->restrictions)) { + return false; + } + + return !$this->authorization->isAllowed($this->restrictions[$itemId]); + } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php index 1895bd08c464f..7a926b1c09c3e 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php @@ -11,6 +11,13 @@ class CleanImages extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::flush_catalog_images'; + /** * Clean JS/css files cache * diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php index 521cb9806a135..72f23ab65cf8a 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php @@ -11,6 +11,13 @@ class CleanMedia extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::flush_js_css'; + /** * Clean JS/css files cache * diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php index adfbf7cfe63c8..27ae2fc31e150 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php @@ -10,6 +10,13 @@ class CleanStaticFiles extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::flush_static_files'; + /** * Clean static files cache * diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php index 2f9dc9ad6a7a5..ca89ea58fa6f3 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php @@ -8,6 +8,13 @@ class FlushAll extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::flush_cache_storage'; + /** * Flush cache storage * diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php index 0f55a59353d65..f0fed159e0f22 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php @@ -8,6 +8,13 @@ class FlushSystem extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::flush_magento_cache'; + /** * Flush all magento cache * diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php index 204105852b9f1..2bfa937b06b77 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php @@ -16,6 +16,13 @@ */ class MassDisable extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::toggling_cache_type'; + /** * @var State */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php index 32acf47887c44..113e0f2d8961b 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php @@ -16,6 +16,13 @@ */ class MassEnable extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::toggling_cache_type'; + /** * @var State */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php index e18aa1555e11b..3843b030afb3d 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php @@ -11,6 +11,13 @@ class MassRefresh extends \Magento\Backend\Controller\Adminhtml\Cache { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Backend::refresh_cache_type'; + /** * Mass action for cache refresh * diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Noroute/Index.php b/app/code/Magento/Backend/Controller/Adminhtml/Noroute/Index.php index e8251b5be6030..ce59d2fd48e5a 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Noroute/Index.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Noroute/Index.php @@ -34,7 +34,7 @@ public function execute() { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); - $resultPage->setStatusHeader(404, '1.1', 'Forbidden'); + $resultPage->setStatusHeader(404, '1.1', 'Not Found'); $resultPage->setHeader('Status', '404 File not found'); $resultPage->addHandle('adminhtml_noroute'); return $resultPage; diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php index c9bce1cbf3888..421885a0c32a3 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php @@ -54,9 +54,9 @@ public function execute() $user = $this->_objectManager->create(\Magento\User\Model\User::class)->load($userId); $user->setId($userId) - ->setUsername($this->getRequest()->getParam('username', false)) - ->setFirstname($this->getRequest()->getParam('firstname', false)) - ->setLastname($this->getRequest()->getParam('lastname', false)) + ->setUserName($this->getRequest()->getParam('username', false)) + ->setFirstName($this->getRequest()->getParam('firstname', false)) + ->setLastName($this->getRequest()->getParam('lastname', false)) ->setEmail(strtolower($this->getRequest()->getParam('email', false))); if ($this->_objectManager->get(\Magento\Framework\Validator\Locale::class)->isValid($interfaceLocale)) { diff --git a/app/code/Magento/Backend/Test/Unit/Block/Cache/PermissionsTest.php b/app/code/Magento/Backend/Test/Unit/Block/Cache/PermissionsTest.php new file mode 100644 index 0000000000000..6975b8ac092ad --- /dev/null +++ b/app/code/Magento/Backend/Test/Unit/Block/Cache/PermissionsTest.php @@ -0,0 +1,76 @@ +objectManager = new ObjectManager($this); + + $this->mockAuthorization = $this->getMockBuilder(Authorization::class) + ->disableOriginalConstructor() + ->setMethods(['isAllowed']) + ->getMock(); + + $this->permissions = new Permissions($this->mockAuthorization); + } + + public function testHasAccessToFlushCatalogImages() + { + $this->mockAuthorization->expects($this->atLeastOnce()) + ->method('isAllowed') + ->with('Magento_Backend::flush_catalog_images') + ->willReturn(true); + + $this->assertTrue($this->permissions->hasAccessToFlushCatalogImages()); + } + + public function testHasAccessToFlushJsCss() + { + $this->mockAuthorization->expects($this->atLeastOnce()) + ->method('isAllowed') + ->with('Magento_Backend::flush_js_css') + ->willReturn(true); + + $this->assertTrue($this->permissions->hasAccessToFlushJsCss()); + } + + public function testHasAccessToFlushStaticFiles() + { + $this->mockAuthorization->expects($this->atLeastOnce()) + ->method('isAllowed') + ->with('Magento_Backend::flush_static_files') + ->willReturn(true); + + $this->assertTrue($this->permissions->hasAccessToFlushStaticFiles()); + } +} diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php index be171a8ed40bf..df242a4cf6129 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php @@ -117,7 +117,7 @@ public function testSetFilterTypePropagatesFilterTypeToColumns() public function testGetRowUrlIfUrlPathNotSet() { - $this->assertEquals('#', $this->_block->getRowUrl(new \StdClass())); + $this->assertEquals('#', $this->_block->getRowUrl(new \stdClass())); } public function testGetRowUrl() diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php index da13af87b71ea..c5c56fd75fbe7 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php @@ -351,7 +351,7 @@ public function testSetGetGrid() $this->_block->setFilter('StdClass'); - $grid = new \StdClass(); + $grid = new \stdClass(); $this->_block->setGrid($grid); $this->assertEquals($grid, $this->_block->getGrid()); } diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index bb389a996e1ed..29ce448a04ecb 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -10,6 +10,7 @@ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; +use Magento\Framework\Authorization; class MassactionTest extends \PHPUnit\Framework\TestCase { @@ -43,6 +44,11 @@ class MassactionTest extends \PHPUnit\Framework\TestCase */ protected $_requestMock; + /** + * @var Authorization|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_authorizationMock; + /** * @var VisibilityChecker|\PHPUnit_Framework_MockObject_MockObject */ @@ -86,11 +92,17 @@ protected function setUp() $this->visibilityCheckerMock = $this->getMockBuilder(VisibilityChecker::class) ->getMockForAbstractClass(); + $this->_authorizationMock = $this->getMockBuilder(Authorization::class) + ->disableOriginalConstructor() + ->setMethods(['isAllowed']) + ->getMock(); + $arguments = [ 'layout' => $this->_layoutMock, 'request' => $this->_requestMock, 'urlBuilder' => $this->_urlModelMock, - 'data' => ['massaction_id_field' => 'test_id', 'massaction_id_filter' => 'test_id'] + 'data' => ['massaction_id_field' => 'test_id', 'massaction_id_filter' => 'test_id'], + 'authorization' => $this->_authorizationMock, ]; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -145,6 +157,10 @@ public function testItemsProcessing($itemId, $item, $expectedItem) ->method('getUrl') ->willReturnMap($urlReturnValueMap); + $this->_authorizationMock->expects($this->any()) + ->method('isAllowed') + ->willReturn(true); + $this->_block->addItem($itemId, $item); $this->assertEquals(1, $this->_block->getCount()); @@ -184,6 +200,28 @@ public function itemsProcessingDataProvider() "id" => 'test_id2', ] ) + ], + [ + 'enabled', + new \Magento\Framework\DataObject(["label" => "Test Item Enabled", "url" => "*/*/test2"]), + new \Magento\Framework\DataObject( + [ + "label" => "Test Item Enabled", + "url" => "http://localhost/index.php/backend/admin/test/test2", + "id" => 'enabled', + ] + ) + ], + [ + 'refresh', + new \Magento\Framework\DataObject(["label" => "Test Item Refresh", "url" => "*/*/test2"]), + new \Magento\Framework\DataObject( + [ + "label" => "Test Item Refresh", + "url" => "http://localhost/index.php/backend/admin/test/test2", + "id" => 'refresh', + ] + ) ] ]; } @@ -237,7 +275,7 @@ public function testGetGridIdsJsonWithoutUseSelectAll() public function testGetGridIdsJsonWithUseSelectAll(array $items, $result) { $this->_block->setUseSelectAll(true); - + if ($this->_block->getMassactionIdField()) { $massActionIdField = $this->_block->getMassactionIdField(); } else { @@ -290,14 +328,20 @@ public function dataProviderGetGridIdsJsonWithUseSelectAll() * @param int $count * @param bool $withVisibilityChecker * @param bool $isVisible + * @param bool $isAllowed + * * @dataProvider addItemDataProvider */ - public function testAddItem($itemId, $item, $count, $withVisibilityChecker, $isVisible) + public function testAddItem($itemId, $item, $count, $withVisibilityChecker, $isVisible, $isAllowed) { $this->visibilityCheckerMock->expects($this->any()) ->method('isVisible') ->willReturn($isVisible); + $this->_authorizationMock->expects($this->any()) + ->method('isAllowed') + ->willReturn($isAllowed); + if ($withVisibilityChecker) { $item['visible'] = $this->visibilityCheckerMock; } @@ -311,7 +355,7 @@ public function testAddItem($itemId, $item, $count, $withVisibilityChecker, $isV ->willReturnMap($urlReturnValueMap); $this->_block->addItem($itemId, $item); - $this->assertEquals($count, $this->_block->getCount()); + $this->assertEquals($count, $this->_block->getCount(), $itemId); } /** @@ -325,7 +369,8 @@ public function addItemDataProvider() 'item' => ['label' => 'Test 1', 'url' => '*/*/test1'], 'count' => 1, 'withVisibilityChecker' => false, - '$isVisible' => false, + 'isVisible' => false, + 'isAllowed' => true, ], [ 'itemId' => 'test2', @@ -333,21 +378,56 @@ public function addItemDataProvider() 'count' => 1, 'withVisibilityChecker' => false, 'isVisible' => true, + 'isAllowed' => true, ], [ - 'itemId' => 'test1', - 'item' => ['label' => 'Test 1. Hide', 'url' => '*/*/test1'], + 'itemId' => 'test3', + 'item' => ['label' => 'Test 3. Hide', 'url' => '*/*/test3'], 'count' => 0, 'withVisibilityChecker' => true, 'isVisible' => false, + 'isAllowed' => true, ], [ - 'itemId' => 'test2', - 'item' => ['label' => 'Test 2. Does not hide', 'url' => '*/*/test2'], + 'itemId' => 'test4', + 'item' => ['label' => 'Test 4. Does not hide', 'url' => '*/*/test4'], 'count' => 1, 'withVisibilityChecker' => true, 'isVisible' => true, - ] + 'isAllowed' => true, + ], + [ + 'itemId' => 'enable', + 'item' => ['label' => 'Test 5. Not restricted', 'url' => '*/*/test5'], + 'count' => 1, + 'withVisibilityChecker' => true, + 'isVisible' => true, + 'isAllowed' => true, + ], + [ + 'itemId' => 'enable', + 'item' => ['label' => 'Test 5. restricted', 'url' => '*/*/test5'], + 'count' => 0, + 'withVisibilityChecker' => true, + 'isVisible' => true, + 'isAllowed' => false, + ], + [ + 'itemId' => 'refresh', + 'item' => ['label' => 'Test 6. Not Restricted', 'url' => '*/*/test6'], + 'count' => 1, + 'withVisibilityChecker' => true, + 'isVisible' => true, + 'isAllowed' => true, + ], + [ + 'itemId' => 'refresh', + 'item' => ['label' => 'Test 6. Restricted', 'url' => '*/*/test6'], + 'count' => 0, + 'withVisibilityChecker' => true, + 'isVisible' => true, + 'isAllowed' => false, + ], ]; } } diff --git a/app/code/Magento/Backend/etc/acl.xml b/app/code/Magento/Backend/etc/acl.xml index af4ab5856e94c..cf9471e75bed9 100644 --- a/app/code/Magento/Backend/etc/acl.xml +++ b/app/code/Magento/Backend/etc/acl.xml @@ -38,7 +38,21 @@ - + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 050115087c26e..b9ebeb227b764 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -145,6 +145,9 @@ Magento\Config\Model\Config\Structure\ElementVisibilityInterface::HIDDEN Magento\Config\Model\Config\Structure\ElementVisibilityInterface::DISABLED + + + diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index 92df39bd65ee4..04bfe76bce9e7 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -231,7 +231,7 @@ Magento\Directory\Model\Config\Source\Country - + Magento\Directory\Model\Config\Source\Country diff --git a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_index.xml b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_index.xml index ab5ddc414b51f..4bbe70b6cdb92 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_index.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_index.xml @@ -11,7 +11,11 @@ - + + + Magento\Backend\Block\Cache\Permissions + + diff --git a/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml b/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml index 40b7173f47417..8feccc9cf1b8f 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml @@ -29,7 +29,7 @@ data-mage-init='{"dropdown":{}}' data-toggle="dropdown"> - +

    @@ -39,7 +39,7 @@ href="getUrl('adminhtml/system_account/index') ?>" getUiId('user', 'account', 'settings') ?> title="escapeHtml(__('Account Setting')) ?>"> - (escapeHtml($block->getUser()->getUsername()) ?>) + (escapeHtml($block->getUser()->getUserName()) ?>) diff --git a/app/code/Magento/Backend/view/adminhtml/templates/system/cache/additional.phtml b/app/code/Magento/Backend/view/adminhtml/templates/system/cache/additional.phtml index 84bbc4ea601ef..8e30afdf51f7f 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/system/cache/additional.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/system/cache/additional.phtml @@ -5,34 +5,39 @@ */ // @codingStandardsIgnoreFile + +/** @var \Magento\Backend\Block\Cache\Permissions|null $permissions */ +$permissions = $block->getData('permissions'); ?> -
    -

    - -

    -

    - - -

    -

    - - -

    - isInProductionMode()): - ?> -

    - - -

    - - getChildHtml() ?> -
    +hasAccessToAdditionalActions()): ?> +
    + hasAccessToFlushCatalogImages()): ?> +

    + escapeHtml(__('Additional Cache Management')); ?> +

    +

    + + escapeHtml(__('Pregenerated product images files')); ?> +

    + + hasAccessToFlushJsCss()): ?> +

    + + escapeHtml(__('Themes JavaScript and CSS files combined to one file')) ?> +

    + + isInProductionMode() && $permissions->hasAccessToFlushStaticFiles()): ?> +

    + + escapeHtml(__('Preprocessed view files and static files')); ?> +

    + + getChildHtml() ?> +
    + diff --git a/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml b/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml index a528133b2bc3a..b50183ced29b4 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml @@ -28,16 +28,16 @@ diff --git a/app/code/Magento/Review/view/frontend/web/js/validate-review.js b/app/code/Magento/Review/view/frontend/web/js/validate-review.js new file mode 100644 index 0000000000000..e3f57eaf8cd33 --- /dev/null +++ b/app/code/Magento/Review/view/frontend/web/js/validate-review.js @@ -0,0 +1,18 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'jquery/ui', + 'jquery/validate', + 'mage/translate' +], function ($) { + 'use strict'; + + $.validator.addMethod( + 'rating-required', function (value) { + return value !== undefined; + }, $.mage.__('Please select one of each of the ratings above.')); +}); diff --git a/app/code/Magento/Robots/Controller/Index/Index.php b/app/code/Magento/Robots/Controller/Index/Index.php index b94626e93432d..679066d723dce 100644 --- a/app/code/Magento/Robots/Controller/Index/Index.php +++ b/app/code/Magento/Robots/Controller/Index/Index.php @@ -43,6 +43,7 @@ public function execute() /** @var Page $resultPage */ $resultPage = $this->resultPageFactory->create(true); $resultPage->addHandle('robots_index_index'); + $resultPage->setHeader('Content-Type', 'text/plain'); return $resultPage; } } diff --git a/app/code/Magento/Robots/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Robots/Test/Unit/Controller/Index/IndexTest.php index 22a69cc13bd52..d3a7a97c7ea80 100644 --- a/app/code/Magento/Robots/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Robots/Test/Unit/Controller/Index/IndexTest.php @@ -51,6 +51,9 @@ public function testExecute() $resultPageMock->expects($this->once()) ->method('addHandle') ->with('robots_index_index'); + $resultPageMock->expects($this->once()) + ->method('setHeader') + ->with('Content-Type', 'text/plain'); $this->resultPageFactory->expects($this->any()) ->method('create') diff --git a/app/code/Magento/Rule/Model/ResourceModel/AbstractResource.php b/app/code/Magento/Rule/Model/ResourceModel/AbstractResource.php index 2fdb960521a97..6e685a9a9b978 100644 --- a/app/code/Magento/Rule/Model/ResourceModel/AbstractResource.php +++ b/app/code/Magento/Rule/Model/ResourceModel/AbstractResource.php @@ -81,7 +81,7 @@ public function bindRuleToEntity($ruleIds, $entityIds, $entityType) try { $this->_multiplyBunchInsert($ruleIds, $entityIds, $entityType); } catch (\Exception $e) { - $this->getConnection()->rollback(); + $this->getConnection()->rollBack(); throw $e; } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php index 85b0ed891b64f..f335705e3deee 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php @@ -160,4 +160,22 @@ public function convertPrice($value, $format = true) ) : $this->priceCurrency->convert($value, $this->getStore()); } + + /** + * If item is quote or wishlist we need to get product from it. + * + * @param $item + * + * @return Product + */ + public function getProduct($item) + { + if ($item instanceof Product) { + $product = $item; + } else { + $product = $item->getProduct(); + } + + return $product; + } } diff --git a/app/code/Magento/Sales/Helper/Guest.php b/app/code/Magento/Sales/Helper/Guest.php index a80be58bc003e..dd8845008d79e 100644 --- a/app/code/Magento/Sales/Helper/Guest.php +++ b/app/code/Magento/Sales/Helper/Guest.php @@ -178,6 +178,9 @@ public function loadValidOrder(App\RequestInterface $request) public function getBreadcrumbs(\Magento\Framework\View\Result\Page $resultPage) { $breadcrumbs = $resultPage->getLayout()->getBlock('breadcrumbs'); + if (!$breadcrumbs) { + return; + } $breadcrumbs->addCrumb( 'home', [ diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 732ad6ba2cf6c..9847c600e691e 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -8,7 +8,12 @@ use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Model\Metadata\Form as CustomerForm; +use Magento\Framework\Api\ExtensibleDataObjectConverter; +use Magento\Framework\App\ObjectManager; +use Magento\Quote\Model\Quote\Address; use Magento\Quote\Model\Quote\Item; +use Magento\Sales\Api\Data\OrderAddressInterface; +use Magento\Sales\Model\Order; /** * Order create model @@ -231,6 +236,11 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ */ private $serializer; + /** + * @var ExtensibleDataObjectConverter + */ + private $dataObjectConverter; + /** * @param \Magento\Framework\ObjectManagerInterface $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -261,6 +271,7 @@ class Create extends \Magento\Framework\DataObject implements \Magento\Checkout\ * @param \Magento\Quote\Model\QuoteFactory $quoteFactory * @param array $data * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @param ExtensibleDataObjectConverter|null $dataObjectConverter * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -292,7 +303,8 @@ public function __construct( \Magento\Sales\Api\OrderManagementInterface $orderManagement, \Magento\Quote\Model\QuoteFactory $quoteFactory, array $data = [], - \Magento\Framework\Serialize\Serializer\Json $serializer = null + \Magento\Framework\Serialize\Serializer\Json $serializer = null, + ExtensibleDataObjectConverter $dataObjectConverter = null ) { $this->_objectManager = $objectManager; $this->_eventManager = $eventManager; @@ -321,9 +333,11 @@ public function __construct( $this->dataObjectHelper = $dataObjectHelper; $this->orderManagement = $orderManagement; $this->quoteFactory = $quoteFactory; - $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() + $this->serializer = $serializer ?: ObjectManager::getInstance() ->get(\Magento\Framework\Serialize\Serializer\Json::class); parent::__construct($data); + $this->dataObjectConverter = $dataObjectConverter ?: ObjectManager::getInstance() + ->get(ExtensibleDataObjectConverter::class); } /** @@ -510,9 +524,7 @@ public function initFromOrder(\Magento\Sales\Model\Order $order) $shippingAddress = $order->getShippingAddress(); if ($shippingAddress) { - $addressDiff = array_diff_assoc($shippingAddress->getData(), $order->getBillingAddress()->getData()); - unset($addressDiff['address_type'], $addressDiff['entity_id']); - $shippingAddress->setSameAsBilling(empty($addressDiff)); + $shippingAddress->setSameAsBilling($this->isAddressesAreEqual($order)); } $this->_initBillingAddressFromOrder($order); @@ -1454,33 +1466,37 @@ public function getBillingAddress() */ public function setBillingAddress($address) { - if (is_array($address)) { - $billingAddress = $this->_objectManager->create( - \Magento\Quote\Model\Quote\Address::class - )->setData( - $address - )->setAddressType( - \Magento\Quote\Model\Quote\Address::TYPE_BILLING - ); - $this->_setQuoteAddress($billingAddress, $address); - /** - * save_in_address_book is not a valid attribute and is filtered out by _setQuoteAddress, - * that is why it should be added after _setQuoteAddress call - */ - $saveInAddressBook = (int)(!empty($address['save_in_address_book'])); - $billingAddress->setData('save_in_address_book', $saveInAddressBook); - - if (!$this->getQuote()->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) { - $shippingAddress = clone $billingAddress; - $shippingAddress->setSameAsBilling(true); - $shippingAddress->setSaveInAddressBook(false); - $address['save_in_address_book'] = 0; - $this->setShippingAddress($address); - } + if (!is_array($address)) { + return $this; + } + + $billingAddress = $this->_objectManager->create(Address::class) + ->setData($address) + ->setAddressType(Address::TYPE_BILLING); - $this->getQuote()->setBillingAddress($billingAddress); + $this->_setQuoteAddress($billingAddress, $address); + + /** + * save_in_address_book is not a valid attribute and is filtered out by _setQuoteAddress, + * that is why it should be added after _setQuoteAddress call + */ + $saveInAddressBook = (int)(!empty($address['save_in_address_book'])); + $billingAddress->setData('save_in_address_book', $saveInAddressBook); + + $quote = $this->getQuote(); + if (!$quote->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) { + $address['save_in_address_book'] = 0; + $this->setShippingAddress($address); } + // not assigned billing address should be saved as new + // but if quote already has the billing address it won't be overridden + if (empty($billingAddress->getCustomerAddressId())) { + $billingAddress->setCustomerAddressId(null); + $quote->getBillingAddress()->setCustomerAddressId(null); + } + $quote->setBillingAddress($billingAddress); + return $this; } @@ -1782,6 +1798,7 @@ public function _prepareCustomer() $address = $this->getShippingAddress()->setCustomerId($this->getQuote()->getCustomer()->getId()); $this->setShippingAddress($address); } + $this->getBillingAddress()->setCustomerId($customer->getId()); $this->getQuote()->updateCustomerData($this->getQuote()->getCustomer()); $customer = $this->getQuote()->getCustomer(); @@ -2010,4 +2027,26 @@ protected function _getNewCustomerEmail() return $email; } + + /** + * Checks id shipping and billing addresses are equal. + * + * @param Order $order + * @return bool + */ + private function isAddressesAreEqual(Order $order) + { + $shippingAddress = $order->getShippingAddress(); + $billingAddress = $order->getBillingAddress(); + $shippingData = $this->dataObjectConverter->toFlatArray($shippingAddress, [], OrderAddressInterface::class); + $billingData = $this->dataObjectConverter->toFlatArray($billingAddress, [], OrderAddressInterface::class); + unset( + $shippingData['address_type'], + $shippingData['entity_id'], + $billingData['address_type'], + $billingData['entity_id'] + ); + + return $shippingData == $billingData; + } } diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php index 1c7514142678b..e00eda647dc8d 100644 --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -122,8 +122,14 @@ public function getStateDefaultStatus($state) */ public function getStatusLabel($code) { - $code = $this->maskStatusForArea($this->state->getAreaCode(), $code); + $area = $this->state->getAreaCode(); + $code = $this->maskStatusForArea($area, $code); $status = $this->orderStatusFactory->create()->load($code); + + if ($area == 'adminhtml') { + return $status->getLabel(); + } + return $status->getStoreLabel(); } @@ -211,7 +217,7 @@ public function getStateStatuses($state, $addLabels = true) foreach ($collection as $item) { $status = $item->getData('status'); if ($addLabels) { - $statuses[$status] = $item->getStoreLabel(); + $statuses[$status] = $this->getStatusLabel($status); } else { $statuses[] = $status; } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index c09a5da9177c3..19aac897c21e2 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -7,10 +7,12 @@ namespace Magento\Sales\Model\Order; use Magento\Framework\Api\AttributeValueFactory; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Api\Data\CreditmemoInterface; use Magento\Sales\Model\AbstractModel; use Magento\Sales\Model\EntityInterface; +use Magento\Sales\Model\Order\InvoiceFactory; /** * Order creditmemo model @@ -112,6 +114,11 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt */ protected $priceCurrency; + /** + * @var InvoiceFactory + */ + private $invoiceFactory; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -128,6 +135,7 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data + * @param InvoiceFactory $invoiceFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -145,7 +153,8 @@ public function __construct( PriceCurrencyInterface $priceCurrency, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - array $data = [] + array $data = [], + InvoiceFactory $invoiceFactory = null ) { $this->_creditmemoConfig = $creditmemoConfig; $this->_orderFactory = $orderFactory; @@ -155,6 +164,7 @@ public function __construct( $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; $this->priceCurrency = $priceCurrency; + $this->invoiceFactory = $invoiceFactory ?: ObjectManager::getInstance()->get(InvoiceFactory::class); parent::__construct( $context, $registry, @@ -377,6 +387,9 @@ public function canRefund() */ public function getInvoice() { + if (!$this->getData('invoice') instanceof \Magento\Sales\Api\Data\InvoiceInterface && $this->getInvoiceId()) { + $this->setInvoice($this->invoiceFactory->create()->load($this->getInvoiceId())); + } return $this->getData('invoice'); } @@ -1505,6 +1518,5 @@ public function setExtensionAttributes(\Magento\Sales\Api\Data\CreditmemoExtensi { return $this->_setExtensionAttributes($extensionAttributes); } - //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/CustomerManagement.php b/app/code/Magento/Sales/Model/Order/CustomerManagement.php index bf54e65d0ce10..466f3ff8adddb 100644 --- a/app/code/Magento/Sales/Model/Order/CustomerManagement.php +++ b/app/code/Magento/Sales/Model/Order/CustomerManagement.php @@ -131,6 +131,7 @@ public function create($orderId) $customer = $this->customerFactory->create(['data' => $customerData]); $account = $this->accountManagement->createAccount($customer); $order->setCustomerId($account->getId()); + $order->setCustomerIsGuest(0); $this->orderRepository->save($order); return $account; diff --git a/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php index 93c6f19b08690..7ec089b882972 100644 --- a/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php +++ b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php @@ -5,7 +5,9 @@ */ namespace Magento\Sales\Model\Order\Email; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Mail\Template\TransportBuilder; +use Magento\Framework\Mail\Template\TransportBuilderByStore; use Magento\Sales\Model\Order\Email\Container\IdentityInterface; use Magento\Sales\Model\Order\Email\Container\Template; @@ -26,19 +28,29 @@ class SenderBuilder */ protected $transportBuilder; + /** + * @var TransportBuilderByStore + */ + private $transportBuilderByStore; + /** * @param Template $templateContainer * @param IdentityInterface $identityContainer * @param TransportBuilder $transportBuilder + * @param TransportBuilderByStore $transportBuilderByStore */ public function __construct( Template $templateContainer, IdentityInterface $identityContainer, - TransportBuilder $transportBuilder + TransportBuilder $transportBuilder, + TransportBuilderByStore $transportBuilderByStore = null ) { $this->templateContainer = $templateContainer; $this->identityContainer = $identityContainer; $this->transportBuilder = $transportBuilder; + $this->transportBuilderByStore = $transportBuilderByStore ?: ObjectManager::getInstance()->get( + TransportBuilderByStore::class + ); } /** @@ -98,6 +110,9 @@ protected function configureEmailTemplate() $this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId()); $this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions()); $this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars()); - $this->transportBuilder->setFrom($this->identityContainer->getEmailIdentity()); + $this->transportBuilderByStore->setFromByStore( + $this->identityContainer->getEmailIdentity(), + $this->identityContainer->getStore()->getId() + ); } } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/ItemCreation.php b/app/code/Magento/Sales/Model/Order/Shipment/ItemCreation.php index 8c018ecee544b..f600c65e05f52 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/ItemCreation.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/ItemCreation.php @@ -43,6 +43,7 @@ public function getOrderItemId() public function setOrderItemId($orderItemId) { $this->orderItemId = $orderItemId; + return $this; } /** @@ -59,6 +60,7 @@ public function getQty() public function setQty($qty) { $this->qty = $qty; + return $this; } /** diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo.php index f95a3206ce786..5ecbbd777a14e 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo.php @@ -50,6 +50,10 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) $object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId()); } + if (!$object->getInvoiceId() && $object->getInvoice()) { + $object->setInvoiceId($object->getInvoice()->getId()); + } + return parent::_beforeSave($object); } } diff --git a/app/code/Magento/Sales/Model/Service/CreditmemoService.php b/app/code/Magento/Sales/Model/Service/CreditmemoService.php index 2f08c26de9058..24f56c0dbd595 100644 --- a/app/code/Magento/Sales/Model/Service/CreditmemoService.php +++ b/app/code/Magento/Sales/Model/Service/CreditmemoService.php @@ -195,7 +195,7 @@ public function refund( */ protected function validateForRefund(\Magento\Sales\Api\Data\CreditmemoInterface $creditmemo) { - if ($creditmemo->getId()) { + if ($creditmemo->getId() && $creditmemo->getState() != \Magento\Sales\Model\Order\Creditmemo::STATE_OPEN) { throw new \Magento\Framework\Exception\LocalizedException( __('We cannot register an existing credit memo.') ); diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php deleted file mode 100644 index 3c1da7add06ec..0000000000000 --- a/app/code/Magento/Sales/Setup/InstallSchema.php +++ /dev/null @@ -1,5573 +0,0 @@ -startSetup(); - - /** - * Create table 'sales_order' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'State' - )->addColumn( - 'status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Status' - )->addColumn( - 'coupon_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Coupon Code' - )->addColumn( - 'protect_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Protect Code' - )->addColumn( - 'shipping_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Description' - )->addColumn( - 'is_virtual', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Is Virtual' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Customer Id' - )->addColumn( - 'base_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Amount' - )->addColumn( - 'base_discount_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Canceled' - )->addColumn( - 'base_discount_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Invoiced' - )->addColumn( - 'base_discount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Refunded' - )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' - )->addColumn( - 'base_shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Amount' - )->addColumn( - 'base_shipping_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Canceled' - )->addColumn( - 'base_shipping_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Invoiced' - )->addColumn( - 'base_shipping_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Refunded' - )->addColumn( - 'base_shipping_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Tax Amount' - )->addColumn( - 'base_shipping_tax_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Tax Refunded' - )->addColumn( - 'base_subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal' - )->addColumn( - 'base_subtotal_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal Canceled' - )->addColumn( - 'base_subtotal_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal Invoiced' - )->addColumn( - 'base_subtotal_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal Refunded' - )->addColumn( - 'base_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Amount' - )->addColumn( - 'base_tax_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Canceled' - )->addColumn( - 'base_tax_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Invoiced' - )->addColumn( - 'base_tax_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Refunded' - )->addColumn( - 'base_to_global_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base To Global Rate' - )->addColumn( - 'base_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base To Order Rate' - )->addColumn( - 'base_total_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Canceled' - )->addColumn( - 'base_total_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Invoiced' - )->addColumn( - 'base_total_invoiced_cost', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Invoiced Cost' - )->addColumn( - 'base_total_offline_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Offline Refunded' - )->addColumn( - 'base_total_online_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Online Refunded' - )->addColumn( - 'base_total_paid', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Paid' - )->addColumn( - 'base_total_qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Qty Ordered' - )->addColumn( - 'base_total_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Refunded' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Amount' - )->addColumn( - 'discount_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Canceled' - )->addColumn( - 'discount_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Invoiced' - )->addColumn( - 'discount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Refunded' - )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Grand Total' - )->addColumn( - 'shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Amount' - )->addColumn( - 'shipping_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Canceled' - )->addColumn( - 'shipping_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Invoiced' - )->addColumn( - 'shipping_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Refunded' - )->addColumn( - 'shipping_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Tax Amount' - )->addColumn( - 'shipping_tax_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Tax Refunded' - )->addColumn( - 'store_to_base_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Store To Base Rate' - )->addColumn( - 'store_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Store To Order Rate' - )->addColumn( - 'subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal' - )->addColumn( - 'subtotal_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal Canceled' - )->addColumn( - 'subtotal_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal Invoiced' - )->addColumn( - 'subtotal_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal Refunded' - )->addColumn( - 'tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Amount' - )->addColumn( - 'tax_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Canceled' - )->addColumn( - 'tax_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Invoiced' - )->addColumn( - 'tax_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Refunded' - )->addColumn( - 'total_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Canceled' - )->addColumn( - 'total_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Invoiced' - )->addColumn( - 'total_offline_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Offline Refunded' - )->addColumn( - 'total_online_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Online Refunded' - )->addColumn( - 'total_paid', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Paid' - )->addColumn( - 'total_qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Qty Ordered' - )->addColumn( - 'total_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Refunded' - )->addColumn( - 'can_ship_partially', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Can Ship Partially' - )->addColumn( - 'can_ship_partially_item', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Can Ship Partially Item' - )->addColumn( - 'customer_is_guest', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Customer Is Guest' - )->addColumn( - 'customer_note_notify', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Customer Note Notify' - )->addColumn( - 'billing_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Billing Address Id' - )->addColumn( - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - [], - 'Customer Group Id' - )->addColumn( - 'edit_increment', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Edit Increment' - )->addColumn( - 'email_sent', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Email Sent' - )->addColumn( - 'send_email', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Send Email' - )->addColumn( - 'forced_shipment_with_invoice', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Forced Do Shipment With Invoice' - )->addColumn( - 'payment_auth_expiration', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Payment Authorization Expiration' - )->addColumn( - 'quote_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Quote Address Id' - )->addColumn( - 'quote_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Quote Id' - )->addColumn( - 'shipping_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Shipping Address Id' - )->addColumn( - 'adjustment_negative', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment Negative' - )->addColumn( - 'adjustment_positive', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment Positive' - )->addColumn( - 'base_adjustment_negative', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Adjustment Negative' - )->addColumn( - 'base_adjustment_positive', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Adjustment Positive' - )->addColumn( - 'base_shipping_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Discount Amount' - )->addColumn( - 'base_subtotal_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal Incl Tax' - )->addColumn( - 'base_total_due', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Due' - )->addColumn( - 'payment_authorization_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Payment Authorization Amount' - )->addColumn( - 'shipping_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Discount Amount' - )->addColumn( - 'subtotal_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal Incl Tax' - )->addColumn( - 'total_due', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Due' - )->addColumn( - 'weight', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Weight' - )->addColumn( - 'customer_dob', - \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME, - null, - [], - 'Customer Dob' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Increment Id' - )->addColumn( - 'applied_rule_ids', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Applied Rule Ids' - )->addColumn( - 'base_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Base Currency Code' - )->addColumn( - 'customer_email', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Customer Email' - )->addColumn( - 'customer_firstname', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Customer Firstname' - )->addColumn( - 'customer_lastname', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Customer Lastname' - )->addColumn( - 'customer_middlename', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Customer Middlename' - )->addColumn( - 'customer_prefix', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Customer Prefix' - )->addColumn( - 'customer_suffix', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Customer Suffix' - )->addColumn( - 'customer_taxvat', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Customer Taxvat' - )->addColumn( - 'discount_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Discount Description' - )->addColumn( - 'ext_customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Ext Customer Id' - )->addColumn( - 'ext_order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Ext Order Id' - )->addColumn( - 'global_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Global Currency Code' - )->addColumn( - 'hold_before_state', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Hold Before State' - )->addColumn( - 'hold_before_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Hold Before Status' - )->addColumn( - 'order_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Order Currency Code' - )->addColumn( - 'original_increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Original Increment Id' - )->addColumn( - 'relation_child_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Relation Child Id' - )->addColumn( - 'relation_child_real_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Relation Child Real Id' - )->addColumn( - 'relation_parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Relation Parent Id' - )->addColumn( - 'relation_parent_real_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Relation Parent Real Id' - )->addColumn( - 'remote_ip', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Remote Ip' - )->addColumn( - 'shipping_method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Shipping Method' - )->addColumn( - 'store_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Store Currency Code' - )->addColumn( - 'store_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Store Name' - )->addColumn( - 'x_forwarded_for', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'X Forwarded For' - )->addColumn( - 'customer_note', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Customer Note' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' - )->addColumn( - 'total_item_count', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Total Item Count' - )->addColumn( - 'customer_gender', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Customer Gender' - )->addColumn( - 'discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Amount' - )->addColumn( - 'base_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Amount' - )->addColumn( - 'shipping_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Discount Tax Compensation Amount' - )->addColumn( - 'base_shipping_discount_tax_compensation_amnt', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Discount Tax Compensation Amount' - )->addColumn( - 'discount_tax_compensation_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Invoiced' - )->addColumn( - 'base_discount_tax_compensation_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Invoiced' - )->addColumn( - 'discount_tax_compensation_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Refunded' - )->addColumn( - 'base_discount_tax_compensation_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Refunded' - )->addColumn( - 'shipping_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Incl Tax' - )->addColumn( - 'base_shipping_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Incl Tax' - )->addColumn( - 'coupon_rule_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => true], - 'Coupon Sales Rule Name' - )->addIndex( - $installer->getIdxName('sales_order', ['status']), - ['status'] - )->addIndex( - $installer->getIdxName('sales_order', ['state']), - ['state'] - )->addIndex( - $installer->getIdxName('sales_order', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName( - 'sales_order', - ['increment_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_order', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_order', ['customer_id']), - ['customer_id'] - )->addIndex( - $installer->getIdxName('sales_order', ['ext_order_id']), - ['ext_order_id'] - )->addIndex( - $installer->getIdxName('sales_order', ['quote_id']), - ['quote_id'] - )->addIndex( - $installer->getIdxName('sales_order', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_order', ['send_email']), - ['send_email'] - )->addIndex( - $installer->getIdxName('sales_order', ['email_sent']), - ['email_sent'] - )->addForeignKey( - $installer->getFkName('sales_order', 'customer_id', 'customer_entity', 'entity_id'), - 'customer_id', - $installer->getTable('customer_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->addForeignKey( - $installer->getFkName('sales_order', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Flat Order' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_grid' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_grid') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Status' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'store_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Store Name' - )->addColumn( - 'customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Customer Id' - )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' - )->addColumn( - 'base_total_paid', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Paid' - )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Grand Total' - )->addColumn( - 'total_paid', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Paid' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'base_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Base Currency Code' - )->addColumn( - 'order_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Order Currency Code' - )->addColumn( - 'shipping_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Name' - )->addColumn( - 'billing_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Name' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Updated At' - )->addColumn( - 'billing_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Address' - )->addColumn( - 'shipping_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Address' - )->addColumn( - 'shipping_information', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Method Name' - )->addColumn( - 'customer_email', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Customer Email' - )->addColumn( - 'customer_group', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Customer Group' - )->addColumn( - 'subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal' - )->addColumn( - 'shipping_and_handling', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping and handling amount' - )->addColumn( - 'customer_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Customer Name' - )->addColumn( - 'payment_method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Payment Method' - )->addColumn( - 'total_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Refunded' - )->addIndex( - $installer->getIdxName('sales_order_grid', ['status']), - ['status'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['base_grand_total']), - ['base_grand_total'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['base_total_paid']), - ['base_total_paid'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['grand_total']), - ['grand_total'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['total_paid']), - ['total_paid'] - )->addIndex( - $installer->getIdxName( - 'sales_order_grid', - ['increment_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['shipping_name']), - ['shipping_name'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['billing_name']), - ['billing_name'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['customer_id']), - ['customer_id'] - )->addIndex( - $installer->getIdxName('sales_order_grid', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName( - 'sales_order_grid', - [ - 'increment_id', - 'billing_name', - 'shipping_name', - 'shipping_address', - 'billing_address', - 'customer_name', - 'customer_email' - ], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT - ), - [ - 'increment_id', - 'billing_name', - 'shipping_name', - 'shipping_address', - 'billing_address', - 'customer_name', - 'customer_email' - ], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] - )->setComment( - 'Sales Flat Order Grid' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_address' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_address') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Parent Id' - )->addColumn( - 'customer_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Customer Address Id' - )->addColumn( - 'quote_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Quote Address Id' - )->addColumn( - 'region_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Region Id' - )->addColumn( - 'customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Customer Id' - )->addColumn( - 'fax', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Fax' - )->addColumn( - 'region', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Region' - )->addColumn( - 'postcode', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Postcode' - )->addColumn( - 'lastname', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Lastname' - )->addColumn( - 'street', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Street' - )->addColumn( - 'city', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'City' - )->addColumn( - 'email', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Email' - )->addColumn( - 'telephone', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Phone Number' - )->addColumn( - 'country_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 2, - [], - 'Country Id' - )->addColumn( - 'firstname', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Firstname' - )->addColumn( - 'address_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Address Type' - )->addColumn( - 'prefix', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Prefix' - )->addColumn( - 'middlename', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Middlename' - )->addColumn( - 'suffix', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Suffix' - )->addColumn( - 'company', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Company' - )->addIndex( - $installer->getIdxName('sales_order_address', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_order_address', 'parent_id', 'sales_order', 'entity_id'), - 'parent_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Order Address' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_status_history' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status_history') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'is_customer_notified', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Is Customer Notified' - )->addColumn( - 'is_visible_on_front', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Is Visible On Front' - )->addColumn( - 'comment', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Comment' - )->addColumn( - 'status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Status' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'entity_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => true], - 'Shows what entity history is bind to.' - )->addIndex( - $installer->getIdxName('sales_order_status_history', ['parent_id']), - ['parent_id'] - )->addIndex( - $installer->getIdxName('sales_order_status_history', ['created_at']), - ['created_at'] - )->addForeignKey( - $installer->getFkName('sales_order_status_history', 'parent_id', 'sales_order', 'entity_id'), - 'parent_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Order Status History' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_item' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_item') - )->addColumn( - 'item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Item Id' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Order Id' - )->addColumn( - 'parent_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Parent Item Id' - )->addColumn( - 'quote_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Quote Item Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Product Id' - )->addColumn( - 'product_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Product Type' - )->addColumn( - 'product_options', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Product Options' - )->addColumn( - 'weight', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Weight' - )->addColumn( - 'is_virtual', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Is Virtual' - )->addColumn( - 'sku', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Sku' - )->addColumn( - 'name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Name' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'applied_rule_ids', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Applied Rule Ids' - )->addColumn( - 'additional_data', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Additional Data' - )->addColumn( - 'is_qty_decimal', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Is Qty Decimal' - )->addColumn( - 'no_discount', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'No Discount' - )->addColumn( - 'qty_backordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Qty Backordered' - )->addColumn( - 'qty_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Qty Canceled' - )->addColumn( - 'qty_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Qty Invoiced' - )->addColumn( - 'qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Qty Ordered' - )->addColumn( - 'qty_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Qty Refunded' - )->addColumn( - 'qty_shipped', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Qty Shipped' - )->addColumn( - 'base_cost', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Base Cost' - )->addColumn( - 'price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Price' - )->addColumn( - 'base_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Base Price' - )->addColumn( - 'original_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Original Price' - )->addColumn( - 'base_original_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Original Price' - )->addColumn( - 'tax_percent', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Tax Percent' - )->addColumn( - 'tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Tax Amount' - )->addColumn( - 'base_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Base Tax Amount' - )->addColumn( - 'tax_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Tax Invoiced' - )->addColumn( - 'base_tax_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Base Tax Invoiced' - )->addColumn( - 'discount_percent', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Discount Percent' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Discount Amount' - )->addColumn( - 'base_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Base Discount Amount' - )->addColumn( - 'discount_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Discount Invoiced' - )->addColumn( - 'base_discount_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Base Discount Invoiced' - )->addColumn( - 'amount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Amount Refunded' - )->addColumn( - 'base_amount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Base Amount Refunded' - )->addColumn( - 'row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Row Total' - )->addColumn( - 'base_row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Base Row Total' - )->addColumn( - 'row_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Row Invoiced' - )->addColumn( - 'base_row_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Base Row Invoiced' - )->addColumn( - 'row_weight', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['default' => '0.0000'], - 'Row Weight' - )->addColumn( - 'base_tax_before_discount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Before Discount' - )->addColumn( - 'tax_before_discount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Before Discount' - )->addColumn( - 'ext_order_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Ext Order Item Id' - )->addColumn( - 'locked_do_invoice', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Locked Do Invoice' - )->addColumn( - 'locked_do_ship', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Locked Do Ship' - )->addColumn( - 'price_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Price Incl Tax' - )->addColumn( - 'base_price_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Price Incl Tax' - )->addColumn( - 'row_total_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Row Total Incl Tax' - )->addColumn( - 'base_row_total_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Row Total Incl Tax' - )->addColumn( - 'discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Amount' - )->addColumn( - 'base_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Amount' - )->addColumn( - 'discount_tax_compensation_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Invoiced' - )->addColumn( - 'base_discount_tax_compensation_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Invoiced' - )->addColumn( - 'discount_tax_compensation_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Refunded' - )->addColumn( - 'base_discount_tax_compensation_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Refunded' - )->addColumn( - 'tax_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Canceled' - )->addColumn( - 'discount_tax_compensation_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Canceled' - )->addColumn( - 'tax_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Refunded' - )->addColumn( - 'base_tax_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Refunded' - )->addColumn( - 'discount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Refunded' - )->addColumn( - 'base_discount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Refunded' - )->addIndex( - $installer->getIdxName('sales_order_item', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_order_item', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_order_item', 'order_id', 'sales_order', 'entity_id'), - 'order_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_order_item', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Flat Order Item' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_payment' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_payment') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'base_shipping_captured', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Captured' - )->addColumn( - 'shipping_captured', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Captured' - )->addColumn( - 'amount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Amount Refunded' - )->addColumn( - 'base_amount_paid', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Paid' - )->addColumn( - 'amount_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Amount Canceled' - )->addColumn( - 'base_amount_authorized', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Authorized' - )->addColumn( - 'base_amount_paid_online', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Paid Online' - )->addColumn( - 'base_amount_refunded_online', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Refunded Online' - )->addColumn( - 'base_shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Amount' - )->addColumn( - 'shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Amount' - )->addColumn( - 'amount_paid', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Amount Paid' - )->addColumn( - 'amount_authorized', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Amount Authorized' - )->addColumn( - 'base_amount_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Ordered' - )->addColumn( - 'base_shipping_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Refunded' - )->addColumn( - 'shipping_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Refunded' - )->addColumn( - 'base_amount_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Refunded' - )->addColumn( - 'amount_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Amount Ordered' - )->addColumn( - 'base_amount_canceled', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount Canceled' - )->addColumn( - 'quote_payment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Quote Payment Id' - )->addColumn( - 'additional_data', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Additional Data' - )->addColumn( - 'cc_exp_month', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 12, - [], - 'Cc Exp Month' - )->addColumn( - 'cc_ss_start_year', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 12, - [], - 'Cc Ss Start Year' - )->addColumn( - 'echeck_bank_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Echeck Bank Name' - )->addColumn( - 'method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Method' - )->addColumn( - 'cc_debug_request_body', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Debug Request Body' - )->addColumn( - 'cc_secure_verify', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Secure Verify' - )->addColumn( - 'protection_eligibility', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Protection Eligibility' - )->addColumn( - 'cc_approval', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Approval' - )->addColumn( - 'cc_last_4', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 100, - [], - 'Cc Last 4' - )->addColumn( - 'cc_status_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Status Description' - )->addColumn( - 'echeck_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Echeck Type' - )->addColumn( - 'cc_debug_response_serialized', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Debug Response Serialized' - )->addColumn( - 'cc_ss_start_month', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Cc Ss Start Month' - )->addColumn( - 'echeck_account_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Echeck Account Type' - )->addColumn( - 'last_trans_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Last Trans Id' - )->addColumn( - 'cc_cid_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Cid Status' - )->addColumn( - 'cc_owner', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Cc Owner' - )->addColumn( - 'cc_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Type' - )->addColumn( - 'po_number', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Po Number' - )->addColumn( - 'cc_exp_year', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 4, - ['nullable' => true, 'default' => null], - 'Cc Exp Year' - )->addColumn( - 'cc_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 4, - [], - 'Cc Status' - )->addColumn( - 'echeck_routing_number', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Echeck Routing Number' - )->addColumn( - 'account_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Account Status' - )->addColumn( - 'anet_trans_method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Anet Trans Method' - )->addColumn( - 'cc_debug_response_body', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Debug Response Body' - )->addColumn( - 'cc_ss_issue', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Ss Issue' - )->addColumn( - 'echeck_account_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Echeck Account Name' - )->addColumn( - 'cc_avs_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Avs Status' - )->addColumn( - 'cc_number_enc', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Cc Number Enc' - )->addColumn( - 'cc_trans_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Cc Trans Id' - )->addColumn( - 'address_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Address Status' - )->addColumn( - 'additional_information', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Additional Information' - )->addIndex( - $installer->getIdxName('sales_order_payment', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_order_payment', 'parent_id', 'sales_order', 'entity_id'), - 'parent_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Order Payment' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipment' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipment') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'total_weight', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Weight' - )->addColumn( - 'total_qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Qty' - )->addColumn( - 'email_sent', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Email Sent' - )->addColumn( - 'send_email', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Send Email' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Customer Id' - )->addColumn( - 'shipping_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Shipping Address Id' - )->addColumn( - 'billing_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Billing Address Id' - )->addColumn( - 'shipment_status', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Shipment Status' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' - )->addColumn( - 'packages', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '20000', - [], - 'Packed Products in Packages' - )->addColumn( - 'shipping_label', - \Magento\Framework\DB\Ddl\Table::TYPE_VARBINARY, - '2m', - [], - 'Shipping Label Content' - )->addColumn( - 'customer_note', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - null, - [], - 'Customer Note' - )->addColumn( - 'customer_note_notify', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Customer Note Notify' - )->addIndex( - $installer->getIdxName('sales_shipment', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_shipment', ['total_qty']), - ['total_qty'] - )->addIndex( - $installer->getIdxName( - 'sales_shipment', - ['increment_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_shipment', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_shipment', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_shipment', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_shipment', ['send_email']), - ['send_email'] - )->addIndex( - $installer->getIdxName('sales_shipment', ['email_sent']), - ['email_sent'] - )->addForeignKey( - $installer->getFkName('sales_shipment', 'order_id', 'sales_order', 'entity_id'), - 'order_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_shipment', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Flat Shipment' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipment_grid' - * - * @add order_id, shipping_description - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipment_grid') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false], - 'Order Increment Id' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'order_created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false], - 'Order Increment Id' - )->addColumn( - 'customer_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - ['nullable' => false], - 'Customer Name' - )->addColumn( - 'total_qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Qty' - )->addColumn( - 'shipment_status', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Shipment Status' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Order' - )->addColumn( - 'billing_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Address' - )->addColumn( - 'shipping_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Address' - )->addColumn( - 'billing_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Billing Name' - )->addColumn( - 'shipping_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Shipping Name' - )->addColumn( - 'customer_email', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Customer Email' - )->addColumn( - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - [], - 'Customer Group Id' - )->addColumn( - 'payment_method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Payment Method' - )->addColumn( - 'shipping_information', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Method Name' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Updated At' - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - [ - 'increment_id', - 'store_id' - ], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - ['store_id'] - ), - ['store_id'] - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - ['total_qty'] - ), - ['total_qty'] - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - ['order_increment_id'] - ), - ['order_increment_id'] - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - ['shipment_status'] - ), - ['shipment_status'] - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - ['order_status'] - ), - ['order_status'] - )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['order_created_at']), - ['order_created_at'] - )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['shipping_name']), - ['shipping_name'] - )->addIndex( - $installer->getIdxName('sales_shipment_grid', ['billing_name']), - ['billing_name'] - )->addIndex( - $installer->getIdxName( - 'sales_shipment_grid', - [ - 'increment_id', - 'order_increment_id', - 'shipping_name', - 'customer_name', - 'customer_email', - 'billing_address', - 'shipping_address' - ], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT - ), - [ - 'increment_id', - 'order_increment_id', - 'shipping_name', - 'customer_name', - 'customer_email', - 'billing_address', - 'shipping_address' - ], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] - )->setComment( - 'Sales Flat Shipment Grid' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipment_item' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipment_item') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Row Total' - )->addColumn( - 'price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Price' - )->addColumn( - 'weight', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Weight' - )->addColumn( - 'qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Qty' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Product Id' - )->addColumn( - 'order_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Order Item Id' - )->addColumn( - 'additional_data', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Additional Data' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Name' - )->addColumn( - 'sku', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Sku' - )->addIndex( - $installer->getIdxName('sales_shipment_item', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_shipment_item', 'parent_id', 'sales_shipment', 'entity_id'), - 'parent_id', - $installer->getTable('sales_shipment'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Shipment Item' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipment_track' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipment_track') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'weight', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Weight' - )->addColumn( - 'qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Qty' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'track_number', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Number' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'title', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Title' - )->addColumn( - 'carrier_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Carrier Code' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' - )->addIndex( - $installer->getIdxName('sales_shipment_track', ['parent_id']), - ['parent_id'] - )->addIndex( - $installer->getIdxName('sales_shipment_track', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_shipment_track', ['created_at']), - ['created_at'] - )->addForeignKey( - $installer->getFkName('sales_shipment_track', 'parent_id', 'sales_shipment', 'entity_id'), - 'parent_id', - $installer->getTable('sales_shipment'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Shipment Track' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipment_comment' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipment_comment') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'is_customer_notified', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Is Customer Notified' - )->addColumn( - 'is_visible_on_front', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Is Visible On Front' - )->addColumn( - 'comment', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Comment' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addIndex( - $installer->getIdxName('sales_shipment_comment', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_shipment_comment', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_shipment_comment', 'parent_id', 'sales_shipment', 'entity_id'), - 'parent_id', - $installer->getTable('sales_shipment'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Shipment Comment' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_invoice' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoice') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true, 'identity' => true], - 'Entity Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' - )->addColumn( - 'shipping_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Tax Amount' - )->addColumn( - 'tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Amount' - )->addColumn( - 'base_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Amount' - )->addColumn( - 'store_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Store To Order Rate' - )->addColumn( - 'base_shipping_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Tax Amount' - )->addColumn( - 'base_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Amount' - )->addColumn( - 'base_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base To Order Rate' - )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Grand Total' - )->addColumn( - 'shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Amount' - )->addColumn( - 'subtotal_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal Incl Tax' - )->addColumn( - 'base_subtotal_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal Incl Tax' - )->addColumn( - 'store_to_base_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Store To Base Rate' - )->addColumn( - 'base_shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Amount' - )->addColumn( - 'total_qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Qty' - )->addColumn( - 'base_to_global_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base To Global Rate' - )->addColumn( - 'subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal' - )->addColumn( - 'base_subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Amount' - )->addColumn( - 'billing_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Billing Address Id' - )->addColumn( - 'is_used_for_refund', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Is Used For Refund' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'email_sent', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Email Sent' - )->addColumn( - 'send_email', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Send Email' - )->addColumn( - 'can_void_flag', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Can Void Flag' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'State' - )->addColumn( - 'shipping_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Shipping Address Id' - )->addColumn( - 'store_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Store Currency Code' - )->addColumn( - 'transaction_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Transaction Id' - )->addColumn( - 'order_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Order Currency Code' - )->addColumn( - 'base_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Base Currency Code' - )->addColumn( - 'global_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Global Currency Code' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' - )->addColumn( - 'discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Amount' - )->addColumn( - 'base_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Amount' - )->addColumn( - 'shipping_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Discount Tax Compensation Amount' - )->addColumn( - 'base_shipping_discount_tax_compensation_amnt', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Discount Tax Compensation Amount' - )->addColumn( - 'shipping_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Incl Tax' - )->addColumn( - 'base_shipping_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Incl Tax' - )->addColumn( - 'base_total_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Total Refunded' - )->addColumn( - 'discount_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Discount Description' - )->addColumn( - 'customer_note', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - null, - [], - 'Customer Note' - )->addColumn( - 'customer_note_notify', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Customer Note Notify' - )->addIndex( - $installer->getIdxName('sales_invoice', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_invoice', ['grand_total']), - ['grand_total'] - )->addIndex( - $installer->getIdxName('sales_invoice', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_invoice', ['state']), - ['state'] - )->addIndex( - $installer->getIdxName( - 'sales_invoice', - ['increment_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_invoice', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_invoice', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_invoice', ['send_email']), - ['send_email'] - )->addIndex( - $installer->getIdxName('sales_invoice', ['email_sent']), - ['email_sent'] - )->addForeignKey( - $installer->getFkName('sales_invoice', 'order_id', 'sales_order', 'entity_id'), - 'order_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_invoice', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Flat Invoice' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_invoice_grid' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoice_grid') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'State' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'store_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Store Name' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'order_increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Increment Id' - )->addColumn( - 'order_created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Order Created At' - )->addColumn( - 'customer_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Customer Name' - )->addColumn( - 'customer_email', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Customer Email' - )->addColumn( - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - [], - 'Customer Group Id' - )->addColumn( - 'payment_method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Payment Method' - )->addColumn( - 'store_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Store Currency Code' - )->addColumn( - 'order_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Order Currency Code' - )->addColumn( - 'base_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Base Currency Code' - )->addColumn( - 'global_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Global Currency Code' - )->addColumn( - 'billing_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Name' - )->addColumn( - 'billing_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Address' - )->addColumn( - 'shipping_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Address' - )->addColumn( - 'shipping_information', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Method Name' - )->addColumn( - 'subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal' - )->addColumn( - 'shipping_and_handling', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping and handling amount' - )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Grand Total' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Updated At' - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['grand_total']), - ['grand_total'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['state']), - ['state'] - )->addIndex( - $installer->getIdxName( - 'sales_invoice_grid', - ['increment_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['order_increment_id']), - ['order_increment_id'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['order_created_at']), - ['order_created_at'] - )->addIndex( - $installer->getIdxName('sales_invoice_grid', ['billing_name']), - ['billing_name'] - )->addIndex( - $installer->getIdxName( - 'sales_invoice_grid', - [ - 'increment_id', - 'order_increment_id', - 'billing_name', - 'billing_address', - 'shipping_address', - 'customer_name', - 'customer_email' - ], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT - ), - [ - 'increment_id', - 'order_increment_id', - 'billing_name', - 'billing_address', - 'shipping_address', - 'customer_name', - 'customer_email' - ], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] - )->setComment( - 'Sales Flat Invoice Grid' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_invoice_item' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoice_item') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'base_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Price' - )->addColumn( - 'tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Amount' - )->addColumn( - 'base_row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Row Total' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Amount' - )->addColumn( - 'row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Row Total' - )->addColumn( - 'base_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Amount' - )->addColumn( - 'price_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Price Incl Tax' - )->addColumn( - 'base_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Amount' - )->addColumn( - 'base_price_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Price Incl Tax' - )->addColumn( - 'qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Qty' - )->addColumn( - 'base_cost', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Cost' - )->addColumn( - 'price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Price' - )->addColumn( - 'base_row_total_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Row Total Incl Tax' - )->addColumn( - 'row_total_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Row Total Incl Tax' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Product Id' - )->addColumn( - 'order_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Order Item Id' - )->addColumn( - 'additional_data', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Additional Data' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'sku', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Sku' - )->addColumn( - 'name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Name' - )->addColumn( - 'discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Amount' - )->addColumn( - 'base_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Amount' - )->addColumn( - 'tax_ratio', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 512, - [], - 'Ratio of tax invoiced over tax of the order item' - )->addIndex( - $installer->getIdxName('sales_invoice_item', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_invoice_item', 'parent_id', 'sales_invoice', 'entity_id'), - 'parent_id', - $installer->getTable('sales_invoice'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Invoice Item' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_invoice_comment' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoice_comment') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'is_customer_notified', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Is Customer Notified' - )->addColumn( - 'is_visible_on_front', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Is Visible On Front' - )->addColumn( - 'comment', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Comment' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addIndex( - $installer->getIdxName('sales_invoice_comment', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_invoice_comment', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_invoice_comment', 'parent_id', 'sales_invoice', 'entity_id'), - 'parent_id', - $installer->getTable('sales_invoice'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Invoice Comment' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_creditmemo' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_creditmemo') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'adjustment_positive', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment Positive' - )->addColumn( - 'base_shipping_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Tax Amount' - )->addColumn( - 'store_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Store To Order Rate' - )->addColumn( - 'base_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Amount' - )->addColumn( - 'base_to_order_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base To Order Rate' - )->addColumn( - 'grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Grand Total' - )->addColumn( - 'base_adjustment_negative', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Adjustment Negative' - )->addColumn( - 'base_subtotal_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal Incl Tax' - )->addColumn( - 'shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Amount' - )->addColumn( - 'subtotal_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal Incl Tax' - )->addColumn( - 'adjustment_negative', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment Negative' - )->addColumn( - 'base_shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Amount' - )->addColumn( - 'store_to_base_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Store To Base Rate' - )->addColumn( - 'base_to_global_rate', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base To Global Rate' - )->addColumn( - 'base_adjustment', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Adjustment' - )->addColumn( - 'base_subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Subtotal' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Amount' - )->addColumn( - 'subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal' - )->addColumn( - 'adjustment', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment' - )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' - )->addColumn( - 'base_adjustment_positive', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Adjustment Positive' - )->addColumn( - 'base_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Amount' - )->addColumn( - 'shipping_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Tax Amount' - )->addColumn( - 'tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Amount' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'email_sent', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Email Sent' - )->addColumn( - 'send_email', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Send Email' - )->addColumn( - 'creditmemo_status', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Creditmemo Status' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'State' - )->addColumn( - 'shipping_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Shipping Address Id' - )->addColumn( - 'billing_address_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Billing Address Id' - )->addColumn( - 'invoice_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Invoice Id' - )->addColumn( - 'store_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Store Currency Code' - )->addColumn( - 'order_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Order Currency Code' - )->addColumn( - 'base_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Base Currency Code' - )->addColumn( - 'global_currency_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 3, - [], - 'Global Currency Code' - )->addColumn( - 'transaction_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Transaction Id' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' - )->addColumn( - 'discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Amount' - )->addColumn( - 'base_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Amount' - )->addColumn( - 'shipping_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Discount Tax Compensation Amount' - )->addColumn( - 'base_shipping_discount_tax_compensation_amnt', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Discount Tax Compensation Amount' - )->addColumn( - 'shipping_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping Incl Tax' - )->addColumn( - 'base_shipping_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Shipping Incl Tax' - )->addColumn( - 'discount_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Discount Description' - )->addColumn( - 'customer_note', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - null, - [], - 'Customer Note' - )->addColumn( - 'customer_note_notify', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Customer Note Notify' - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['creditmemo_status']), - ['creditmemo_status'] - )->addIndex( - $installer->getIdxName( - 'sales_creditmemo', - ['increment_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['state']), - ['state'] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['send_email']), - ['send_email'] - )->addIndex( - $installer->getIdxName('sales_creditmemo', ['email_sent']), - ['email_sent'] - )->addForeignKey( - $installer->getFkName('sales_creditmemo', 'order_id', 'sales_order', 'entity_id'), - 'order_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_creditmemo', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Flat Creditmemo' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_creditmemo_grid' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_creditmemo_grid') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Increment Id' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Created At' - )->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Updated At' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'order_increment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Increment Id' - )->addColumn( - 'order_created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Order Created At' - )->addColumn( - 'billing_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Name' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Status' - )->addColumn( - 'base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Grand Total' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Order Status' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'billing_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Billing Address' - )->addColumn( - 'shipping_address', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Address' - )->addColumn( - 'customer_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - ['nullable' => false], - 'Customer Name' - )->addColumn( - 'customer_email', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - [], - 'Customer Email' - )->addColumn( - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - [], - 'Customer Group Id' - )->addColumn( - 'payment_method', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Payment Method' - )->addColumn( - 'shipping_information', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Method Name' - )->addColumn( - 'subtotal', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Subtotal' - )->addColumn( - 'shipping_and_handling', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Shipping and handling amount' - )->addColumn( - 'adjustment_positive', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment Positive' - )->addColumn( - 'adjustment_negative', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Adjustment Negative' - )->addColumn( - 'order_base_grand_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Order Grand Total' - )->addIndex( - $installer->getIdxName( - 'sales_creditmemo_grid', - [ - 'increment_id', - 'store_id' - ], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['increment_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['order_increment_id']), - ['order_increment_id'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['updated_at']), - ['updated_at'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['order_created_at']), - ['order_created_at'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['state']), - ['state'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['billing_name']), - ['billing_name'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['order_status']), - ['order_status'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['base_grand_total']), - ['base_grand_total'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['order_base_grand_total']), - ['order_base_grand_total'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_grid', ['order_id']), - ['order_id'] - )->addIndex( - $installer->getIdxName( - 'sales_creditmemo_grid', - [ - 'increment_id', - 'order_increment_id', - 'billing_name', - 'billing_address', - 'shipping_address', - 'customer_name', - 'customer_email' - ], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT - ), - [ - 'increment_id', - 'order_increment_id', - 'billing_name', - 'billing_address', - 'shipping_address', - 'customer_name', - 'customer_email' - ], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT] - )->setComment( - 'Sales Flat Creditmemo Grid' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_creditmemo_item' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_creditmemo_item') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'base_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Price' - )->addColumn( - 'tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Tax Amount' - )->addColumn( - 'base_row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Row Total' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Amount' - )->addColumn( - 'row_total', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Row Total' - )->addColumn( - 'base_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Amount' - )->addColumn( - 'price_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Price Incl Tax' - )->addColumn( - 'base_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Tax Amount' - )->addColumn( - 'base_price_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Price Incl Tax' - )->addColumn( - 'qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Qty' - )->addColumn( - 'base_cost', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Cost' - )->addColumn( - 'price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Price' - )->addColumn( - 'base_row_total_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Row Total Incl Tax' - )->addColumn( - 'row_total_incl_tax', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Row Total Incl Tax' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Product Id' - )->addColumn( - 'order_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Order Item Id' - )->addColumn( - 'additional_data', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Additional Data' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'sku', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Sku' - )->addColumn( - 'name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Name' - )->addColumn( - 'discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Discount Tax Compensation Amount' - )->addColumn( - 'base_discount_tax_compensation_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Discount Tax Compensation Amount' - )->addColumn( - 'tax_ratio', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 512, - [], - 'Ratio of tax in the creditmemo item over tax of the order item' - )->addIndex( - $installer->getIdxName('sales_creditmemo_item', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_creditmemo_item', 'parent_id', 'sales_creditmemo', 'entity_id'), - 'parent_id', - $installer->getTable('sales_creditmemo'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Creditmemo Item' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_creditmemo_comment' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_creditmemo_comment') - )->addColumn( - 'entity_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Entity Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Parent Id' - )->addColumn( - 'is_customer_notified', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Is Customer Notified' - )->addColumn( - 'is_visible_on_front', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Is Visible On Front' - )->addColumn( - 'comment', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Comment' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addIndex( - $installer->getIdxName('sales_creditmemo_comment', ['created_at']), - ['created_at'] - )->addIndex( - $installer->getIdxName('sales_creditmemo_comment', ['parent_id']), - ['parent_id'] - )->addForeignKey( - $installer->getFkName('sales_creditmemo_comment', 'parent_id', 'sales_creditmemo', 'entity_id'), - 'parent_id', - $installer->getTable('sales_creditmemo'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Flat Creditmemo Comment' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_invoiced_aggregated' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoiced_aggregated') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Status' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'orders_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Orders Invoiced' - )->addColumn( - 'invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Invoiced' - )->addColumn( - 'invoiced_captured', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Invoiced Captured' - )->addColumn( - 'invoiced_not_captured', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Invoiced Not Captured' - )->addIndex( - $installer->getIdxName( - 'sales_invoiced_aggregated', - ['period', 'store_id', 'order_status'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_invoiced_aggregated', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_invoiced_aggregated', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Invoiced Aggregated' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_invoiced_aggregated_order' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_invoiced_aggregated_order') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - ['nullable' => false, 'default' => false], - 'Order Status' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'orders_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Orders Invoiced' - )->addColumn( - 'invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Invoiced' - )->addColumn( - 'invoiced_captured', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Invoiced Captured' - )->addColumn( - 'invoiced_not_captured', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Invoiced Not Captured' - )->addIndex( - $installer->getIdxName( - 'sales_invoiced_aggregated_order', - ['period', 'store_id', 'order_status'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_invoiced_aggregated_order', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_invoiced_aggregated_order', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Invoiced Aggregated Order' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_aggregated_created' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_aggregated_created') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - ['nullable' => false, 'default' => false], - 'Order Status' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'total_qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Qty Ordered' - )->addColumn( - 'total_qty_invoiced', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Qty Invoiced' - )->addColumn( - 'total_income_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Income Amount' - )->addColumn( - 'total_revenue_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Revenue Amount' - )->addColumn( - 'total_profit_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Profit Amount' - )->addColumn( - 'total_invoiced_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Invoiced Amount' - )->addColumn( - 'total_canceled_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Canceled Amount' - )->addColumn( - 'total_paid_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Paid Amount' - )->addColumn( - 'total_refunded_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Refunded Amount' - )->addColumn( - 'total_tax_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Tax Amount' - )->addColumn( - 'total_tax_amount_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Tax Amount Actual' - )->addColumn( - 'total_shipping_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Shipping Amount' - )->addColumn( - 'total_shipping_amount_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Shipping Amount Actual' - )->addColumn( - 'total_discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Discount Amount' - )->addColumn( - 'total_discount_amount_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Total Discount Amount Actual' - )->addIndex( - $installer->getIdxName( - 'sales_order_aggregated_created', - ['period', 'store_id', 'order_status'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_order_aggregated_created', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_order_aggregated_created', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Order Aggregated Created' - ); - $installer->getConnection()->createTable($table); - - $installer->getConnection()->createTable( - $installer->getConnection()->createTableByDdl( - $installer->getTable('sales_order_aggregated_created'), - $installer->getTable('sales_order_aggregated_updated') - ) - ); - - /** - * Create table 'sales_payment_transaction' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_payment_transaction') - )->addColumn( - 'transaction_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Transaction Id' - )->addColumn( - 'parent_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Parent Id' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Order Id' - )->addColumn( - 'payment_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Payment Id' - )->addColumn( - 'txn_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 100, - [], - 'Txn Id' - )->addColumn( - 'parent_txn_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 100, - [], - 'Parent Txn Id' - )->addColumn( - 'txn_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 15, - [], - 'Txn Type' - )->addColumn( - 'is_closed', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '1'], - 'Is Closed' - )->addColumn( - 'additional_information', - \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, - '64K', - [], - 'Additional Information' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Created At' - )->addIndex( - $installer->getIdxName( - 'sales_payment_transaction', - ['order_id', 'payment_id', 'txn_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['order_id', 'payment_id', 'txn_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_payment_transaction', ['parent_id']), - ['parent_id'] - )->addIndex( - $installer->getIdxName('sales_payment_transaction', ['payment_id']), - ['payment_id'] - )->addForeignKey( - $installer->getFkName('sales_payment_transaction', 'order_id', 'sales_order', 'entity_id'), - 'order_id', - $installer->getTable('sales_order'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName( - 'sales_payment_transaction', - 'parent_id', - 'sales_payment_transaction', - 'transaction_id' - ), - 'parent_id', - $installer->getTable('sales_payment_transaction'), - 'transaction_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_payment_transaction', 'payment_id', 'sales_order_payment', 'entity_id'), - 'payment_id', - $installer->getTable('sales_order_payment'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Payment Transaction' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_refunded_aggregated' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_refunded_aggregated') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - ['nullable' => false, 'default' => false], - 'Order Status' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Refunded' - )->addColumn( - 'online_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Online Refunded' - )->addColumn( - 'offline_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Offline Refunded' - )->addIndex( - $installer->getIdxName( - 'sales_refunded_aggregated', - ['period', 'store_id', 'order_status'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_refunded_aggregated', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_refunded_aggregated', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Refunded Aggregated' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_refunded_aggregated_order' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_refunded_aggregated_order') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Status' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Refunded' - )->addColumn( - 'online_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Online Refunded' - )->addColumn( - 'offline_refunded', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Offline Refunded' - )->addIndex( - $installer->getIdxName( - 'sales_refunded_aggregated_order', - ['period', 'store_id', 'order_status'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_refunded_aggregated_order', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_refunded_aggregated_order', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Refunded Aggregated Order' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipping_aggregated' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipping_aggregated') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Status' - )->addColumn( - 'shipping_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Description' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'total_shipping', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Shipping' - )->addColumn( - 'total_shipping_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Shipping Actual' - )->addIndex( - $installer->getIdxName( - 'sales_shipping_aggregated', - ['period', 'store_id', 'order_status', 'shipping_description'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status', 'shipping_description'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_shipping_aggregated', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_shipping_aggregated', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Shipping Aggregated' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_shipping_aggregated_order' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_shipping_aggregated_order') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Status' - )->addColumn( - 'shipping_description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Shipping Description' - )->addColumn( - 'orders_count', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Orders Count' - )->addColumn( - 'total_shipping', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Shipping' - )->addColumn( - 'total_shipping_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Total Shipping Actual' - )->addIndex( - $installer->getIdxName( - 'sales_shipping_aggregated_order', - ['period', 'store_id', 'order_status', 'shipping_description'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status', 'shipping_description'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_shipping_aggregated_order', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_shipping_aggregated_order', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL - )->setComment( - 'Sales Shipping Aggregated Order' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_bestsellers_aggregated_daily' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_bestsellers_aggregated_daily') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Product Id' - )->addColumn( - 'product_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => true], - 'Product Name' - )->addColumn( - 'product_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Product Price' - )->addColumn( - 'qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Qty Ordered' - )->addColumn( - 'rating_pos', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Rating Pos' - )->addIndex( - $installer->getIdxName( - 'sales_bestsellers_aggregated_daily', - ['period', 'store_id', 'product_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'product_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_daily', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_daily', ['product_id']), - ['product_id'] - )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_daily', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Bestsellers Aggregated Daily' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_bestsellers_aggregated_monthly' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_bestsellers_aggregated_monthly') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Product Id' - )->addColumn( - 'product_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => true], - 'Product Name' - )->addColumn( - 'product_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Product Price' - )->addColumn( - 'qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Qty Ordered' - )->addColumn( - 'rating_pos', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Rating Pos' - )->addIndex( - $installer->getIdxName( - 'sales_bestsellers_aggregated_monthly', - ['period', 'store_id', 'product_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'product_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_monthly', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_monthly', ['product_id']), - ['product_id'] - )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_monthly', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Bestsellers Aggregated Monthly' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_bestsellers_aggregated_yearly' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_bestsellers_aggregated_yearly') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'product_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Product Id' - )->addColumn( - 'product_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => true], - 'Product Name' - )->addColumn( - 'product_price', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Product Price' - )->addColumn( - 'qty_ordered', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false, 'default' => '0.0000'], - 'Qty Ordered' - )->addColumn( - 'rating_pos', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Rating Pos' - )->addIndex( - $installer->getIdxName( - 'sales_bestsellers_aggregated_yearly', - ['period', 'store_id', 'product_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'product_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_yearly', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('sales_bestsellers_aggregated_yearly', ['product_id']), - ['product_id'] - )->addForeignKey( - $installer->getFkName('sales_bestsellers_aggregated_yearly', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Bestsellers Aggregated Yearly' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_tax' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_tax') - )->addColumn( - 'tax_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Tax Id' - )->addColumn( - 'order_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Order Id' - )->addColumn( - 'code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Code' - )->addColumn( - 'title', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Title' - )->addColumn( - 'percent', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Percent' - )->addColumn( - 'amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Amount' - )->addColumn( - 'priority', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false], - 'Priority' - )->addColumn( - 'position', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false], - 'Position' - )->addColumn( - 'base_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Amount' - )->addColumn( - 'process', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['nullable' => false], - 'Process' - )->addColumn( - 'base_real_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - [], - 'Base Real Amount' - )->addIndex( - $installer->getIdxName('sales_order_tax', ['order_id', 'priority', 'position']), - ['order_id', 'priority', 'position'] - )->setComment( - 'Sales Order Tax Table' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_tax_item' - */ - $table = $setup->getConnection()->newTable( - $setup->getTable('sales_order_tax_item') - )->addColumn( - 'tax_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Tax Item Id' - )->addColumn( - 'tax_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Tax Id' - )->addColumn( - 'item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => true], - 'Item Id' - )->addColumn( - 'tax_percent', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Real Tax Percent For Item' - )->addColumn( - 'amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Tax amount for the item and tax rate' - )->addColumn( - 'base_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Base tax amount for the item and tax rate' - )->addColumn( - 'real_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Real tax amount for the item and tax rate' - )->addColumn( - 'real_base_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - '12,4', - ['nullable' => false], - 'Real base tax amount for the item and tax rate' - )->addColumn( - 'associated_item_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => true, 'unsigned' => true], - 'Id of the associated item' - )->addColumn( - 'taxable_item_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false], - 'Type of the taxable item' - )->addIndex( - $setup->getIdxName('sales_order_tax_item', ['item_id']), - ['item_id'] - )->addIndex( - $setup->getIdxName( - 'sales_order_tax_item', - ['tax_id', 'item_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['tax_id', 'item_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addForeignKey( - $setup->getFkName('sales_order_tax_item', 'associated_item_id', 'sales_order_item', 'item_id'), - 'associated_item_id', - $setup->getTable('sales_order_item'), - 'item_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $setup->getFkName('sales_order_tax_item', 'tax_id', 'sales_order_tax', 'tax_id'), - 'tax_id', - $setup->getTable('sales_order_tax'), - 'tax_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $setup->getFkName('sales_order_tax_item', 'item_id', 'sales_order_item', 'item_id'), - 'item_id', - $setup->getTable('sales_order_item'), - 'item_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Order Tax Item' - ); - $setup->getConnection()->createTable($table); - - /** - * Create table 'sales_order_status' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status') - )->addColumn( - 'status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false, 'primary' => true], - 'Status' - )->addColumn( - 'label', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - ['nullable' => false], - 'Label' - )->setComment( - 'Sales Order Status Table' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_status_state' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status_state') - )->addColumn( - 'status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false, 'primary' => true], - 'Status' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false, 'primary' => true], - 'Label' - )->addColumn( - 'is_default', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Is Default' - )->addColumn( - 'visible_on_front', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - 1, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Visible on front' - )->addForeignKey( - $installer->getFkName('sales_order_status_state', 'status', 'sales_order_status', 'status'), - 'status', - $installer->getTable('sales_order_status'), - 'status', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Order Status Table' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'sales_order_status_label' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('sales_order_status_label') - )->addColumn( - 'status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false, 'primary' => true], - 'Status' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Store Id' - )->addColumn( - 'label', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 128, - ['nullable' => false], - 'Label' - )->addIndex( - $installer->getIdxName('sales_order_status_label', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('sales_order_status_label', 'status', 'sales_order_status', 'status'), - 'status', - $installer->getTable('sales_order_status'), - 'status', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('sales_order_status_label', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Order Status Label Table' - ); - $installer->getConnection()->createTable($table); - - $installer->endSetup(); - } -} diff --git a/app/code/Magento/Sales/Setup/SalesSetup.php b/app/code/Magento/Sales/Setup/SalesSetup.php index ec8f7ce0f14d2..cfaa9106d1c7c 100644 --- a/app/code/Magento/Sales/Setup/SalesSetup.php +++ b/app/code/Magento/Sales/Setup/SalesSetup.php @@ -302,11 +302,6 @@ public function getEncryptor() return $this->encryptor; } - /** - * Get sales connection - * - * @return \Magento\Framework\DB\Adapter\AdapterInterface - */ public function getConnection() { return $this->getSetup()->getConnection(self::$connectionName); diff --git a/app/code/Magento/Sales/Setup/UpgradeSchema.php b/app/code/Magento/Sales/Setup/UpgradeSchema.php deleted file mode 100644 index 5dbf71e69e9b8..0000000000000 --- a/app/code/Magento/Sales/Setup/UpgradeSchema.php +++ /dev/null @@ -1,144 +0,0 @@ -startSetup(); - if (version_compare($context->getVersion(), '2.0.2', '<')) { - $connection = $installer->getConnection(self::$connectionName); - //sales_bestsellers_aggregated_daily - $connection->dropForeignKey( - $installer->getTable('sales_bestsellers_aggregated_daily', self::$connectionName), - $installer->getFkName( - 'sales_bestsellers_aggregated_daily', - 'product_id', - 'catalog_product_entity', - 'entity_id', - self::$connectionName - ) - ); - //sales_bestsellers_aggregated_monthly - $connection->dropForeignKey( - $installer->getTable('sales_bestsellers_aggregated_monthly', self::$connectionName), - $installer->getFkName( - 'sales_bestsellers_aggregated_monthly', - 'product_id', - 'catalog_product_entity', - 'entity_id', - self::$connectionName - ) - ); - - //sales_bestsellers_aggregated_yearly - $connection->dropForeignKey( - $installer->getTable('sales_bestsellers_aggregated_yearly', self::$connectionName), - $installer->getFkName( - 'sales_bestsellers_aggregated_yearly', - 'product_id', - 'catalog_product_entity', - 'entity_id', - self::$connectionName - ) - ); - - $installer->endSetup(); - } - if (version_compare($context->getVersion(), '2.0.3', '<')) { - $this->addColumnBaseGrandTotal($installer); - $this->addIndexBaseGrandTotal($installer); - } - if (version_compare($context->getVersion(), '2.0.4', '<')) { - $tables = [ - 'sales_invoice_grid', - 'sales_order', - 'sales_shipment_grid', - ]; - foreach ($tables as $table) { - $salesConnection = $setup->getConnection(self::$connectionName); - $salesConnection->modifyColumn( - $installer->getTable($table, self::$connectionName), - 'customer_group_id', - ['type' => 'integer'] - ); - } - } - if (version_compare($context->getVersion(), '2.0.5', '<')) { - $connection = $installer->getConnection(self::$connectionName); - $connection->modifyColumn( - $installer->getTable('sales_order_payment', self::$connectionName), - 'cc_number_enc', - [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 128 - ] - ); - } - if (version_compare($context->getVersion(), '2.0.7', '<')) { - $connection = $installer->getConnection(self::$connectionName); - $connection->modifyColumn( - $installer->getTable('sales_order', self::$connectionName), - 'shipping_method', - [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 'length' => 120 - ] - ); - } - } - - /** - * @param SchemaSetupInterface $installer - * @return void - */ - private function addColumnBaseGrandTotal(SchemaSetupInterface $installer) - { - $connection = $installer->getConnection(self::$connectionName); - $connection->addColumn( - $installer->getTable('sales_invoice_grid', self::$connectionName), - 'base_grand_total', - [ - 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - 'nullable' => true, - 'length' => '12,4', - 'comment' => 'Base Grand Total', - 'after' => 'grand_total' - ] - ); - } - - /** - * @param SchemaSetupInterface $installer - * @return void - */ - private function addIndexBaseGrandTotal(SchemaSetupInterface $installer) - { - $connection = $installer->getConnection(self::$connectionName); - $connection->addIndex( - $installer->getTable('sales_invoice_grid', self::$connectionName), - $installer->getIdxName('sales_invoice_grid', ['base_grand_total'], '', self::$connectionName), - ['base_grand_total'] - ); - } -} diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php index 20f7a7061b6b0..a390c43276085 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractItemsTest.php @@ -84,7 +84,7 @@ public function testGetItemRenderer() */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $renderer = $this->createMock(\StdClass::class); + $renderer = $this->createMock(\stdClass::class); $layout = $this->createPartialMock( \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', '__wakeup'] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php index 311e5f697675b..a34373f516c42 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Items/AbstractTest.php @@ -62,7 +62,7 @@ public function testGetItemRenderer() */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $renderer = $this->createMock(\StdClass::class); + $renderer = $this->createMock(\stdClass::class); $layout = $this->createPartialMock( \Magento\Framework\View\Layout::class, ['getChildName', 'getBlock', '__wakeup'] diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/AbstractCreateTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/AbstractCreateTest.php index 447fd7791ecbd..e010674ca354e 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/AbstractCreateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/AbstractCreateTest.php @@ -3,8 +3,10 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Create; +use Magento\Catalog\Model\Product; use Magento\Catalog\Pricing\Price\FinalPrice; class AbstractCreateTest extends \PHPUnit\Framework\TestCase @@ -67,4 +69,34 @@ public function testGetItemPrice() ->willReturn($resultPrice); $this->assertEquals($resultPrice, $this->model->getItemPrice($this->productMock)); } + + /** + * @param $item + * + * @dataProvider getProductDataProvider + */ + public function testGetProduct($item) + { + $product = $this->model->getProduct($item); + + self::assertInstanceOf(Product::class, $product); + } + + /** + * DataProvider for testGetProduct. + * + * @return array + */ + public function getProductDataProvider() + { + $productMock = $this->createMock(Product::class); + + $itemMock = $this->createMock(\Magento\Wishlist\Model\Item::class); + $itemMock->expects($this->once())->method('getProduct')->willReturn($productMock); + + return [ + [$productMock], + [$itemMock], + ]; + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php index 3bdbacadad230..3dab9178739b8 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php @@ -6,8 +6,25 @@ namespace Magento\Sales\Test\Unit\Model\AdminOrder; +use Magento\Backend\Model\Session\Quote as SessionQuote; +use Magento\Customer\Api\Data\AttributeMetadataInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Customer\Api\Data\GroupInterface; +use Magento\Customer\Api\GroupRepositoryInterface; +use Magento\Customer\Model\Customer\Mapper; +use Magento\Customer\Model\Metadata\Form; +use Magento\Customer\Model\Metadata\FormFactory; +use Magento\Framework\Api\DataObjectHelper; +use Magento\Framework\App\RequestInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Model\Quote\Item; +use Magento\Quote\Model\Quote\Item\Updater; +use Magento\Sales\Model\AdminOrder\Create; use Magento\Sales\Model\AdminOrder\Product; +use PHPUnit_Framework_MockObject_MockObject as MockObject; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -17,169 +34,74 @@ class CreateTest extends \PHPUnit\Framework\TestCase { const CUSTOMER_ID = 1; - /** @var \Magento\Sales\Model\AdminOrder\Create */ - protected $adminOrderCreate; - - /** @var \Magento\Backend\Model\Session\Quote|\PHPUnit_Framework_MockObject_MockObject */ - protected $sessionQuoteMock; - - /** @var \Magento\Customer\Model\Metadata\FormFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $formFactoryMock; - - /** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $customerFactoryMock; - - /** @var \Magento\Quote\Model\Quote\Item\Updater|\PHPUnit_Framework_MockObject_MockObject */ - protected $itemUpdater; - - /** @var \Magento\Customer\Model\Customer\Mapper|\PHPUnit_Framework_MockObject_MockObject */ - protected $customerMapper; - /** - * @var Product\Quote\Initializer|\PHPUnit_Framework_MockObject_MockObject + * @var Create */ - protected $quoteInitializerMock; + private $adminOrderCreate; /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + * @var SessionQuote|MockObject */ - protected $customerRepositoryMock; + private $sessionQuote; /** - * @var \Magento\Customer\Api\AddressRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + * @var FormFactory|MockObject */ - protected $addressRepositoryMock; + private $formFactory; /** - * @var \Magento\Customer\Api\Data\AddressInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CustomerInterfaceFactory|MockObject */ - protected $addressFactoryMock; + private $customerFactory; /** - * @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + * @var Updater|MockObject */ - protected $groupRepositoryMock; + private $itemUpdater; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var Mapper|MockObject */ - protected $scopeConfigMock; + private $customerMapper; /** - * @var \Magento\Sales\Model\AdminOrder\EmailSender|\PHPUnit_Framework_MockObject_MockObject + * @var GroupRepositoryInterface|MockObject */ - protected $emailSenderMock; + private $groupRepository; /** - * @var \Magento\Customer\Api\AccountManagementInterface|\PHPUnit_Framework_MockObject_MockObject + * @var DataObjectHelper|MockObject */ - protected $accountManagementMock; + private $dataObjectHelper; - /** - * @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject - */ - protected $dataObjectHelper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $objectFactory; - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ protected function setUp() { - $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); - $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $registryMock = $this->createMock(\Magento\Framework\Registry::class); - $configMock = $this->createMock(\Magento\Sales\Model\Config::class); - $this->sessionQuoteMock = $this->createMock(\Magento\Backend\Model\Session\Quote::class); - $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); - $copyMock = $this->createMock(\Magento\Framework\DataObject\Copy::class); - $messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); - $this->formFactoryMock = $this->createPartialMock( - \Magento\Customer\Model\Metadata\FormFactory::class, - ['create'] - ); - $this->customerFactoryMock = $this->createPartialMock( - \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, - ['create'] - ); + $this->sessionQuote = $this->createMock(SessionQuote::class); + $this->formFactory = $this->createPartialMock(FormFactory::class, ['create']); + $this->customerFactory = $this->createPartialMock(CustomerInterfaceFactory::class, ['create']); - $this->itemUpdater = $this->createMock(\Magento\Quote\Model\Quote\Item\Updater::class); + $this->itemUpdater = $this->createMock(Updater::class); - $this->objectFactory = $this->getMockBuilder(\Magento\Framework\DataObject\Factory::class) + $this->customerMapper = $this->getMockBuilder(Mapper::class) + ->setMethods(['toFlatArray']) ->disableOriginalConstructor() - ->setMethods(['create']) ->getMock(); - $this->customerMapper = $this->getMockBuilder( - \Magento\Customer\Model\Customer\Mapper::class - )->setMethods(['toFlatArray'])->disableOriginalConstructor()->getMock(); - - $this->quoteInitializerMock = $this->createMock( - \Magento\Sales\Model\AdminOrder\Product\Quote\Initializer::class - ); - $this->customerRepositoryMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\CustomerRepositoryInterface::class, - [], - '', - false - ); - $this->addressRepositoryMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\AddressRepositoryInterface::class, - [], - '', - false - ); - $this->addressFactoryMock = $this->createMock(\Magento\Customer\Api\Data\AddressInterfaceFactory::class); - $this->groupRepositoryMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\GroupRepositoryInterface::class, - [], - '', - false - ); - $this->scopeConfigMock = $this->getMockForAbstractClass( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - [], - '', - false - ); - $this->emailSenderMock = $this->createMock(\Magento\Sales\Model\AdminOrder\EmailSender::class); - $this->accountManagementMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\AccountManagementInterface::class, - [], - '', - false - ); - $this->dataObjectHelper = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) + $this->groupRepository = $this->getMockForAbstractClass(GroupRepositoryInterface::class); + $this->dataObjectHelper = $this->getMockBuilder(DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); $objectManagerHelper = new ObjectManagerHelper($this); $this->adminOrderCreate = $objectManagerHelper->getObject( - \Magento\Sales\Model\AdminOrder\Create::class, + Create::class, [ - 'objectManager' => $objectManagerMock, - 'eventManager' => $eventManagerMock, - 'coreRegistry' => $registryMock, - 'salesConfig' => $configMock, - 'quoteSession' => $this->sessionQuoteMock, - 'logger' => $loggerMock, - 'objectCopyService' => $copyMock, - 'messageManager' => $messageManagerMock, - 'quoteInitializer' => $this->quoteInitializerMock, - 'customerRepository' => $this->customerRepositoryMock, - 'addressRepository' => $this->addressRepositoryMock, - 'addressFactory' => $this->addressFactoryMock, - 'metadataFormFactory' => $this->formFactoryMock, - 'customerFactory' => $this->customerFactoryMock, - 'groupRepository' => $this->groupRepositoryMock, + 'quoteSession' => $this->sessionQuote, + 'metadataFormFactory' => $this->formFactory, + 'customerFactory' => $this->customerFactory, + 'groupRepository' => $this->groupRepository, 'quoteItemUpdater' => $this->itemUpdater, 'customerMapper' => $this->customerMapper, - 'objectFactory' => $this->objectFactory, - 'accountManagement' => $this->accountManagementMock, 'dataObjectHelper' => $this->dataObjectHelper, ] ); @@ -194,65 +116,60 @@ public function testSetAccountData() ]; $attributeMocks = []; - foreach ($attributes as $attribute) { - $attributeMock = $this->createMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); - - $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attribute[0])); + foreach ($attributes as $value) { + $attribute = $this->createMock(AttributeMetadataInterface::class); + $attribute->method('getAttributeCode') + ->willReturn($value[0]); - $attributeMocks[] = $attributeMock; + $attributeMocks[] = $attribute; } - $customerGroupMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\Data\GroupInterface::class, - [], - '', - false, - true, - true, - ['getTaxClassId'] - ); - $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId)); - $customerFormMock = $this->createMock(\Magento\Customer\Model\Metadata\Form::class); - $customerFormMock->expects($this->any()) - ->method('getAttributes') - ->will($this->returnValue([$attributeMocks[1]])); - $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue([])); - $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue(['group_id' => 1])); - - $customerFormMock->expects($this->any()) - ->method('prepareRequest') - ->will($this->returnValue($this->createMock(\Magento\Framework\App\RequestInterface::class))); - - $customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); - $this->customerMapper->expects($this->atLeastOnce()) + $customerGroup = $this->getMockForAbstractClass(GroupInterface::class); + $customerGroup->method('getTaxClassId') + ->willReturn($taxClassId); + $customerForm = $this->createMock(Form::class); + $customerForm->method('getAttributes') + ->willReturn([$attributeMocks[1]]); + $customerForm + ->method('extractData') + ->willReturn([]); + $customerForm + ->method('restoreData') + ->willReturn(['group_id' => 1]); + + $customerForm->method('prepareRequest') + ->willReturn($this->createMock(RequestInterface::class)); + + $customer = $this->createMock(CustomerInterface::class); + $this->customerMapper->expects(self::atLeastOnce()) ->method('toFlatArray') ->willReturn(['group_id' => 1]); - $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); - $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock)); - $quoteMock->expects($this->once()) - ->method('addData') - ->with( - [ - 'customer_group_id' => $attributes[1][1], - 'customer_tax_class_id' => $taxClassId - ] - ); - $this->dataObjectHelper->expects($this->once()) - ->method('populateWithArray') + $quote = $this->createMock(Quote::class); + $quote->method('getCustomer')->willReturn($customer); + $quote->method('addData')->with( + [ + 'customer_group_id' => $attributes[1][1], + 'customer_tax_class_id' => $taxClassId + ] + ); + $this->dataObjectHelper->method('populateWithArray') ->with( - $customerMock, + $customer, ['group_id' => 1], - \Magento\Customer\Api\Data\CustomerInterface::class + CustomerInterface::class ); - $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock)); - $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); - $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerMock)); + $this->formFactory->method('create') + ->willReturn($customerForm); + $this->sessionQuote + ->method('getQuote') + ->willReturn($quote); + $this->customerFactory->method('create') + ->willReturn($customer); - $this->groupRepositoryMock->expects($this->once()) - ->method('getById') - ->will($this->returnValue($customerGroupMock)); + $this->groupRepository->method('getById') + ->willReturn($customerGroup); $this->adminOrderCreate->setAccountData(['group_id' => 1]); } @@ -260,7 +177,7 @@ public function testSetAccountData() public function testUpdateQuoteItemsNotArray() { $object = $this->adminOrderCreate->updateQuoteItems('string'); - $this->assertEquals($this->adminOrderCreate, $object); + self::assertEquals($this->adminOrderCreate, $object); } public function testUpdateQuoteItemsEmptyConfiguredOption() @@ -273,22 +190,21 @@ public function testUpdateQuoteItemsEmptyConfiguredOption() ] ]; - $itemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); + $item = $this->createMock(Item::class); - $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); - $quoteMock->expects($this->once()) - ->method('getItemById') - ->will($this->returnValue($itemMock)); + $quote = $this->createMock(Quote::class); + $quote->method('getItemById') + ->willReturn($item); - $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); - $this->itemUpdater->expects($this->once()) - ->method('update') - ->with($this->equalTo($itemMock), $this->equalTo($items[1])) - ->will($this->returnSelf()); + $this->sessionQuote->method('getQuote') + ->willReturn($quote); + $this->itemUpdater->method('update') + ->with(self::equalTo($item), self::equalTo($items[1])) + ->willReturnSelf(); $this->adminOrderCreate->setRecollect(false); $object = $this->adminOrderCreate->updateQuoteItems($items); - $this->assertEquals($this->adminOrderCreate, $object); + self::assertEquals($this->adminOrderCreate, $object); } public function testUpdateQuoteItemsWithConfiguredOption() @@ -302,49 +218,50 @@ public function testUpdateQuoteItemsWithConfiguredOption() ] ]; - $itemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); - $itemMock->expects($this->once()) - ->method('getQty') - ->will($this->returnValue($qty)); + $item = $this->createMock(Item::class); + $item->method('getQty') + ->willReturn($qty); - $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); - $quoteMock->expects($this->once()) - ->method('updateItem') - ->will($this->returnValue($itemMock)); + $quote = $this->createMock(Quote::class); + $quote->method('updateItem') + ->willReturn($item); - $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); + $this->sessionQuote + ->method('getQuote') + ->willReturn($quote); $expectedInfo = $items[1]; $expectedInfo['qty'] = $qty; - $this->itemUpdater->expects($this->once()) - ->method('update') - ->with($this->equalTo($itemMock), $this->equalTo($expectedInfo)); + $this->itemUpdater->method('update') + ->with(self::equalTo($item), self::equalTo($expectedInfo)); $this->adminOrderCreate->setRecollect(false); $object = $this->adminOrderCreate->updateQuoteItems($items); - $this->assertEquals($this->adminOrderCreate, $object); + self::assertEquals($this->adminOrderCreate, $object); } public function testApplyCoupon() { - $couponCode = ''; - $quoteMock = $this->createPartialMock( - \Magento\Quote\Model\Quote::class, - ['getShippingAddress', 'setCouponCode'] - ); - $this->sessionQuoteMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); - - $addressMock = $this->createPartialMock( - \Magento\Quote\Model\Quote\Address::class, - ['setCollectShippingRates', 'setFreeShipping'] - ); - $quoteMock->expects($this->exactly(2))->method('getShippingAddress')->willReturn($addressMock); - $quoteMock->expects($this->once())->method('setCouponCode')->with($couponCode)->willReturnSelf(); - - $addressMock->expects($this->once())->method('setCollectShippingRates')->with(true)->willReturnSelf(); - $addressMock->expects($this->once())->method('setFreeShipping')->with(0)->willReturnSelf(); + $couponCode = '123'; + $quote = $this->createPartialMock(Quote::class, ['getShippingAddress', 'setCouponCode']); + $this->sessionQuote->method('getQuote') + ->willReturn($quote); + + $address = $this->createPartialMock(Address::class, ['setCollectShippingRates', 'setFreeShipping']); + $quote->method('getShippingAddress') + ->willReturn($address); + $quote->method('setCouponCode') + ->with($couponCode) + ->willReturnSelf(); + + $address->method('setCollectShippingRates') + ->with(true) + ->willReturnSelf(); + $address->method('setFreeShipping') + ->with(0) + ->willReturnSelf(); $object = $this->adminOrderCreate->applyCoupon($couponCode); - $this->assertEquals($this->adminOrderCreate, $object); + self::assertEquals($this->adminOrderCreate, $object); } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php index f3a35e485c166..86419c0c905b6 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ConfigTest.php @@ -23,18 +23,41 @@ class ConfigTest extends \PHPUnit\Framework\TestCase */ protected $orderStatusCollectionFactoryMock; + /** + * @var \Magento\Sales\Model\Order\StatusFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $statusFactoryMock; + + /** + * @var \Magento\Sales\Model\Order\Status + */ + protected $orderStatusModel; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + protected function setUp() { - $orderStatusFactory = $this->createMock(\Magento\Sales\Model\Order\StatusFactory::class); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->orderStatusModel = $objectManager->getObject(\Magento\Sales\Model\Order\Status::class, [ + 'storeManager' => $this->storeManagerMock, + ]); + $this->statusFactoryMock = $this->getMockBuilder(\Magento\Sales\Model\Order\StatusFactory::class) + ->setMethods(['load', 'create']) + ->getMock(); $this->orderStatusCollectionFactoryMock = $this->createPartialMock( \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory::class, ['create'] ); - $this->salesConfig = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) + $this->salesConfig = $objectManager ->getObject( \Magento\Sales\Model\Order\Config::class, [ - 'orderStatusFactory' => $orderStatusFactory, + 'orderStatusFactory' => $this->statusFactoryMock, 'orderStatusCollectionFactory' => $this->orderStatusCollectionFactoryMock ] ); @@ -147,6 +170,22 @@ public function testGetStatuses($state, $joinLabels, $collectionData, $expectedR ->method('joinStates') ->will($this->returnValue($collectionData)); + $this->statusFactoryMock->method('create') + ->willReturnSelf(); + + $this->statusFactoryMock->method('load') + ->willReturn($this->orderStatusModel); + + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock->method('getId') + ->willReturn(1); + + $this->storeManagerMock->method('getStore') + ->with($this->anything()) + ->willReturn($storeMock); + + $this->orderStatusModel->setData('store_labels', [1 => 'Pending label']); + $result = $this->salesConfig->getStateStatuses($state, $joinLabels); $this->assertSame($expectedResult, $result); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php index 5319aa510bedf..38209bb22aef4 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php @@ -3,8 +3,10 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Sales\Test\Unit\Model\Order\Email; +use Magento\Framework\Mail\Template\TransportBuilderByStore; use Magento\Sales\Model\Order\Email\SenderBuilder; class SenderBuilderTest extends \PHPUnit\Framework\TestCase @@ -29,6 +31,16 @@ class SenderBuilderTest extends \PHPUnit\Framework\TestCase */ protected $transportBuilder; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $storeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $transportBuilderByStore; + protected function setUp() { $templateId = 'test_template_id'; @@ -42,7 +54,11 @@ protected function setUp() ['getTemplateVars', 'getTemplateOptions', 'getTemplateId'] ); - $this->storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getStoreId', '__wakeup']); + $this->storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, [ + 'getStoreId', + '__wakeup', + 'getId', + ]); $this->identityContainerMock = $this->createPartialMock( \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity::class, @@ -52,15 +68,24 @@ protected function setUp() 'getCustomerName', 'getTemplateOptions', 'getEmailCopyTo', - 'getCopyMethod' + 'getCopyMethod', + 'getStore', ] ); - $this->transportBuilder = $this->createPartialMock(\Magento\Framework\Mail\Template\TransportBuilder::class, [ - 'addTo', 'addBcc', 'getTransport', - 'setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', - 'setFrom', - ]); + $this->transportBuilder = $this->createPartialMock( + \Magento\Framework\Mail\Template\TransportBuilder::class, + [ + 'addTo', + 'addBcc', + 'getTransport', + 'setTemplateIdentifier', + 'setTemplateOptions', + 'setTemplateVars', + ] + ); + + $this->transportBuilderByStore = $this->createMock(TransportBuilderByStore::class); $this->templateContainerMock->expects($this->once()) ->method('getTemplateId') @@ -84,8 +109,8 @@ protected function setUp() $this->identityContainerMock->expects($this->once()) ->method('getEmailIdentity') ->will($this->returnValue($emailIdentity)); - $this->transportBuilder->expects($this->once()) - ->method('setFrom') + $this->transportBuilderByStore->expects($this->once()) + ->method('setFromByStore') ->with($this->equalTo($emailIdentity)); $this->identityContainerMock->expects($this->once()) @@ -95,7 +120,8 @@ protected function setUp() $this->senderBuilder = new SenderBuilder( $this->templateContainerMock, $this->identityContainerMock, - $this->transportBuilder + $this->transportBuilder, + $this->transportBuilderByStore ); } @@ -119,6 +145,12 @@ public function testSend() $this->identityContainerMock->expects($this->once()) ->method('getCustomerName') ->will($this->returnValue($customerName)); + $this->identityContainerMock->expects($this->once()) + ->method('getStore') + ->willReturn($this->storeMock); + $this->storeMock->expects($this->once()) + ->method('getId') + ->willReturn(1); $this->transportBuilder->expects($this->once()) ->method('addTo') ->with($this->equalTo($customerEmail), $this->equalTo($customerName)); @@ -145,7 +177,12 @@ public function testSendCopyTo() $this->transportBuilder->expects($this->once()) ->method('addTo') ->with($this->equalTo('example@mail.com')); - + $this->identityContainerMock->expects($this->once()) + ->method('getStore') + ->willReturn($this->storeMock); + $this->storeMock->expects($this->once()) + ->method('getId') + ->willReturn(1); $this->transportBuilder->expects($this->once()) ->method('getTransport') ->will($this->returnValue($transportMock)); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php index 70e5ad127e44c..293c2eea1231d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Payment/InfoTest.php @@ -179,7 +179,7 @@ public function testDecrypt() */ public function testSetAdditionalInformationException() { - $this->info->setAdditionalInformation('object', new \StdClass()); + $this->info->setAdditionalInformation('object', new \stdClass()); } /** diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php index c91d4edb155a4..0761b5abb5d45 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/AbstractTest.php @@ -19,7 +19,7 @@ public function testInsertTotals() // Setup parameters, that will be passed to the tested model method $page = $this->createMock(\Zend_Pdf_Page::class); - $order = new \StdClass(); + $order = new \stdClass(); $source = $this->createMock(\Magento\Sales\Model\Order\Invoice::class); $source->expects($this->any())->method('getOrder')->will($this->returnValue($order)); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php index b1b51c3f12330..b808a4139e84e 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Pdf/Config/ReaderTest.php @@ -87,7 +87,7 @@ protected function setUp() public function testRead() { $expectedResult = new \stdClass(); - $constraint = function (\DOMDOcument $actual) { + $constraint = function (\DOMDocument $actual) { try { $expected = __DIR__ . '/_files/pdf_merged.xml'; \PHPUnit\Framework\Assert::assertXmlStringEqualsXmlFile($expected, $actual->saveXML()); diff --git a/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php index 9ecab6cf9ab52..2e668f0b0d6f1 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php @@ -243,6 +243,78 @@ public function testRefund() $this->assertSame($creditMemoMock, $this->creditmemoService->refund($creditMemoMock, true)); } + public function testRefundPendingCreditMemo() + { + $creditMemoMock = $this->getMockBuilder(\Magento\Sales\Api\Data\CreditmemoInterface::class) + ->setMethods(['getId', 'getOrder', 'getState', 'getInvoice']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $creditMemoMock->expects($this->once())->method('getId')->willReturn(444); + $creditMemoMock->expects($this->once())->method('getState') + ->willReturn(\Magento\Sales\Model\Order\Creditmemo::STATE_OPEN); + $orderMock = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock(); + + $creditMemoMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($orderMock); + $orderMock->expects($this->once())->method('getBaseTotalRefunded')->willReturn(0); + $orderMock->expects($this->once())->method('getBaseTotalPaid')->willReturn(10); + $creditMemoMock->expects($this->once())->method('getBaseGrandTotal')->willReturn(10); + + $this->priceCurrencyMock->expects($this->any()) + ->method('round') + ->willReturnArgument(0); + + // Set payment adapter dependency + $refundAdapterMock = $this->getMockBuilder(\Magento\Sales\Model\Order\RefundAdapterInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->objectManagerHelper->setBackwardCompatibleProperty( + $this->creditmemoService, + 'refundAdapter', + $refundAdapterMock + ); + + // Set resource dependency + $resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class) + ->disableOriginalConstructor() + ->getMock(); + $this->objectManagerHelper->setBackwardCompatibleProperty( + $this->creditmemoService, + 'resource', + $resourceMock + ); + + // Set order repository dependency + $orderRepositoryMock = $this->getMockBuilder(\Magento\Sales\Api\OrderRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->objectManagerHelper->setBackwardCompatibleProperty( + $this->creditmemoService, + 'orderRepository', + $orderRepositoryMock + ); + + $adapterMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $resourceMock->expects($this->once())->method('getConnection')->with('sales')->willReturn($adapterMock); + $adapterMock->expects($this->once())->method('beginTransaction'); + $refundAdapterMock->expects($this->once()) + ->method('refund') + ->with($creditMemoMock, $orderMock, false) + ->willReturn($orderMock); + $orderRepositoryMock->expects($this->once()) + ->method('save') + ->with($orderMock); + $creditMemoMock->expects($this->once()) + ->method('getInvoice') + ->willReturn(null); + $adapterMock->expects($this->once())->method('commit'); + $this->creditmemoRepositoryMock->expects($this->once()) + ->method('save'); + + $this->assertSame($creditMemoMock, $this->creditmemoService->refund($creditMemoMock, true)); + } + /** * @expectedExceptionMessage The most money available to refund is 1. * @expectedException \Magento\Framework\Exception\LocalizedException diff --git a/app/code/Magento/Sales/Test/Unit/Setup/SalesSetupTest.php b/app/code/Magento/Sales/Test/Unit/Setup/SalesSetupTest.php new file mode 100644 index 0000000000000..51ff936fd5ef7 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Setup/SalesSetupTest.php @@ -0,0 +1,89 @@ +moduleDataSetupMock = $this->getMockBuilder(\Magento\Framework\Setup\ModuleDataSetupInterface::class) + ->getMockForAbstractClass(); + $this->contextMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Setup\Context::class) + ->disableOriginalConstructor() + ->getMock(); + $this->cacheMock = $this->getMockBuilder(\Magento\Framework\App\CacheInterface::class) + ->getMockForAbstractClass(); + $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) + ->getMockForAbstractClass(); + + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->model = $this->objectManagerHelper->getObject( + \Magento\Sales\Setup\SalesSetup::class, + [ + 'setup' => $this->moduleDataSetupMock, + 'context' => $this->contextMock, + 'cache' => $this->cacheMock, + 'attrGroupCollectionFactory' => $this->collectionFactoryMock, + 'config' => $this->scopeConfigMock + ] + ); + } + + public function testGetConnection() + { + $this->moduleDataSetupMock->expects($this->once()) + ->method('getConnection') + ->with('sales'); + $this->model->getConnection(); + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php index 1a903ab68952c..c79b06da60c4e 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php @@ -47,7 +47,7 @@ public function testPrepareDataSource() { $itemName = 'itemName'; $oldItemValue = "itemValue\n"; - $newItemValue = 'itemValue
    '; + $newItemValue = "itemValue
    \n"; $dataSource = [ 'data' => [ 'items' => [ @@ -57,7 +57,7 @@ public function testPrepareDataSource() ]; $this->model->setData('name', $itemName); - $this->escaper->expects($this->once())->method('escapeHtml')->with($newItemValue)->willReturnArgument(0); + $this->escaper->expects($this->any())->method('escapeHtml')->with($oldItemValue)->willReturnArgument(0); $dataSource = $this->model->prepareDataSource($dataSource); $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); } diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php index 23a6e7a41a5b7..d900bb7ba670f 100644 --- a/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php @@ -49,9 +49,7 @@ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { - $item[$this->getData('name')] = $this->escaper->escapeHtml( - str_replace("\n", '
    ', $item[$this->getData('name')]) - ); + $item[$this->getData('name')] = nl2br($this->escaper->escapeHtml($item[$this->getData('name')])); } } diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml new file mode 100644 index 0000000000000..c084a5b87b109 --- /dev/null +++ b/app/code/Magento/Sales/etc/db_schema.xml @@ -0,0 +1,2063 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + +
    + + + + + + + + + + +
    + + + + + + + + + + + + + +
    +
    diff --git a/app/code/Magento/Sales/etc/db_schema_whitelist.json b/app/code/Magento/Sales/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..415ee7f0b26c1 --- /dev/null +++ b/app/code/Magento/Sales/etc/db_schema_whitelist.json @@ -0,0 +1,1248 @@ +{ + "sales_order": { + "column": { + "entity_id": true, + "state": true, + "status": true, + "coupon_code": true, + "protect_code": true, + "shipping_description": true, + "is_virtual": true, + "store_id": true, + "customer_id": true, + "base_discount_amount": true, + "base_discount_canceled": true, + "base_discount_invoiced": true, + "base_discount_refunded": true, + "base_grand_total": true, + "base_shipping_amount": true, + "base_shipping_canceled": true, + "base_shipping_invoiced": true, + "base_shipping_refunded": true, + "base_shipping_tax_amount": true, + "base_shipping_tax_refunded": true, + "base_subtotal": true, + "base_subtotal_canceled": true, + "base_subtotal_invoiced": true, + "base_subtotal_refunded": true, + "base_tax_amount": true, + "base_tax_canceled": true, + "base_tax_invoiced": true, + "base_tax_refunded": true, + "base_to_global_rate": true, + "base_to_order_rate": true, + "base_total_canceled": true, + "base_total_invoiced": true, + "base_total_invoiced_cost": true, + "base_total_offline_refunded": true, + "base_total_online_refunded": true, + "base_total_paid": true, + "base_total_qty_ordered": true, + "base_total_refunded": true, + "discount_amount": true, + "discount_canceled": true, + "discount_invoiced": true, + "discount_refunded": true, + "grand_total": true, + "shipping_amount": true, + "shipping_canceled": true, + "shipping_invoiced": true, + "shipping_refunded": true, + "shipping_tax_amount": true, + "shipping_tax_refunded": true, + "store_to_base_rate": true, + "store_to_order_rate": true, + "subtotal": true, + "subtotal_canceled": true, + "subtotal_invoiced": true, + "subtotal_refunded": true, + "tax_amount": true, + "tax_canceled": true, + "tax_invoiced": true, + "tax_refunded": true, + "total_canceled": true, + "total_invoiced": true, + "total_offline_refunded": true, + "total_online_refunded": true, + "total_paid": true, + "total_qty_ordered": true, + "total_refunded": true, + "can_ship_partially": true, + "can_ship_partially_item": true, + "customer_is_guest": true, + "customer_note_notify": true, + "billing_address_id": true, + "customer_group_id": true, + "edit_increment": true, + "email_sent": true, + "send_email": true, + "forced_shipment_with_invoice": true, + "payment_auth_expiration": true, + "quote_address_id": true, + "quote_id": true, + "shipping_address_id": true, + "adjustment_negative": true, + "adjustment_positive": true, + "base_adjustment_negative": true, + "base_adjustment_positive": true, + "base_shipping_discount_amount": true, + "base_subtotal_incl_tax": true, + "base_total_due": true, + "payment_authorization_amount": true, + "shipping_discount_amount": true, + "subtotal_incl_tax": true, + "total_due": true, + "weight": true, + "customer_dob": true, + "increment_id": true, + "applied_rule_ids": true, + "base_currency_code": true, + "customer_email": true, + "customer_firstname": true, + "customer_lastname": true, + "customer_middlename": true, + "customer_prefix": true, + "customer_suffix": true, + "customer_taxvat": true, + "discount_description": true, + "ext_customer_id": true, + "ext_order_id": true, + "global_currency_code": true, + "hold_before_state": true, + "hold_before_status": true, + "order_currency_code": true, + "original_increment_id": true, + "relation_child_id": true, + "relation_child_real_id": true, + "relation_parent_id": true, + "relation_parent_real_id": true, + "remote_ip": true, + "shipping_method": true, + "store_currency_code": true, + "store_name": true, + "x_forwarded_for": true, + "customer_note": true, + "created_at": true, + "updated_at": true, + "total_item_count": true, + "customer_gender": true, + "discount_tax_compensation_amount": true, + "base_discount_tax_compensation_amount": true, + "shipping_discount_tax_compensation_amount": true, + "base_shipping_discount_tax_compensation_amnt": true, + "discount_tax_compensation_invoiced": true, + "base_discount_tax_compensation_invoiced": true, + "discount_tax_compensation_refunded": true, + "base_discount_tax_compensation_refunded": true, + "shipping_incl_tax": true, + "base_shipping_incl_tax": true, + "coupon_rule_name": true + }, + "index": { + "SALES_ORDER_STATUS": true, + "SALES_ORDER_STATE": true, + "SALES_ORDER_STORE_ID": true, + "SALES_ORDER_CREATED_AT": true, + "SALES_ORDER_CUSTOMER_ID": true, + "SALES_ORDER_EXT_ORDER_ID": true, + "SALES_ORDER_QUOTE_ID": true, + "SALES_ORDER_UPDATED_AT": true, + "SALES_ORDER_SEND_EMAIL": true, + "SALES_ORDER_EMAIL_SENT": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID": true, + "SALES_ORDER_STORE_ID_STORE_STORE_ID": true, + "SALES_ORDER_INCREMENT_ID_STORE_ID": true + } + }, + "sales_order_grid": { + "column": { + "entity_id": true, + "status": true, + "store_id": true, + "store_name": true, + "customer_id": true, + "base_grand_total": true, + "base_total_paid": true, + "grand_total": true, + "total_paid": true, + "increment_id": true, + "base_currency_code": true, + "order_currency_code": true, + "shipping_name": true, + "billing_name": true, + "created_at": true, + "updated_at": true, + "billing_address": true, + "shipping_address": true, + "shipping_information": true, + "customer_email": true, + "customer_group": true, + "subtotal": true, + "shipping_and_handling": true, + "customer_name": true, + "payment_method": true, + "total_refunded": true + }, + "index": { + "SALES_ORDER_GRID_STATUS": true, + "SALES_ORDER_GRID_STORE_ID": true, + "SALES_ORDER_GRID_BASE_GRAND_TOTAL": true, + "SALES_ORDER_GRID_BASE_TOTAL_PAID": true, + "SALES_ORDER_GRID_GRAND_TOTAL": true, + "SALES_ORDER_GRID_TOTAL_PAID": true, + "SALES_ORDER_GRID_SHIPPING_NAME": true, + "SALES_ORDER_GRID_BILLING_NAME": true, + "SALES_ORDER_GRID_CREATED_AT": true, + "SALES_ORDER_GRID_CUSTOMER_ID": true, + "SALES_ORDER_GRID_UPDATED_AT": true, + "FTI_65B9E9925EC58F0C7C2E2F6379C233E7": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_GRID_INCREMENT_ID_STORE_ID": true + } + }, + "sales_order_address": { + "column": { + "entity_id": true, + "parent_id": true, + "customer_address_id": true, + "quote_address_id": true, + "region_id": true, + "customer_id": true, + "fax": true, + "region": true, + "postcode": true, + "lastname": true, + "street": true, + "city": true, + "email": true, + "telephone": true, + "country_id": true, + "firstname": true, + "address_type": true, + "prefix": true, + "middlename": true, + "suffix": true, + "company": true, + "vat_id": true, + "vat_is_valid": true, + "vat_request_id": true, + "vat_request_date": true, + "vat_request_success": true + }, + "index": { + "SALES_ORDER_ADDRESS_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_ADDRESS_PARENT_ID_SALES_ORDER_ENTITY_ID": true + } + }, + "sales_order_status_history": { + "column": { + "entity_id": true, + "parent_id": true, + "is_customer_notified": true, + "is_visible_on_front": true, + "comment": true, + "status": true, + "created_at": true, + "entity_name": true + }, + "index": { + "SALES_ORDER_STATUS_HISTORY_PARENT_ID": true, + "SALES_ORDER_STATUS_HISTORY_CREATED_AT": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_STATUS_HISTORY_PARENT_ID_SALES_ORDER_ENTITY_ID": true + } + }, + "sales_order_item": { + "column": { + "item_id": true, + "order_id": true, + "parent_item_id": true, + "quote_item_id": true, + "store_id": true, + "created_at": true, + "updated_at": true, + "product_id": true, + "product_type": true, + "product_options": true, + "weight": true, + "is_virtual": true, + "sku": true, + "name": true, + "description": true, + "applied_rule_ids": true, + "additional_data": true, + "is_qty_decimal": true, + "no_discount": true, + "qty_backordered": true, + "qty_canceled": true, + "qty_invoiced": true, + "qty_ordered": true, + "qty_refunded": true, + "qty_shipped": true, + "base_cost": true, + "price": true, + "base_price": true, + "original_price": true, + "base_original_price": true, + "tax_percent": true, + "tax_amount": true, + "base_tax_amount": true, + "tax_invoiced": true, + "base_tax_invoiced": true, + "discount_percent": true, + "discount_amount": true, + "base_discount_amount": true, + "discount_invoiced": true, + "base_discount_invoiced": true, + "amount_refunded": true, + "base_amount_refunded": true, + "row_total": true, + "base_row_total": true, + "row_invoiced": true, + "base_row_invoiced": true, + "row_weight": true, + "base_tax_before_discount": true, + "tax_before_discount": true, + "ext_order_item_id": true, + "locked_do_invoice": true, + "locked_do_ship": true, + "price_incl_tax": true, + "base_price_incl_tax": true, + "row_total_incl_tax": true, + "base_row_total_incl_tax": true, + "discount_tax_compensation_amount": true, + "base_discount_tax_compensation_amount": true, + "discount_tax_compensation_invoiced": true, + "base_discount_tax_compensation_invoiced": true, + "discount_tax_compensation_refunded": true, + "base_discount_tax_compensation_refunded": true, + "tax_canceled": true, + "discount_tax_compensation_canceled": true, + "tax_refunded": true, + "base_tax_refunded": true, + "discount_refunded": true, + "base_discount_refunded": true + }, + "index": { + "SALES_ORDER_ITEM_ORDER_ID": true, + "SALES_ORDER_ITEM_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_ITEM_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "SALES_ORDER_ITEM_STORE_ID_STORE_STORE_ID": true + } + }, + "sales_order_payment": { + "column": { + "entity_id": true, + "parent_id": true, + "base_shipping_captured": true, + "shipping_captured": true, + "amount_refunded": true, + "base_amount_paid": true, + "amount_canceled": true, + "base_amount_authorized": true, + "base_amount_paid_online": true, + "base_amount_refunded_online": true, + "base_shipping_amount": true, + "shipping_amount": true, + "amount_paid": true, + "amount_authorized": true, + "base_amount_ordered": true, + "base_shipping_refunded": true, + "shipping_refunded": true, + "base_amount_refunded": true, + "amount_ordered": true, + "base_amount_canceled": true, + "quote_payment_id": true, + "additional_data": true, + "cc_exp_month": true, + "cc_ss_start_year": true, + "echeck_bank_name": true, + "method": true, + "cc_debug_request_body": true, + "cc_secure_verify": true, + "protection_eligibility": true, + "cc_approval": true, + "cc_last_4": true, + "cc_status_description": true, + "echeck_type": true, + "cc_debug_response_serialized": true, + "cc_ss_start_month": true, + "echeck_account_type": true, + "last_trans_id": true, + "cc_cid_status": true, + "cc_owner": true, + "cc_type": true, + "po_number": true, + "cc_exp_year": true, + "cc_status": true, + "echeck_routing_number": true, + "account_status": true, + "anet_trans_method": true, + "cc_debug_response_body": true, + "cc_ss_issue": true, + "echeck_account_name": true, + "cc_avs_status": true, + "cc_number_enc": true, + "cc_trans_id": true, + "address_status": true, + "additional_information": true + }, + "index": { + "SALES_ORDER_PAYMENT_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_PAYMENT_PARENT_ID_SALES_ORDER_ENTITY_ID": true + } + }, + "sales_shipment": { + "column": { + "entity_id": true, + "store_id": true, + "total_weight": true, + "total_qty": true, + "email_sent": true, + "send_email": true, + "order_id": true, + "customer_id": true, + "shipping_address_id": true, + "billing_address_id": true, + "shipment_status": true, + "increment_id": true, + "created_at": true, + "updated_at": true, + "packages": true, + "shipping_label": true, + "customer_note": true, + "customer_note_notify": true + }, + "index": { + "SALES_SHIPMENT_STORE_ID": true, + "SALES_SHIPMENT_TOTAL_QTY": true, + "SALES_SHIPMENT_ORDER_ID": true, + "SALES_SHIPMENT_CREATED_AT": true, + "SALES_SHIPMENT_UPDATED_AT": true, + "SALES_SHIPMENT_SEND_EMAIL": true, + "SALES_SHIPMENT_EMAIL_SENT": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPMENT_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "SALES_SHIPMENT_STORE_ID_STORE_STORE_ID": true, + "SALES_SHIPMENT_INCREMENT_ID_STORE_ID": true + } + }, + "sales_shipment_grid": { + "column": { + "entity_id": true, + "increment_id": true, + "store_id": true, + "order_increment_id": true, + "order_id": true, + "order_created_at": true, + "customer_name": true, + "total_qty": true, + "shipment_status": true, + "order_status": true, + "billing_address": true, + "shipping_address": true, + "billing_name": true, + "shipping_name": true, + "customer_email": true, + "customer_group_id": true, + "payment_method": true, + "shipping_information": true, + "created_at": true, + "updated_at": true + }, + "index": { + "SALES_SHIPMENT_GRID_STORE_ID": true, + "SALES_SHIPMENT_GRID_TOTAL_QTY": true, + "SALES_SHIPMENT_GRID_ORDER_INCREMENT_ID": true, + "SALES_SHIPMENT_GRID_SHIPMENT_STATUS": true, + "SALES_SHIPMENT_GRID_ORDER_STATUS": true, + "SALES_SHIPMENT_GRID_CREATED_AT": true, + "SALES_SHIPMENT_GRID_UPDATED_AT": true, + "SALES_SHIPMENT_GRID_ORDER_CREATED_AT": true, + "SALES_SHIPMENT_GRID_SHIPPING_NAME": true, + "SALES_SHIPMENT_GRID_BILLING_NAME": true, + "FTI_086B40C8955F167B8EA76653437879B4": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPMENT_GRID_INCREMENT_ID_STORE_ID": true + } + }, + "sales_shipment_item": { + "column": { + "entity_id": true, + "parent_id": true, + "row_total": true, + "price": true, + "weight": true, + "qty": true, + "product_id": true, + "order_item_id": true, + "additional_data": true, + "description": true, + "name": true, + "sku": true + }, + "index": { + "SALES_SHIPMENT_ITEM_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPMENT_ITEM_PARENT_ID_SALES_SHIPMENT_ENTITY_ID": true + } + }, + "sales_shipment_track": { + "column": { + "entity_id": true, + "parent_id": true, + "weight": true, + "qty": true, + "order_id": true, + "track_number": true, + "description": true, + "title": true, + "carrier_code": true, + "created_at": true, + "updated_at": true + }, + "index": { + "SALES_SHIPMENT_TRACK_PARENT_ID": true, + "SALES_SHIPMENT_TRACK_ORDER_ID": true, + "SALES_SHIPMENT_TRACK_CREATED_AT": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPMENT_TRACK_PARENT_ID_SALES_SHIPMENT_ENTITY_ID": true + } + }, + "sales_shipment_comment": { + "column": { + "entity_id": true, + "parent_id": true, + "is_customer_notified": true, + "is_visible_on_front": true, + "comment": true, + "created_at": true + }, + "index": { + "SALES_SHIPMENT_COMMENT_CREATED_AT": true, + "SALES_SHIPMENT_COMMENT_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPMENT_COMMENT_PARENT_ID_SALES_SHIPMENT_ENTITY_ID": true + } + }, + "sales_invoice": { + "column": { + "entity_id": true, + "store_id": true, + "base_grand_total": true, + "shipping_tax_amount": true, + "tax_amount": true, + "base_tax_amount": true, + "store_to_order_rate": true, + "base_shipping_tax_amount": true, + "base_discount_amount": true, + "base_to_order_rate": true, + "grand_total": true, + "shipping_amount": true, + "subtotal_incl_tax": true, + "base_subtotal_incl_tax": true, + "store_to_base_rate": true, + "base_shipping_amount": true, + "total_qty": true, + "base_to_global_rate": true, + "subtotal": true, + "base_subtotal": true, + "discount_amount": true, + "billing_address_id": true, + "is_used_for_refund": true, + "order_id": true, + "email_sent": true, + "send_email": true, + "can_void_flag": true, + "state": true, + "shipping_address_id": true, + "store_currency_code": true, + "transaction_id": true, + "order_currency_code": true, + "base_currency_code": true, + "global_currency_code": true, + "increment_id": true, + "created_at": true, + "updated_at": true, + "discount_tax_compensation_amount": true, + "base_discount_tax_compensation_amount": true, + "shipping_discount_tax_compensation_amount": true, + "base_shipping_discount_tax_compensation_amnt": true, + "shipping_incl_tax": true, + "base_shipping_incl_tax": true, + "base_total_refunded": true, + "discount_description": true, + "customer_note": true, + "customer_note_notify": true + }, + "index": { + "SALES_INVOICE_STORE_ID": true, + "SALES_INVOICE_GRAND_TOTAL": true, + "SALES_INVOICE_ORDER_ID": true, + "SALES_INVOICE_STATE": true, + "SALES_INVOICE_CREATED_AT": true, + "SALES_INVOICE_UPDATED_AT": true, + "SALES_INVOICE_SEND_EMAIL": true, + "SALES_INVOICE_EMAIL_SENT": true + }, + "constraint": { + "PRIMARY": true, + "SALES_INVOICE_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "SALES_INVOICE_STORE_ID_STORE_STORE_ID": true, + "SALES_INVOICE_INCREMENT_ID_STORE_ID": true + } + }, + "sales_invoice_grid": { + "column": { + "entity_id": true, + "increment_id": true, + "state": true, + "store_id": true, + "store_name": true, + "order_id": true, + "order_increment_id": true, + "order_created_at": true, + "customer_name": true, + "customer_email": true, + "customer_group_id": true, + "payment_method": true, + "store_currency_code": true, + "order_currency_code": true, + "base_currency_code": true, + "global_currency_code": true, + "billing_name": true, + "billing_address": true, + "shipping_address": true, + "shipping_information": true, + "subtotal": true, + "shipping_and_handling": true, + "grand_total": true, + "created_at": true, + "updated_at": true, + "base_grand_total": true + }, + "index": { + "SALES_INVOICE_GRID_STORE_ID": true, + "SALES_INVOICE_GRID_GRAND_TOTAL": true, + "SALES_INVOICE_GRID_ORDER_ID": true, + "SALES_INVOICE_GRID_STATE": true, + "SALES_INVOICE_GRID_ORDER_INCREMENT_ID": true, + "SALES_INVOICE_GRID_CREATED_AT": true, + "SALES_INVOICE_GRID_UPDATED_AT": true, + "SALES_INVOICE_GRID_ORDER_CREATED_AT": true, + "SALES_INVOICE_GRID_BILLING_NAME": true, + "FTI_95D9C924DD6A8734EB8B5D01D60F90DE": true, + "SALES_INVOICE_GRID_BASE_GRAND_TOTAL": true + }, + "constraint": { + "PRIMARY": true, + "SALES_INVOICE_GRID_INCREMENT_ID_STORE_ID": true + } + }, + "sales_invoice_item": { + "column": { + "entity_id": true, + "parent_id": true, + "base_price": true, + "tax_amount": true, + "base_row_total": true, + "discount_amount": true, + "row_total": true, + "base_discount_amount": true, + "price_incl_tax": true, + "base_tax_amount": true, + "base_price_incl_tax": true, + "qty": true, + "base_cost": true, + "price": true, + "base_row_total_incl_tax": true, + "row_total_incl_tax": true, + "product_id": true, + "order_item_id": true, + "additional_data": true, + "description": true, + "sku": true, + "name": true, + "discount_tax_compensation_amount": true, + "base_discount_tax_compensation_amount": true, + "tax_ratio": true + }, + "index": { + "SALES_INVOICE_ITEM_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_INVOICE_ITEM_PARENT_ID_SALES_INVOICE_ENTITY_ID": true + } + }, + "sales_invoice_comment": { + "column": { + "entity_id": true, + "parent_id": true, + "is_customer_notified": true, + "is_visible_on_front": true, + "comment": true, + "created_at": true + }, + "index": { + "SALES_INVOICE_COMMENT_CREATED_AT": true, + "SALES_INVOICE_COMMENT_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_INVOICE_COMMENT_PARENT_ID_SALES_INVOICE_ENTITY_ID": true + } + }, + "sales_creditmemo": { + "column": { + "entity_id": true, + "store_id": true, + "adjustment_positive": true, + "base_shipping_tax_amount": true, + "store_to_order_rate": true, + "base_discount_amount": true, + "base_to_order_rate": true, + "grand_total": true, + "base_adjustment_negative": true, + "base_subtotal_incl_tax": true, + "shipping_amount": true, + "subtotal_incl_tax": true, + "adjustment_negative": true, + "base_shipping_amount": true, + "store_to_base_rate": true, + "base_to_global_rate": true, + "base_adjustment": true, + "base_subtotal": true, + "discount_amount": true, + "subtotal": true, + "adjustment": true, + "base_grand_total": true, + "base_adjustment_positive": true, + "base_tax_amount": true, + "shipping_tax_amount": true, + "tax_amount": true, + "order_id": true, + "email_sent": true, + "send_email": true, + "creditmemo_status": true, + "state": true, + "shipping_address_id": true, + "billing_address_id": true, + "invoice_id": true, + "store_currency_code": true, + "order_currency_code": true, + "base_currency_code": true, + "global_currency_code": true, + "transaction_id": true, + "increment_id": true, + "created_at": true, + "updated_at": true, + "discount_tax_compensation_amount": true, + "base_discount_tax_compensation_amount": true, + "shipping_discount_tax_compensation_amount": true, + "base_shipping_discount_tax_compensation_amnt": true, + "shipping_incl_tax": true, + "base_shipping_incl_tax": true, + "discount_description": true, + "customer_note": true, + "customer_note_notify": true + }, + "index": { + "SALES_CREDITMEMO_STORE_ID": true, + "SALES_CREDITMEMO_ORDER_ID": true, + "SALES_CREDITMEMO_CREDITMEMO_STATUS": true, + "SALES_CREDITMEMO_STATE": true, + "SALES_CREDITMEMO_CREATED_AT": true, + "SALES_CREDITMEMO_UPDATED_AT": true, + "SALES_CREDITMEMO_SEND_EMAIL": true, + "SALES_CREDITMEMO_EMAIL_SENT": true + }, + "constraint": { + "PRIMARY": true, + "SALES_CREDITMEMO_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "SALES_CREDITMEMO_STORE_ID_STORE_STORE_ID": true, + "SALES_CREDITMEMO_INCREMENT_ID_STORE_ID": true + } + }, + "sales_creditmemo_grid": { + "column": { + "entity_id": true, + "increment_id": true, + "created_at": true, + "updated_at": true, + "order_id": true, + "order_increment_id": true, + "order_created_at": true, + "billing_name": true, + "state": true, + "base_grand_total": true, + "order_status": true, + "store_id": true, + "billing_address": true, + "shipping_address": true, + "customer_name": true, + "customer_email": true, + "customer_group_id": true, + "payment_method": true, + "shipping_information": true, + "subtotal": true, + "shipping_and_handling": true, + "adjustment_positive": true, + "adjustment_negative": true, + "order_base_grand_total": true + }, + "index": { + "SALES_CREDITMEMO_GRID_ORDER_INCREMENT_ID": true, + "SALES_CREDITMEMO_GRID_CREATED_AT": true, + "SALES_CREDITMEMO_GRID_UPDATED_AT": true, + "SALES_CREDITMEMO_GRID_ORDER_CREATED_AT": true, + "SALES_CREDITMEMO_GRID_STATE": true, + "SALES_CREDITMEMO_GRID_BILLING_NAME": true, + "SALES_CREDITMEMO_GRID_ORDER_STATUS": true, + "SALES_CREDITMEMO_GRID_BASE_GRAND_TOTAL": true, + "SALES_CREDITMEMO_GRID_STORE_ID": true, + "SALES_CREDITMEMO_GRID_ORDER_BASE_GRAND_TOTAL": true, + "SALES_CREDITMEMO_GRID_ORDER_ID": true, + "FTI_32B7BA885941A8254EE84AE650ABDC86": true + }, + "constraint": { + "PRIMARY": true, + "SALES_CREDITMEMO_GRID_INCREMENT_ID_STORE_ID": true + } + }, + "sales_creditmemo_item": { + "column": { + "entity_id": true, + "parent_id": true, + "base_price": true, + "tax_amount": true, + "base_row_total": true, + "discount_amount": true, + "row_total": true, + "base_discount_amount": true, + "price_incl_tax": true, + "base_tax_amount": true, + "base_price_incl_tax": true, + "qty": true, + "base_cost": true, + "price": true, + "base_row_total_incl_tax": true, + "row_total_incl_tax": true, + "product_id": true, + "order_item_id": true, + "additional_data": true, + "description": true, + "sku": true, + "name": true, + "discount_tax_compensation_amount": true, + "base_discount_tax_compensation_amount": true, + "tax_ratio": true + }, + "index": { + "SALES_CREDITMEMO_ITEM_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_CREDITMEMO_ITEM_PARENT_ID_SALES_CREDITMEMO_ENTITY_ID": true + } + }, + "sales_creditmemo_comment": { + "column": { + "entity_id": true, + "parent_id": true, + "is_customer_notified": true, + "is_visible_on_front": true, + "comment": true, + "created_at": true + }, + "index": { + "SALES_CREDITMEMO_COMMENT_CREATED_AT": true, + "SALES_CREDITMEMO_COMMENT_PARENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_CREDITMEMO_COMMENT_PARENT_ID_SALES_CREDITMEMO_ENTITY_ID": true + } + }, + "sales_invoiced_aggregated": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "orders_count": true, + "orders_invoiced": true, + "invoiced": true, + "invoiced_captured": true, + "invoiced_not_captured": true + }, + "index": { + "SALES_INVOICED_AGGREGATED_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_INVOICED_AGGREGATED_STORE_ID_STORE_STORE_ID": true, + "SALES_INVOICED_AGGREGATED_PERIOD_STORE_ID_ORDER_STATUS": true + } + }, + "sales_invoiced_aggregated_order": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "orders_count": true, + "orders_invoiced": true, + "invoiced": true, + "invoiced_captured": true, + "invoiced_not_captured": true + }, + "index": { + "SALES_INVOICED_AGGREGATED_ORDER_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_INVOICED_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID": true, + "SALES_INVOICED_AGGREGATED_ORDER_PERIOD_STORE_ID_ORDER_STATUS": true + } + }, + "sales_order_aggregated_created": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "orders_count": true, + "total_qty_ordered": true, + "total_qty_invoiced": true, + "total_income_amount": true, + "total_revenue_amount": true, + "total_profit_amount": true, + "total_invoiced_amount": true, + "total_canceled_amount": true, + "total_paid_amount": true, + "total_refunded_amount": true, + "total_tax_amount": true, + "total_tax_amount_actual": true, + "total_shipping_amount": true, + "total_shipping_amount_actual": true, + "total_discount_amount": true, + "total_discount_amount_actual": true + }, + "index": { + "SALES_ORDER_AGGREGATED_CREATED_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_AGGREGATED_CREATED_STORE_ID_STORE_STORE_ID": true, + "SALES_ORDER_AGGREGATED_CREATED_PERIOD_STORE_ID_ORDER_STATUS": true + } + }, + "sales_order_aggregated_updated": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "orders_count": true, + "total_qty_ordered": true, + "total_qty_invoiced": true, + "total_income_amount": true, + "total_revenue_amount": true, + "total_profit_amount": true, + "total_invoiced_amount": true, + "total_canceled_amount": true, + "total_paid_amount": true, + "total_refunded_amount": true, + "total_tax_amount": true, + "total_tax_amount_actual": true, + "total_shipping_amount": true, + "total_shipping_amount_actual": true, + "total_discount_amount": true, + "total_discount_amount_actual": true + }, + "index": { + "SALES_ORDER_AGGREGATED_UPDATED_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID": true, + "SALES_ORDER_AGGREGATED_UPDATED_PERIOD_STORE_ID_ORDER_STATUS": true + } + }, + "sales_payment_transaction": { + "column": { + "transaction_id": true, + "parent_id": true, + "order_id": true, + "payment_id": true, + "txn_id": true, + "parent_txn_id": true, + "txn_type": true, + "is_closed": true, + "additional_information": true, + "created_at": true + }, + "index": { + "SALES_PAYMENT_TRANSACTION_PARENT_ID": true, + "SALES_PAYMENT_TRANSACTION_PAYMENT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_PAYMENT_TRANSACTION_ORDER_ID_SALES_ORDER_ENTITY_ID": true, + "FK_B99FF1A06402D725EBDB0F3A7ECD47A2": true, + "SALES_PAYMENT_TRANSACTION_PAYMENT_ID_SALES_ORDER_PAYMENT_ENTT_ID": true, + "SALES_PAYMENT_TRANSACTION_ORDER_ID_PAYMENT_ID_TXN_ID": true + } + }, + "sales_refunded_aggregated": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "orders_count": true, + "refunded": true, + "online_refunded": true, + "offline_refunded": true + }, + "index": { + "SALES_REFUNDED_AGGREGATED_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_REFUNDED_AGGREGATED_STORE_ID_STORE_STORE_ID": true, + "SALES_REFUNDED_AGGREGATED_PERIOD_STORE_ID_ORDER_STATUS": true + } + }, + "sales_refunded_aggregated_order": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "orders_count": true, + "refunded": true, + "online_refunded": true, + "offline_refunded": true + }, + "index": { + "SALES_REFUNDED_AGGREGATED_ORDER_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_REFUNDED_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID": true, + "SALES_REFUNDED_AGGREGATED_ORDER_PERIOD_STORE_ID_ORDER_STATUS": true + } + }, + "sales_shipping_aggregated": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "shipping_description": true, + "orders_count": true, + "total_shipping": true, + "total_shipping_actual": true + }, + "index": { + "SALES_SHIPPING_AGGREGATED_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPPING_AGGREGATED_STORE_ID_STORE_STORE_ID": true, + "SALES_SHPP_AGGRED_PERIOD_STORE_ID_ORDER_STS_SHPP_DESCRIPTION": true + } + }, + "sales_shipping_aggregated_order": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "shipping_description": true, + "orders_count": true, + "total_shipping": true, + "total_shipping_actual": true + }, + "index": { + "SALES_SHIPPING_AGGREGATED_ORDER_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SHIPPING_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID": true, + "UNQ_C05FAE47282EEA68654D0924E946761F": true + } + }, + "sales_bestsellers_aggregated_daily": { + "column": { + "id": true, + "period": true, + "store_id": true, + "product_id": true, + "product_name": true, + "product_price": true, + "qty_ordered": true, + "rating_pos": true + }, + "index": { + "SALES_BESTSELLERS_AGGREGATED_DAILY_STORE_ID": true, + "SALES_BESTSELLERS_AGGREGATED_DAILY_PRODUCT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_BESTSELLERS_AGGREGATED_DAILY_STORE_ID_STORE_STORE_ID": true, + "SALES_BESTSELLERS_AGGREGATED_DAILY_PERIOD_STORE_ID_PRODUCT_ID": true + } + }, + "sales_bestsellers_aggregated_monthly": { + "column": { + "id": true, + "period": true, + "store_id": true, + "product_id": true, + "product_name": true, + "product_price": true, + "qty_ordered": true, + "rating_pos": true + }, + "index": { + "SALES_BESTSELLERS_AGGREGATED_MONTHLY_STORE_ID": true, + "SALES_BESTSELLERS_AGGREGATED_MONTHLY_PRODUCT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_BESTSELLERS_AGGREGATED_MONTHLY_STORE_ID_STORE_STORE_ID": true, + "SALES_BESTSELLERS_AGGREGATED_MONTHLY_PERIOD_STORE_ID_PRODUCT_ID": true + } + }, + "sales_bestsellers_aggregated_yearly": { + "column": { + "id": true, + "period": true, + "store_id": true, + "product_id": true, + "product_name": true, + "product_price": true, + "qty_ordered": true, + "rating_pos": true + }, + "index": { + "SALES_BESTSELLERS_AGGREGATED_YEARLY_STORE_ID": true, + "SALES_BESTSELLERS_AGGREGATED_YEARLY_PRODUCT_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_BESTSELLERS_AGGREGATED_YEARLY_STORE_ID_STORE_STORE_ID": true, + "SALES_BESTSELLERS_AGGREGATED_YEARLY_PERIOD_STORE_ID_PRODUCT_ID": true + } + }, + "sales_order_tax": { + "column": { + "tax_id": true, + "order_id": true, + "code": true, + "title": true, + "percent": true, + "amount": true, + "priority": true, + "position": true, + "base_amount": true, + "process": true, + "base_real_amount": true + }, + "index": { + "SALES_ORDER_TAX_ORDER_ID_PRIORITY_POSITION": true + }, + "constraint": { + "PRIMARY": true + } + }, + "sales_order_tax_item": { + "column": { + "tax_item_id": true, + "tax_id": true, + "item_id": true, + "tax_percent": true, + "amount": true, + "base_amount": true, + "real_amount": true, + "real_base_amount": true, + "associated_item_id": true, + "taxable_item_type": true + }, + "index": { + "SALES_ORDER_TAX_ITEM_ITEM_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_TAX_ITEM_ASSOCIATED_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID": true, + "SALES_ORDER_TAX_ITEM_TAX_ID_SALES_ORDER_TAX_TAX_ID": true, + "SALES_ORDER_TAX_ITEM_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID": true, + "SALES_ORDER_TAX_ITEM_TAX_ID_ITEM_ID": true + } + }, + "sales_order_status": { + "column": { + "status": true, + "label": true + }, + "constraint": { + "PRIMARY": true + } + }, + "sales_order_status_state": { + "column": { + "status": true, + "state": true, + "is_default": true, + "visible_on_front": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_STATUS_STATE_STATUS_SALES_ORDER_STATUS_STATUS": true + } + }, + "sales_order_status_label": { + "column": { + "status": true, + "store_id": true, + "label": true + }, + "index": { + "SALES_ORDER_STATUS_LABEL_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALES_ORDER_STATUS_LABEL_STATUS_SALES_ORDER_STATUS_STATUS": true, + "SALES_ORDER_STATUS_LABEL_STORE_ID_STORE_STORE_ID": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml index 2ca2420934519..2dbf717f73439 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/sidebar/items.phtml @@ -67,11 +67,7 @@ canDisplayPrice()): ?> - getDataId() == 'cart'): ?> - getItemPrice($_item->getProduct()) ?> - - getItemPrice($_item) ?> - + getItemPrice($block->getProduct($_item)) ?> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/view/history.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/view/history.phtml index 1ec51ffb793c6..6ac6e13a873ed 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/view/history.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/view/history.phtml @@ -5,7 +5,7 @@ */ // @codingStandardsIgnoreFile - +/** @var \Magento\Sales\Block\Adminhtml\Order\View\History $block */ ?>
    canAddComment()):?> diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml index ecc2b5beee321..10b7b1c028c66 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml @@ -35,7 +35,13 @@ - + + + + * + + + diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml index 3ec450a570b46..ac1233c5e4961 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml @@ -35,7 +35,13 @@ - + + + + * + + + diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml index 27cef50742163..6db77a79b8c14 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml @@ -35,7 +35,13 @@ - + + + + * + + + diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js index 629b7ac93ecee..8990ea8d3f75b 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js @@ -55,7 +55,8 @@ define([ } }); - var searchButton = new ControlButton(jQuery.mage.__('Add Products')), + var searchButtonId = 'add_products', + searchButton = new ControlButton(jQuery.mage.__('Add Products'), searchButtonId), searchAreaId = this.getAreaId('search'); searchButton.onClick = function() { $(searchAreaId).show(); @@ -74,7 +75,7 @@ define([ this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) { proceed(); - if ($(searchAreaId) && !$(searchAreaId).visible()) { + if ($(searchAreaId) && !$(searchAreaId).visible() && !$(searchButtonId)) { this.addControlButton(searchButton); } }); @@ -157,6 +158,7 @@ define([ } if(this.addresses[id]){ this.fillAddressFields(container, this.addresses[id]); + } else{ this.fillAddressFields(container, {}); @@ -190,43 +192,53 @@ define([ } }, - changeAddressField : function(event){ - var field = Event.element(event); - var re = /[^\[]*\[([^\]]*)_address\]\[([^\]]*)\](\[(\d)\])?/; - var matchRes = field.name.match(re); + /** + * Triggers on each form's element changes. + * + * @param {Object} event + */ + changeAddressField: function (event) { + var field = Event.element(event), + re = /[^\[]*\[([^\]]*)_address\]\[([^\]]*)\](\[(\d)\])?/, + matchRes = field.name.match(re), + type, + name, + data; if (!matchRes) { return; } - var type = matchRes[1]; - var name = matchRes[2]; - var data; + type = matchRes[1]; + name = matchRes[2]; - if(this.isBillingField(field.id)){ - data = this.serializeData(this.billingAddressContainer) - } - else{ - data = this.serializeData(this.shippingAddressContainer) + if (this.isBillingField(field.id)) { + data = this.serializeData(this.billingAddressContainer); + } else { + data = this.serializeData(this.shippingAddressContainer); } data = data.toObject(); - if( (type == 'billing' && this.shippingAsBilling) - || (type == 'shipping' && !this.shippingAsBilling) ) { + if (type === 'billing' && this.shippingAsBilling || type === 'shipping' && !this.shippingAsBilling) { data['reset_shipping'] = true; } - data['order['+type+'_address][customer_address_id]'] = $('order-'+type+'_address_customer_address_id').value; + data['order[' + type + '_address][customer_address_id]'] = null; + data['shipping_as_billing'] = jQuery('[name="shipping_same_as_billing"]').is(':checked') ? 1 : 0; + + if (name === 'customer_address_id') { + data['order[' + type + '_address][customer_address_id]'] = + $('order-' + type + '_address_customer_address_id').value; + } if (data['reset_shipping']) { this.resetShippingMethod(data); } else { this.saveData(data); - if (name == 'country_id' || name == 'customer_address_id') { + + if (name === 'country_id' || name === 'customer_address_id') { this.loadArea(['shipping_method', 'billing_method', 'totals', 'items'], true, data); } - // added for reloading of default sender and default recipient for giftmessages - //this.loadArea(['giftmessage'], true, data); } }, @@ -1383,12 +1395,15 @@ define([ _label: '', _node: null, - initialize: function(label){ + initialize: function(label, id){ this._label = label; this._node = new Element('button', { 'class': 'action-secondary action-add', 'type': 'button' }); + if (typeof id !== 'undefined') { + this._node.setAttribute('id', id) + } }, onClick: function(){ diff --git a/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml b/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml index 20c2c1869fedb..1fca65932b0b0 100644 --- a/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/email/items/invoice/default.phtml @@ -31,6 +31,6 @@ getQty() * 1 ?> - getItemPrice($_item) ?> + getItemPrice($_item->getOrderItem()) ?> diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php index 108cc341253ae..1e8fbf43ec3bc 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php @@ -136,6 +136,7 @@ public function asHtml() * * @param \Magento\Framework\Model\AbstractModel $model * @return bool + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function validate(\Magento\Framework\Model\AbstractModel $model) { @@ -145,8 +146,22 @@ public function validate(\Magento\Framework\Model\AbstractModel $model) $attr = $this->getAttribute(); $total = 0; foreach ($model->getQuote()->getAllVisibleItems() as $item) { - if (parent::validate($item)) { - $total += $item->getData($attr); + $hasValidChild = false; + $useChildrenTotal = ($item->getProductType() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE); + $childrenAttrTotal = 0; + $children = $item->getChildren(); + if (!empty($children)) { + foreach ($children as $child) { + if (parent::validate($child)) { + $hasValidChild = true; + if ($useChildrenTotal) { + $childrenAttrTotal += $child->getData($attr); + } + } + } + } + if ($hasValidChild || parent::validate($item)) { + $total += (($hasValidChild && $useChildrenTotal) ? $childrenAttrTotal : $item->getData($attr)); } } return $this->validateAttribute($total); diff --git a/app/code/Magento/SalesRule/Setup/InstallSchema.php b/app/code/Magento/SalesRule/Setup/InstallSchema.php deleted file mode 100644 index e49933c211d20..0000000000000 --- a/app/code/Magento/SalesRule/Setup/InstallSchema.php +++ /dev/null @@ -1,794 +0,0 @@ -startSetup(); - $customerGroupTable = $setup->getConnection()->describeTable($setup->getTable('customer_group')); - $customerGroupIdType = $customerGroupTable['customer_group_id']['DATA_TYPE'] == 'int' - ? \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER : $customerGroupTable['customer_group_id']['DATA_TYPE']; - /** - * Create table 'salesrule' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule') - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Rule Id' - )->addColumn( - 'name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Name' - )->addColumn( - 'description', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Description' - )->addColumn( - 'from_date', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - ['nullable' => true, 'default' => null], - 'From' - )->addColumn( - 'to_date', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - ['nullable' => true, 'default' => null], - 'To' - )->addColumn( - 'uses_per_customer', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Uses Per Customer' - )->addColumn( - 'is_active', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['nullable' => false, 'default' => '0'], - 'Is Active' - )->addColumn( - 'conditions_serialized', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '2M', - [], - 'Conditions Serialized' - )->addColumn( - 'actions_serialized', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '2M', - [], - 'Actions Serialized' - )->addColumn( - 'stop_rules_processing', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['nullable' => false, 'default' => '1'], - 'Stop Rules Processing' - )->addColumn( - 'is_advanced', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '1'], - 'Is Advanced' - )->addColumn( - 'product_ids', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Product Ids' - )->addColumn( - 'sort_order', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Sort Order' - )->addColumn( - 'simple_action', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - [], - 'Simple Action' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Discount Amount' - )->addColumn( - 'discount_qty', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - [], - 'Discount Qty' - )->addColumn( - 'discount_step', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Discount Step' - )->addColumn( - 'apply_to_shipping', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Apply To Shipping' - )->addColumn( - 'times_used', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Times Used' - )->addColumn( - 'is_rss', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['nullable' => false, 'default' => '0'], - 'Is Rss' - )->addColumn( - 'coupon_type', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '1'], - 'Coupon Type' - )->addColumn( - 'use_auto_generation', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => false, 'nullable' => false, 'default' => 0], - 'Use Auto Generation' - )->addColumn( - 'uses_per_coupon', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => 0], - 'User Per Coupon' - )->addIndex( - $installer->getIdxName('salesrule', ['is_active', 'sort_order', 'to_date', 'from_date']), - ['is_active', 'sort_order', 'to_date', 'from_date'] - )->setComment( - 'Salesrule' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_coupon' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_coupon') - )->addColumn( - 'coupon_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Coupon Id' - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Rule Id' - )->addColumn( - 'code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Code' - )->addColumn( - 'usage_limit', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Usage Limit' - )->addColumn( - 'usage_per_customer', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true], - 'Usage Per Customer' - )->addColumn( - 'times_used', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Times Used' - )->addColumn( - 'expiration_date', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - [], - 'Expiration Date' - )->addColumn( - 'is_primary', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Is Primary' - )->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => true], - 'Coupon Code Creation Date' - )->addColumn( - 'type', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['nullable' => true, 'default' => 0], - 'Coupon Code Type' - )->addIndex( - $installer->getIdxName( - 'salesrule_coupon', - ['code'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['code'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName( - 'salesrule_coupon', - ['rule_id', 'is_primary'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['rule_id', 'is_primary'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('salesrule_coupon', ['rule_id']), - ['rule_id'] - )->addForeignKey( - $installer->getFkName('salesrule_coupon', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $installer->getTable('salesrule'), - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Salesrule Coupon' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_coupon_usage' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_coupon_usage') - )->addColumn( - 'coupon_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Coupon Id' - )->addColumn( - 'customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Customer Id' - )->addColumn( - 'times_used', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Times Used' - )->addIndex( - $installer->getIdxName('salesrule_coupon_usage', ['customer_id']), - ['customer_id'] - )->addForeignKey( - $installer->getFkName('salesrule_coupon_usage', 'coupon_id', 'salesrule_coupon', 'coupon_id'), - 'coupon_id', - $installer->getTable('salesrule_coupon'), - 'coupon_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('salesrule_coupon_usage', 'customer_id', 'customer_entity', 'entity_id'), - 'customer_id', - $installer->getTable('customer_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Salesrule Coupon Usage' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_customer' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_customer') - )->addColumn( - 'rule_customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Rule Customer Id' - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Rule Id' - )->addColumn( - 'customer_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Customer Id' - )->addColumn( - 'times_used', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Times Used' - )->addIndex( - $installer->getIdxName('salesrule_customer', ['rule_id', 'customer_id']), - ['rule_id', 'customer_id'] - )->addIndex( - $installer->getIdxName('salesrule_customer', ['customer_id', 'rule_id']), - ['customer_id', 'rule_id'] - )->addForeignKey( - $installer->getFkName('salesrule_customer', 'customer_id', 'customer_entity', 'entity_id'), - 'customer_id', - $installer->getTable('customer_entity'), - 'entity_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('salesrule_customer', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $installer->getTable('salesrule'), - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Salesrule Customer' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_label' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_label') - )->addColumn( - 'label_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Label Id' - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false], - 'Rule Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false], - 'Store Id' - )->addColumn( - 'label', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Label' - )->addIndex( - $installer->getIdxName( - 'salesrule_label', - ['rule_id', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['rule_id', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('salesrule_label', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('salesrule_label', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $installer->getTable('salesrule'), - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('salesrule_label', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Salesrule Label' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_product_attribute' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_product_attribute') - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Rule Id' - )->addColumn( - 'website_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Website Id' - )->addColumn( - 'customer_group_id', - $customerGroupIdType, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Customer Group Id' - )->addColumn( - 'attribute_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Attribute Id' - )->addIndex( - $installer->getIdxName('salesrule_product_attribute', ['website_id']), - ['website_id'] - )->addIndex( - $installer->getIdxName('salesrule_product_attribute', ['customer_group_id']), - ['customer_group_id'] - )->addIndex( - $installer->getIdxName('salesrule_product_attribute', ['attribute_id']), - ['attribute_id'] - )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'attribute_id', 'eav_attribute', 'attribute_id'), - 'attribute_id', - $installer->getTable('eav_attribute'), - 'attribute_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName( - 'salesrule_product_attribute', - 'customer_group_id', - 'customer_group', - 'customer_group_id' - ), - 'customer_group_id', - $installer->getTable('customer_group'), - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $installer->getTable('salesrule'), - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('salesrule_product_attribute', 'website_id', 'store_website', 'website_id'), - 'website_id', - $installer->getTable('store_website'), - 'website_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Salesrule Product Attribute' - ); - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_coupon_aggregated' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_coupon_aggregated') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - ['nullable' => false], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Status' - )->addColumn( - 'coupon_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Coupon Code' - )->addColumn( - 'coupon_uses', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Coupon Uses' - )->addColumn( - 'subtotal_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Subtotal Amount' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Discount Amount' - )->addColumn( - 'total_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Total Amount' - )->addColumn( - 'subtotal_amount_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Subtotal Amount Actual' - )->addColumn( - 'discount_amount_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Discount Amount Actual' - )->addColumn( - 'total_amount_actual', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Total Amount Actual' - )->addColumn( - 'rule_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Rule Name' - )->addIndex( - $installer->getIdxName( - 'salesrule_coupon_aggregated', - ['period', 'store_id', 'order_status', 'coupon_code'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status', 'coupon_code'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('salesrule_coupon_aggregated', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('salesrule_coupon_aggregated', ['rule_name']), - ['rule_name'] - )->addForeignKey( - $installer->getFkName('salesrule_coupon_aggregated', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Coupon Aggregated' - ); - $installer->getConnection()->createTable($table); - - $installer->getConnection()->createTable( - $installer->getConnection()->createTableByDdl( - $installer->getTable('salesrule_coupon_aggregated'), - $installer->getTable('salesrule_coupon_aggregated_updated') - ) - ); - - /** - * Create table 'salesrule_coupon_aggregated_order' - */ - $table = $installer->getConnection()->newTable( - $installer->getTable('salesrule_coupon_aggregated_order') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'period', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - ['nullable' => false], - 'Period' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true], - 'Store Id' - )->addColumn( - 'order_status', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Order Status' - )->addColumn( - 'coupon_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 50, - [], - 'Coupon Code' - )->addColumn( - 'coupon_uses', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'default' => '0'], - 'Coupon Uses' - )->addColumn( - 'subtotal_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Subtotal Amount' - )->addColumn( - 'discount_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Discount Amount' - )->addColumn( - 'total_amount', - \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL, - [12, 4], - ['nullable' => false, 'default' => '0.0000'], - 'Total Amount' - )->addColumn( - 'rule_name', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Rule Name' - )->addIndex( - $installer->getIdxName( - 'salesrule_coupon_aggregated_order', - ['period', 'store_id', 'order_status', 'coupon_code'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['period', 'store_id', 'order_status', 'coupon_code'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addIndex( - $installer->getIdxName('salesrule_coupon_aggregated_order', ['store_id']), - ['store_id'] - )->addIndex( - $installer->getIdxName('salesrule_coupon_aggregated_order', ['rule_name']), - ['rule_name'] - )->addForeignKey( - $installer->getFkName('salesrule_coupon_aggregated_order', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Coupon Aggregated Order' - ); - $installer->getConnection()->createTable($table); - - $websitesTable = $installer->getTable('store_website'); - $customerGroupsTable = $installer->getTable('customer_group'); - $rulesWebsitesTable = $installer->getTable('salesrule_website'); - $rulesCustomerGroupsTable = $installer->getTable('salesrule_customer_group'); - - /** - * Create table 'salesrule_website' if not exists. This table will be used instead of - * column website_ids of main catalog rules table - */ - $table = $installer->getConnection()->newTable( - $rulesWebsitesTable - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Rule Id' - )->addColumn( - 'website_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Website Id' - )->addIndex( - $installer->getIdxName('salesrule_website', ['website_id']), - ['website_id'] - )->addForeignKey( - $installer->getFkName('salesrule_website', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $installer->getTable('salesrule'), - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName('salesrule_website', 'website_id', 'store_website', 'website_id'), - 'website_id', - $websitesTable, - 'website_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Rules To Websites Relations' - ); - - $installer->getConnection()->createTable($table); - - /** - * Create table 'salesrule_customer_group' if not exists. This table will be used instead of - * column customer_group_ids of main catalog rules table - */ - $table = $installer->getConnection()->newTable( - $rulesCustomerGroupsTable - )->addColumn( - 'rule_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Rule Id' - )->addColumn( - 'customer_group_id', - $customerGroupIdType, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => true], - 'Customer Group Id' - )->addIndex( - $installer->getIdxName('salesrule_customer_group', ['customer_group_id']), - ['customer_group_id'] - )->addForeignKey( - $installer->getFkName('salesrule_customer_group', 'rule_id', 'salesrule', 'rule_id'), - 'rule_id', - $installer->getTable('salesrule'), - 'rule_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->addForeignKey( - $installer->getFkName( - 'salesrule_customer_group', - 'customer_group_id', - 'customer_group', - 'customer_group_id' - ), - 'customer_group_id', - $customerGroupsTable, - 'customer_group_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Sales Rules To Customer Groups Relations' - ); - - $installer->getConnection()->createTable($table); - - $installer->endSetup(); - } -} diff --git a/app/code/Magento/SalesRule/Setup/UpgradeSchema.php b/app/code/Magento/SalesRule/Setup/UpgradeSchema.php deleted file mode 100644 index c39536d121064..0000000000000 --- a/app/code/Magento/SalesRule/Setup/UpgradeSchema.php +++ /dev/null @@ -1,53 +0,0 @@ -startSetup(); - - if (version_compare($context->getVersion(), '2.0.1', '<')) { - $this->addDefaultValueForDiscountStep($setup); - } - - $setup->endSetup(); - } - - /** - * Add default value of 0 for the discount step column - * @param SchemaSetupInterface $setup - * @return void - */ - private function addDefaultValueForDiscountStep(SchemaSetupInterface $setup) - { - $connection = $setup->getConnection(); - $connection->modifyColumn( - $setup->getTable('salesrule'), - 'discount_step', - [ - 'type' => Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Discount Step', - ] - ); - } -} diff --git a/app/code/Magento/SalesRule/etc/db_schema.xml b/app/code/Magento/SalesRule/etc/db_schema.xml new file mode 100644 index 0000000000000..ed205d88d9a2d --- /dev/null +++ b/app/code/Magento/SalesRule/etc/db_schema.xml @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    +
    diff --git a/app/code/Magento/SalesRule/etc/db_schema_whitelist.json b/app/code/Magento/SalesRule/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..e72a0c687331a --- /dev/null +++ b/app/code/Magento/SalesRule/etc/db_schema_whitelist.json @@ -0,0 +1,230 @@ +{ + "salesrule": { + "column": { + "rule_id": true, + "name": true, + "description": true, + "from_date": true, + "to_date": true, + "uses_per_customer": true, + "is_active": true, + "conditions_serialized": true, + "actions_serialized": true, + "stop_rules_processing": true, + "is_advanced": true, + "product_ids": true, + "sort_order": true, + "simple_action": true, + "discount_amount": true, + "discount_qty": true, + "discount_step": true, + "apply_to_shipping": true, + "times_used": true, + "is_rss": true, + "coupon_type": true, + "use_auto_generation": true, + "uses_per_coupon": true + }, + "index": { + "SALESRULE_IS_ACTIVE_SORT_ORDER_TO_DATE_FROM_DATE": true + }, + "constraint": { + "PRIMARY": true + } + }, + "salesrule_coupon": { + "column": { + "coupon_id": true, + "rule_id": true, + "code": true, + "usage_limit": true, + "usage_per_customer": true, + "times_used": true, + "expiration_date": true, + "is_primary": true, + "created_at": true, + "type": true + }, + "index": { + "SALESRULE_COUPON_RULE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_COUPON_RULE_ID_SALESRULE_RULE_ID": true, + "SALESRULE_COUPON_CODE": true, + "SALESRULE_COUPON_RULE_ID_IS_PRIMARY": true + } + }, + "salesrule_coupon_usage": { + "column": { + "coupon_id": true, + "customer_id": true, + "times_used": true + }, + "index": { + "SALESRULE_COUPON_USAGE_CUSTOMER_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_COUPON_USAGE_COUPON_ID_SALESRULE_COUPON_COUPON_ID": true, + "SALESRULE_COUPON_USAGE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID": true + } + }, + "salesrule_customer": { + "column": { + "rule_customer_id": true, + "rule_id": true, + "customer_id": true, + "times_used": true + }, + "index": { + "SALESRULE_CUSTOMER_RULE_ID_CUSTOMER_ID": true, + "SALESRULE_CUSTOMER_CUSTOMER_ID_RULE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_CUSTOMER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID": true, + "SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID": true + } + }, + "salesrule_label": { + "column": { + "label_id": true, + "rule_id": true, + "store_id": true, + "label": true + }, + "index": { + "SALESRULE_LABEL_STORE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_LABEL_RULE_ID_SALESRULE_RULE_ID": true, + "SALESRULE_LABEL_STORE_ID_STORE_STORE_ID": true, + "SALESRULE_LABEL_RULE_ID_STORE_ID": true + } + }, + "salesrule_product_attribute": { + "column": { + "rule_id": true, + "website_id": true, + "customer_group_id": true, + "attribute_id": true + }, + "index": { + "SALESRULE_PRODUCT_ATTRIBUTE_WEBSITE_ID": true, + "SALESRULE_PRODUCT_ATTRIBUTE_CUSTOMER_GROUP_ID": true, + "SALESRULE_PRODUCT_ATTRIBUTE_ATTRIBUTE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_PRD_ATTR_ATTR_ID_EAV_ATTR_ATTR_ID": true, + "SALESRULE_PRD_ATTR_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID": true, + "SALESRULE_PRODUCT_ATTRIBUTE_RULE_ID_SALESRULE_RULE_ID": true, + "SALESRULE_PRODUCT_ATTRIBUTE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID": true + } + }, + "salesrule_coupon_aggregated": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "coupon_code": true, + "coupon_uses": true, + "subtotal_amount": true, + "discount_amount": true, + "total_amount": true, + "subtotal_amount_actual": true, + "discount_amount_actual": true, + "total_amount_actual": true, + "rule_name": true + }, + "index": { + "SALESRULE_COUPON_AGGREGATED_STORE_ID": true, + "SALESRULE_COUPON_AGGREGATED_RULE_NAME": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_COUPON_AGGREGATED_STORE_ID_STORE_STORE_ID": true, + "SALESRULE_COUPON_AGGRED_PERIOD_STORE_ID_ORDER_STS_COUPON_CODE": true + } + }, + "salesrule_coupon_aggregated_updated": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "coupon_code": true, + "coupon_uses": true, + "subtotal_amount": true, + "discount_amount": true, + "total_amount": true, + "subtotal_amount_actual": true, + "discount_amount_actual": true, + "total_amount_actual": true, + "rule_name": true + }, + "index": { + "SALESRULE_COUPON_AGGREGATED_UPDATED_STORE_ID": true, + "SALESRULE_COUPON_AGGREGATED_UPDATED_RULE_NAME": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_COUPON_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID": true, + "UNQ_7196FA120A4F0F84E1B66605E87E213E": true + } + }, + "salesrule_coupon_aggregated_order": { + "column": { + "id": true, + "period": true, + "store_id": true, + "order_status": true, + "coupon_code": true, + "coupon_uses": true, + "subtotal_amount": true, + "discount_amount": true, + "total_amount": true, + "rule_name": true + }, + "index": { + "SALESRULE_COUPON_AGGREGATED_ORDER_STORE_ID": true, + "SALESRULE_COUPON_AGGREGATED_ORDER_RULE_NAME": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_COUPON_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID": true, + "UNQ_1094D1FBBCBB11704A29DEF3ACC37D2B": true + } + }, + "salesrule_website": { + "column": { + "rule_id": true, + "website_id": true + }, + "index": { + "SALESRULE_WEBSITE_WEBSITE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_WEBSITE_RULE_ID_SALESRULE_RULE_ID": true, + "SALESRULE_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID": true + } + }, + "salesrule_customer_group": { + "column": { + "rule_id": true, + "customer_group_id": true + }, + "index": { + "SALESRULE_CUSTOMER_GROUP_CUSTOMER_GROUP_ID": true + }, + "constraint": { + "PRIMARY": true, + "SALESRULE_CUSTOMER_GROUP_RULE_ID_SALESRULE_RULE_ID": true, + "SALESRULE_CSTR_GROUP_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/SalesRule/view/frontend/web/template/payment/discount.html b/app/code/Magento/SalesRule/view/frontend/web/template/payment/discount.html index 7246460382fa7..d622b5ea5762d 100644 --- a/app/code/Magento/SalesRule/view/frontend/web/template/payment/discount.html +++ b/app/code/Magento/SalesRule/view/frontend/web/template/payment/discount.html @@ -27,7 +27,7 @@ id="discount-code" name="discount_code" data-validate="{'required-entry':true}" - data-bind="value: couponCode, attr:{placeholder: $t('Enter discount code')} " /> + data-bind="value: couponCode, attr:{disabled:isApplied() , placeholder: $t('Enter discount code')} " />
    diff --git a/app/code/Magento/SalesSequence/Setup/InstallSchema.php b/app/code/Magento/SalesSequence/Setup/InstallSchema.php deleted file mode 100644 index a73d892b5ea2a..0000000000000 --- a/app/code/Magento/SalesSequence/Setup/InstallSchema.php +++ /dev/null @@ -1,156 +0,0 @@ -startSetup(); - /** - * Create table 'sales_sequence_profile' - */ - $table = $installer->getConnection(self::$connectionName)->newTable( - $installer->getTable('sales_sequence_profile', self::$connectionName) - )->addColumn( - 'profile_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'meta_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false] - )->addColumn( - 'prefix', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => true, 'primary' => false], - 'Prefix' - )->addColumn( - 'suffix', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => true, 'primary' => false], - 'Suffix' - )->addColumn( - 'start_value', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'unsigned' => true, 'primary' => false, 'default' => 1], - 'Start value for sequence' - )->addColumn( - 'step', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'unsigned' => true, 'primary' => false, 'default' => 1], - 'Step for sequence' - )->addColumn( - 'max_value', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'unsigned' => true, 'primary' => false], - 'MaxValue for sequence' - )->addColumn( - 'warning_value', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['nullable' => false, 'unsigned' => true, 'primary' => false], - 'WarningValue for sequence' - )->addColumn( - 'is_active', - \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN, - null, - ['nullable' => false, 'default' => 0], - 'isActive flag' - )->addIndex( - $installer->getIdxName( - 'sales_sequence_profile', - ['meta_id', 'prefix', 'suffix'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE, - '', - self::$connectionName - ), - ['meta_id', 'prefix', 'suffix'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - )->addForeignKey( - $installer->getFkName( - 'sales_sequence_profile', - 'meta_id', - 'sales_sequence_meta', - 'meta_id', - self::$connectionName - ), - 'meta_id', - $installer->getTable('sales_sequence_meta', self::$connectionName), - 'meta_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - ); - $installer->getConnection(self::$connectionName)->createTable($table); - - /** - * Create table 'sales_sequence_meta' - */ - $table = $installer->getConnection(self::$connectionName)->newTable( - $installer->getTable('sales_sequence_meta', self::$connectionName) - )->addColumn( - 'meta_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Id' - )->addColumn( - 'entity_type', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false, 'primary' => false], - 'Prefix' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'primary' => false], - 'Store Id' - )->addColumn( - 'sequence_table', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 32, - ['nullable' => false], - 'table for sequence' - )->addIndex( - $installer->getIdxName( - 'sales_sequence_meta', - ['entity_type', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE, - '', - self::$connectionName - ), - ['entity_type', 'store_id'], - ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE] - ); - $installer->getConnection(self::$connectionName)->createTable($table); - $installer->endSetup(); - } -} diff --git a/app/code/Magento/SalesSequence/etc/db_schema.xml b/app/code/Magento/SalesSequence/etc/db_schema.xml new file mode 100644 index 0000000000000..1f63c1c93a18a --- /dev/null +++ b/app/code/Magento/SalesSequence/etc/db_schema.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + +
    +
    diff --git a/app/code/Magento/SalesSequence/etc/db_schema_whitelist.json b/app/code/Magento/SalesSequence/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..37a5d715ab024 --- /dev/null +++ b/app/code/Magento/SalesSequence/etc/db_schema_whitelist.json @@ -0,0 +1,32 @@ +{ + "sales_sequence_profile": { + "column": { + "profile_id": true, + "meta_id": true, + "prefix": true, + "suffix": true, + "start_value": true, + "step": true, + "max_value": true, + "warning_value": true, + "is_active": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SEQUENCE_PROFILE_META_ID_SALES_SEQUENCE_META_META_ID": true, + "SALES_SEQUENCE_PROFILE_META_ID_PREFIX_SUFFIX": true + } + }, + "sales_sequence_meta": { + "column": { + "meta_id": true, + "entity_type": true, + "store_id": true, + "sequence_table": true + }, + "constraint": { + "PRIMARY": true, + "SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Search/Helper/Data.php b/app/code/Magento/Search/Helper/Data.php index f3ad8a39de00e..e813d7342761f 100644 --- a/app/code/Magento/Search/Helper/Data.php +++ b/app/code/Magento/Search/Helper/Data.php @@ -124,7 +124,7 @@ public function getSuggestUrl() { return $this->_getUrl( 'search/ajax/suggest', - ['_secure' => $this->storeManager->getStore()->isCurrentlySecure()] + ['_secure' => $this->_getRequest()->isSecure()] ); } diff --git a/app/code/Magento/Search/Setup/InstallSchema.php b/app/code/Magento/Search/Setup/InstallSchema.php deleted file mode 100644 index 5aba160381d0a..0000000000000 --- a/app/code/Magento/Search/Setup/InstallSchema.php +++ /dev/null @@ -1,138 +0,0 @@ -startSetup(); - - /** - * Create table 'search_query' - */ - $table = $installer->getConnection() - ->newTable($installer->getTable('search_query')) - ->addColumn( - 'query_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Query ID' - ) - ->addColumn( - 'query_text', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Query text' - ) - ->addColumn( - 'num_results', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Num results' - ) - ->addColumn( - 'popularity', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Popularity' - ) - ->addColumn( - 'redirect', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Redirect' - ) - ->addColumn( - 'synonym_for', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Synonym for' - ) - ->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Store ID' - ) - ->addColumn( - 'display_in_terms', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['nullable' => false, 'default' => '1'], - 'Display in terms' - ) - ->addColumn( - 'is_active', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['default' => '1'], - 'Active status' - ) - ->addColumn( - 'is_processed', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['default' => '0'], - 'Processed status' - ) - ->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated at' - ) - ->addIndex( - $installer->getIdxName('search_query', ['query_text', 'store_id', 'popularity']), - ['query_text', 'store_id', 'popularity'] - ) - ->addIndex( - $installer->getIdxName('search_query', 'store_id'), - 'store_id' - ) - ->addIndex( - $installer->getIdxName('search_query', 'is_processed'), - 'is_processed' - ) - ->addIndex( - $installer->getIdxName('search_query', 'synonym_for'), - 'synonym_for' - ) - ->addForeignKey( - $installer->getFkName('search_query', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - ) - ->setComment('Search query table'); - $installer->getConnection()->createTable($table); - - $installer->endSetup(); - } -} diff --git a/app/code/Magento/Search/Setup/UpgradeSchema.php b/app/code/Magento/Search/Setup/UpgradeSchema.php deleted file mode 100644 index ba725d968ca33..0000000000000 --- a/app/code/Magento/Search/Setup/UpgradeSchema.php +++ /dev/null @@ -1,176 +0,0 @@ -getConnection(); - if (version_compare($context->getVersion(), '2.0.1') < 0) { - $connection->dropIndex( - $setup->getTable('search_query'), - $installer->getIdxName('search_query', ['query_text', 'store_id']) - ); - $connection->addIndex( - $setup->getTable('search_query'), - $installer->getIdxName( - 'search_query', - ['query_text', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - ['query_text', 'store_id'], - \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ); - } - - if (version_compare($context->getVersion(), '2.0.2') < 0) { - /** - * Create table 'search_synonyms' - */ - $table = $connection - ->newTable($installer->getTable('search_synonyms')) - ->addColumn( - 'group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Synonyms Group Id' - ) - ->addColumn( - 'synonyms', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 65535, - ['nullable' => false], - 'list of synonyms making up this group' - ) - ->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Store Id - identifies the store view these synonyms belong to' - ) - ->addIndex( - $setup->getIdxName( - $installer->getTable('search_synonyms'), - ['synonyms'], - AdapterInterface::INDEX_TYPE_FULLTEXT - ), - ['synonyms'], - ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT] - ) - ->addIndex( - $installer->getIdxName('search_synonyms', 'store_id'), - ['store_id'], - ['type' => AdapterInterface::INDEX_TYPE_INDEX] - ) - ->addForeignKey( - $installer->getFkName('search_synonyms', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - ) - ->setComment('table storing various synonyms groups per store view'); - - $connection->createTable($table); - } - - if (version_compare($context->getVersion(), '2.0.3') < 0) { - // Drop and recreate 'search_synonyms' table - $connection->dropTable($installer->getTable('search_synonyms')); - - $table = $connection - ->newTable($installer->getTable('search_synonyms')) - ->addColumn( - 'group_id', - \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Synonyms Group Id' - ) - ->addColumn( - 'synonyms', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 65535, - ['nullable' => false], - 'list of synonyms making up this group' - ) - ->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Store Id - identifies the store view these synonyms belong to' - ) - ->addColumn( - 'website_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Website Id - identifies the website id these synonyms belong to' - ) - ->addIndex( - $setup->getIdxName( - $installer->getTable('search_synonyms'), - ['synonyms'], - AdapterInterface::INDEX_TYPE_FULLTEXT - ), - ['synonyms'], - ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT] - ) - ->addIndex( - $installer->getIdxName('search_synonyms', 'store_id'), - ['store_id'], - ['type' => AdapterInterface::INDEX_TYPE_INDEX] - ) - ->addIndex( - $installer->getIdxName('search_synonyms', 'website_id'), - ['website_id'], - ['type' => AdapterInterface::INDEX_TYPE_INDEX] - ) - ->addForeignKey( - $installer->getFkName('search_synonyms', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - ) - ->addForeignKey( - $installer->getFkName('search_synonyms', 'website_id', 'store_website', 'website_id'), - 'website_id', - $installer->getTable('store_website'), - 'website_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - ) - ->setComment('table storing various synonyms groups'); - - $connection->createTable($table); - } - - if (version_compare($context->getVersion(), '2.0.4') < 0) { - $connection->dropIndex( - $setup->getTable('search_query'), - $installer->getIdxName('search_query', 'synonym_for') - ); - $connection->dropColumn($setup->getTable('search_query'), 'synonym_for'); - } - } -} diff --git a/app/code/Magento/Search/Test/Unit/Helper/DataTest.php b/app/code/Magento/Search/Test/Unit/Helper/DataTest.php index 5cfde7e8efda9..291362734feff 100644 --- a/app/code/Magento/Search/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Search/Test/Unit/Helper/DataTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Search\Test\Unit\Helper; /** @@ -43,6 +44,11 @@ class DataTest extends \PHPUnit\Framework\TestCase */ protected $storeManagerMock; + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $urlBuilderMock; + protected function setUp() { $this->stringMock = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class); @@ -53,9 +59,14 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods([]) ->getMock(); + $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) + ->setMethods(['getUrl']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->contextMock = $this->createMock(\Magento\Framework\App\Helper\Context::class); $this->contextMock->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfigMock); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilderMock); $this->model = new \Magento\Search\Helper\Data( $this->contextMock, @@ -126,4 +137,39 @@ public function queryTextDataProvider() ['testtest', 7, 'testtes'], ]; } + + /** + * Test getSuggestUrl() take into consideration type of request(secure, non-secure). + * + * @dataProvider getSuggestUrlDataProvider + * @param bool $isSecure + * @return void + */ + public function testGetSuggestUrl(bool $isSecure) + { + $this->requestMock->expects(self::once()) + ->method('isSecure') + ->willReturn($isSecure); + $this->urlBuilderMock->expects(self::once()) + ->method('getUrl') + ->with(self::identicalTo('search/ajax/suggest'), self::identicalTo(['_secure' => $isSecure])); + $this->model->getSuggestUrl(); + } + + /** + * Provide test data for testGetSuggestUrl() test. + * + * @return array + */ + public function getSuggestUrlDataProvider() + { + return [ + 'non-secure' => [ + 'isSecure' => false, + ], + 'secure' => [ + 'secure' => true, + ], + ]; + } } diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml new file mode 100644 index 0000000000000..54fac0778d469 --- /dev/null +++ b/app/code/Magento/Search/etc/db_schema.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    +
    diff --git a/app/code/Magento/Search/etc/db_schema_whitelist.json b/app/code/Magento/Search/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..72b417b976862 --- /dev/null +++ b/app/code/Magento/Search/etc/db_schema_whitelist.json @@ -0,0 +1,46 @@ +{ + "search_query": { + "column": { + "query_id": true, + "query_text": true, + "num_results": true, + "popularity": true, + "redirect": true, + "synonym_for": true, + "store_id": true, + "display_in_terms": true, + "is_active": true, + "is_processed": true, + "updated_at": true + }, + "index": { + "SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true, + "SEARCH_QUERY_STORE_ID": true, + "SEARCH_QUERY_IS_PROCESSED": true, + "SEARCH_QUERY_SYNONYM_FOR": true + }, + "constraint": { + "PRIMARY": true, + "SEARCH_QUERY_STORE_ID_STORE_STORE_ID": true, + "SEARCH_QUERY_QUERY_TEXT_STORE_ID": true + } + }, + "search_synonyms": { + "column": { + "group_id": true, + "synonyms": true, + "store_id": true, + "website_id": true + }, + "index": { + "SEARCH_SYNONYMS_SYNONYMS": true, + "SEARCH_SYNONYMS_STORE_ID": true, + "SEARCH_SYNONYMS_WEBSITE_ID": true + }, + "constraint": { + "PRIMARY": true, + "SEARCH_SYNONYMS_STORE_ID_STORE_STORE_ID": true, + "SEARCH_SYNONYMS_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Search/view/frontend/templates/form.mini.phtml b/app/code/Magento/Search/view/frontend/templates/form.mini.phtml index c4297b404717c..2ea87be13d5e3 100644 --- a/app/code/Magento/Search/view/frontend/templates/form.mini.phtml +++ b/app/code/Magento/Search/view/frontend/templates/form.mini.phtml @@ -9,7 +9,7 @@ helper('Magento\Search\Helper\Data'); +$helper = $this->helper(\Magento\Search\Helper\Data::class); ?>