diff --git a/app/code/Magento/Authorization/Setup/InstallSchema.php b/app/code/Magento/Authorization/Setup/InstallSchema.php
index d2199ef50ff83..be78cce218735 100644
--- a/app/code/Magento/Authorization/Setup/InstallSchema.php
+++ b/app/code/Magento/Authorization/Setup/InstallSchema.php
@@ -138,7 +138,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'role_id',
$installer->getTable('authorization_role'),
'role_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Admin Rule Table'
diff --git a/app/code/Magento/Bundle/Setup/InstallSchema.php b/app/code/Magento/Bundle/Setup/InstallSchema.php
index 96f43cb95704d..94325c54ff13c 100644
--- a/app/code/Magento/Bundle/Setup/InstallSchema.php
+++ b/app/code/Magento/Bundle/Setup/InstallSchema.php
@@ -79,7 +79,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Bundle Option');
@@ -138,7 +137,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_id',
$installer->getTable('catalog_product_bundle_option'),
'option_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Bundle Option Value');
@@ -238,7 +236,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_id',
$installer->getTable('catalog_product_bundle_option'),
'option_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -251,7 +248,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Bundle Selection');
@@ -305,7 +301,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -318,7 +313,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'selection_id',
$installer->getTable('catalog_product_bundle_selection'),
'selection_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Bundle Selection Price');
@@ -383,7 +377,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -396,7 +389,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -409,7 +401,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Bundle Price Index');
diff --git a/app/code/Magento/Catalog/Setup/InstallSchema.php b/app/code/Magento/Catalog/Setup/InstallSchema.php
index 1ca2468ed2a4e..d2dc790edb124 100644
--- a/app/code/Magento/Catalog/Setup/InstallSchema.php
+++ b/app/code/Magento/Catalog/Setup/InstallSchema.php
@@ -115,7 +115,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_set_id',
$installer->getTable('eav_attribute_set'),
'attribute_set_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -123,7 +122,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Table');
@@ -203,7 +201,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -216,7 +213,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -224,7 +220,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Datetime Attribute Backend Table');
@@ -304,7 +299,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -317,7 +311,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -325,7 +318,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Decimal Attribute Backend Table');
@@ -400,7 +392,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -408,7 +399,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -416,7 +406,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Integer Attribute Backend Table');
@@ -496,7 +485,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -509,7 +497,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -517,7 +504,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Text Attribute Backend Table');
@@ -597,7 +583,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -610,7 +595,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -618,7 +602,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Varchar Attribute Backend Table');
@@ -709,7 +692,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -722,7 +704,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -730,7 +711,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Gallery Attribute Backend Table');
@@ -896,7 +876,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -909,7 +888,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -917,7 +895,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Category Datetime Attribute Backend Table');
@@ -1001,7 +978,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1014,7 +990,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1022,7 +997,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Category Decimal Attribute Backend Table');
@@ -1101,7 +1075,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1114,7 +1087,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1122,7 +1094,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Category Integer Attribute Backend Table');
@@ -1201,7 +1172,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1214,7 +1184,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1222,7 +1191,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Category Text Attribute Backend Table');
@@ -1306,7 +1274,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1319,7 +1286,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1327,7 +1293,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Category Varchar Attribute Backend Table');
@@ -1373,7 +1338,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'category_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1381,7 +1345,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product To Category Linkage Table');
@@ -1514,7 +1477,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1522,7 +1484,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1530,8 +1491,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment(
'Catalog Compare Table'
@@ -1569,7 +1529,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1577,7 +1536,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -1675,7 +1633,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'linked_product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1683,7 +1640,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1696,7 +1652,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_type_id',
$installer->getTable('catalog_product_link_type'),
'link_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -1754,7 +1709,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_type_id',
$installer->getTable('catalog_product_link_type'),
'link_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -1821,7 +1775,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_id',
$installer->getTable('catalog_product_link'),
'link_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1834,7 +1787,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_link_attribute_id',
$installer->getTable('catalog_product_link_attribute'),
'product_link_attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -1901,7 +1853,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_id',
$installer->getTable('catalog_product_link'),
'link_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1914,7 +1865,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_link_attribute_id',
$installer->getTable('catalog_product_link_attribute'),
'product_link_attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -1981,7 +1931,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_id',
$installer->getTable('catalog_product_link'),
'link_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -1994,7 +1943,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_link_attribute_id',
$installer->getTable('catalog_product_link_attribute'),
'product_link_attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2086,7 +2034,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2099,7 +2046,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2107,7 +2053,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2169,7 +2114,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2182,7 +2126,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2258,7 +2201,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'value_id',
$installer->getTable('catalog_product_entity_media_gallery'),
'value_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2266,7 +2208,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2279,7 +2220,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2374,7 +2314,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2448,7 +2387,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_id',
$installer->getTable('catalog_product_option'),
'option_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2456,7 +2394,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2523,7 +2460,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_id',
$installer->getTable('catalog_product_option'),
'option_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2531,7 +2467,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2663,7 +2598,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_type_id',
$installer->getTable('catalog_product_option_type_value'),
'option_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2671,7 +2605,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2738,7 +2671,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_type_id',
$installer->getTable('catalog_product_option_type_value'),
'option_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2746,7 +2678,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2908,7 +2839,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -2947,7 +2877,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'child_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -2955,7 +2884,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -3169,7 +3097,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -3182,7 +3109,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -3190,7 +3116,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -3252,7 +3177,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -3265,7 +3189,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -3273,7 +3196,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -3319,7 +3241,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -4605,7 +4526,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -4618,7 +4538,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -4631,7 +4550,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
@@ -4694,7 +4612,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -4707,7 +4624,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -4715,7 +4631,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment(
diff --git a/app/code/Magento/CatalogInventory/Setup/InstallSchema.php b/app/code/Magento/CatalogInventory/Setup/InstallSchema.php
index d7730876dd43e..aa6705a61ca82 100644
--- a/app/code/Magento/CatalogInventory/Setup/InstallSchema.php
+++ b/app/code/Magento/CatalogInventory/Setup/InstallSchema.php
@@ -283,7 +283,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -291,7 +290,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'stock_id',
$installer->getTable('cataloginventory_stock'),
'stock_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Cataloginventory Stock Item');
diff --git a/app/code/Magento/CatalogRule/Setup/InstallSchema.php b/app/code/Magento/CatalogRule/Setup/InstallSchema.php
index 7c9fd560f92a8..610434b70a444 100644
--- a/app/code/Magento/CatalogRule/Setup/InstallSchema.php
+++ b/app/code/Magento/CatalogRule/Setup/InstallSchema.php
@@ -418,7 +418,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -426,7 +425,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('catalogrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -434,7 +432,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('CatalogRule Group Website');
@@ -469,7 +466,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('catalogrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -477,7 +473,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Rules To Websites Relations');
@@ -512,7 +507,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('catalogrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -525,7 +519,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Rules To Customer Groups Relations');
diff --git a/app/code/Magento/CatalogUrlRewrite/Setup/InstallSchema.php b/app/code/Magento/CatalogUrlRewrite/Setup/InstallSchema.php
index baed812982fcb..88acf7808b614 100644
--- a/app/code/Magento/CatalogUrlRewrite/Setup/InstallSchema.php
+++ b/app/code/Magento/CatalogUrlRewrite/Setup/InstallSchema.php
@@ -57,7 +57,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -65,7 +64,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'category_id',
$installer->getTable('catalog_category_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -73,7 +71,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'url_rewrite_id',
$installer->getTable('url_rewrite'),
'url_rewrite_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('url_rewrite_relation');
diff --git a/app/code/Magento/CheckoutAgreements/Setup/InstallSchema.php b/app/code/Magento/CheckoutAgreements/Setup/InstallSchema.php
index 2b782a0ed9bf7..d4df1585bb67b 100644
--- a/app/code/Magento/CheckoutAgreements/Setup/InstallSchema.php
+++ b/app/code/Magento/CheckoutAgreements/Setup/InstallSchema.php
@@ -97,14 +97,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'agreement_id',
$installer->getTable('checkout_agreement'),
'agreement_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('checkout_agreement_store', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Checkout Agreement Store'
diff --git a/app/code/Magento/Cms/Setup/InstallSchema.php b/app/code/Magento/Cms/Setup/InstallSchema.php
index d57b656b11039..00c2eba7289fe 100644
--- a/app/code/Magento/Cms/Setup/InstallSchema.php
+++ b/app/code/Magento/Cms/Setup/InstallSchema.php
@@ -102,14 +102,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'block_id',
$installer->getTable('cms_block'),
'block_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('cms_block_store', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'CMS Block To Store Linkage Table'
@@ -262,14 +260,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'page_id',
$installer->getTable('cms_page'),
'page_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('cms_page_store', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'CMS Page To Store Linkage Table'
diff --git a/app/code/Magento/ConfigurableProduct/Setup/InstallSchema.php b/app/code/Magento/ConfigurableProduct/Setup/InstallSchema.php
index 51ce770c9aa04..d4514e8618dbd 100644
--- a/app/code/Magento/ConfigurableProduct/Setup/InstallSchema.php
+++ b/app/code/Magento/ConfigurableProduct/Setup/InstallSchema.php
@@ -77,8 +77,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Super Attribute Table');
@@ -147,7 +146,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_super_attribute_id',
$installer->getTable('catalog_product_super_attribute'),
'product_super_attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -155,7 +153,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Super Attribute Label Table');
@@ -231,7 +228,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -244,7 +240,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_super_attribute_id',
$installer->getTable('catalog_product_super_attribute'),
'product_super_attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Super Attribute Pricing Table');
@@ -300,7 +295,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -308,7 +302,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Catalog Product Super Link Table');
diff --git a/app/code/Magento/Customer/Setup/InstallSchema.php b/app/code/Magento/Customer/Setup/InstallSchema.php
index d4a9815838c9e..6f6750f379704 100644
--- a/app/code/Magento/Customer/Setup/InstallSchema.php
+++ b/app/code/Magento/Customer/Setup/InstallSchema.php
@@ -123,15 +123,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->addForeignKey(
$installer->getFkName('customer_entity', 'website_id', 'store_website', 'website_id'),
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Customer Entity'
);
@@ -262,7 +260,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -274,7 +271,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('customer_address_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -286,7 +282,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Address Entity Datetime'
@@ -350,7 +345,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -362,7 +356,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('customer_address_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -374,7 +367,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Address Entity Decimal'
@@ -438,21 +430,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_address_entity_int', 'entity_id', 'customer_address_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_address_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_address_entity_int', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Address Entity Int'
@@ -513,14 +502,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_address_entity_text', 'entity_id', 'customer_address_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_address_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -532,7 +519,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Address Entity Text'
@@ -596,7 +582,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -608,7 +593,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('customer_address_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -620,7 +604,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Address Entity Varchar'
@@ -684,21 +667,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_datetime', 'entity_id', 'customer_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_datetime', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Entity Datetime'
@@ -762,21 +742,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_decimal', 'entity_id', 'customer_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_decimal', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Entity Decimal'
@@ -840,21 +817,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_int', 'entity_id', 'customer_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_int', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Entity Int'
@@ -915,21 +889,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_text', 'entity_id', 'customer_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_text', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Entity Text'
@@ -993,21 +964,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_varchar', 'entity_id', 'customer_entity', 'entity_id'),
'entity_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_entity_varchar', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Entity Varchar'
@@ -1100,7 +1068,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Eav Attribute'
@@ -1132,7 +1099,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Form Attribute'
@@ -1188,14 +1154,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('customer_eav_attribute_website', 'website_id', 'store_website', 'website_id'),
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Customer Eav Attribute Website'
diff --git a/app/code/Magento/DesignEditor/Setup/InstallSchema.php b/app/code/Magento/DesignEditor/Setup/InstallSchema.php
index e6a87de0bc1f1..d5edc3e7e86d9 100644
--- a/app/code/Magento/DesignEditor/Setup/InstallSchema.php
+++ b/app/code/Magento/DesignEditor/Setup/InstallSchema.php
@@ -51,7 +51,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'theme_id',
$setup->getTable('theme'),
'theme_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Design Editor Theme Change'
diff --git a/app/code/Magento/Directory/Setup/InstallSchema.php b/app/code/Magento/Directory/Setup/InstallSchema.php
index e28328894d022..101ccd3ededc4 100644
--- a/app/code/Magento/Directory/Setup/InstallSchema.php
+++ b/app/code/Magento/Directory/Setup/InstallSchema.php
@@ -168,7 +168,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'region_id',
$installer->getTable('directory_country_region'),
'region_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Directory Country Region Name'
diff --git a/app/code/Magento/Downloadable/Setup/InstallSchema.php b/app/code/Magento/Downloadable/Setup/InstallSchema.php
index 101da102b1418..e7043312e7a49 100644
--- a/app/code/Magento/Downloadable/Setup/InstallSchema.php
+++ b/app/code/Magento/Downloadable/Setup/InstallSchema.php
@@ -116,7 +116,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Downloadable Link Table');
@@ -164,7 +163,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_id',
$installer->getTable('downloadable_link'),
'link_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addIndex(
@@ -176,7 +174,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Downloadable Link Price Table');
@@ -274,16 +271,14 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->addForeignKey(
$installer->getFkName('downloadable_link_purchased', 'order_id', 'sales_order', 'entity_id'),
'order_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Downloadable Link Purchased Table');
$installer->getConnection()->createTable($table);
@@ -427,7 +422,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'purchased_id',
$installer->getTable('downloadable_link_purchased'),
'purchased_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -440,8 +434,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'order_item_id',
$installer->getTable('sales_order_item'),
'item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Downloadable Link Purchased Item Table');
$installer->getConnection()->createTable($table);
@@ -493,7 +486,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'link_id',
$installer->getTable('downloadable_link'),
'link_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addIndex(
@@ -505,7 +497,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Link Title Table');
@@ -567,7 +558,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Downloadable Sample Table');
@@ -620,7 +610,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'sample_id',
$installer->getTable('downloadable_sample'),
'sample_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addIndex(
@@ -632,7 +621,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Downloadable Sample Title Table');
diff --git a/app/code/Magento/Eav/Setup/InstallSchema.php b/app/code/Magento/Eav/Setup/InstallSchema.php
index 9fb0d559cce5b..244cfe2d85e9e 100644
--- a/app/code/Magento/Eav/Setup/InstallSchema.php
+++ b/app/code/Magento/Eav/Setup/InstallSchema.php
@@ -204,14 +204,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity'
@@ -281,21 +279,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('eav_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_datetime', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_datetime', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Value Prefix'
@@ -365,21 +360,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('eav_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_decimal', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_decimal', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Value Prefix'
@@ -449,21 +441,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('eav_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_int', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_int', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Value Prefix'
@@ -533,21 +522,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('eav_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_text', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_text', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Value Prefix'
@@ -617,21 +603,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('eav_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_varchar', 'entity_type_id', 'eav_entity_type', 'entity_type_id'),
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_varchar', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Value Prefix'
@@ -758,7 +741,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Attribute'
@@ -811,14 +793,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_entity_store', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Store'
@@ -870,7 +850,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Attribute Set'
@@ -940,7 +919,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_set_id',
$installer->getTable('eav_attribute_set'),
'attribute_set_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Attribute Group'
@@ -1015,7 +993,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -1027,7 +1004,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_group_id',
$installer->getTable('eav_attribute_group'),
'attribute_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Entity Attributes'
@@ -1065,7 +1041,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Attribute Option'
@@ -1112,14 +1087,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_id',
$installer->getTable('eav_attribute_option'),
'option_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_attribute_option_value', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Attribute Option Value'
@@ -1166,14 +1139,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_attribute_label', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Attribute Label'
@@ -1237,7 +1208,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Form Type'
@@ -1269,14 +1239,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_type_id',
$installer->getTable('eav_entity_type'),
'entity_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_form_type_entity', 'type_id', 'eav_form_type', 'type_id'),
'type_id',
$installer->getTable('eav_form_type'),
'type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Form Type Entity'
@@ -1325,7 +1293,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'type_id',
$installer->getTable('eav_form_type'),
'type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Form Fieldset'
@@ -1363,14 +1330,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'fieldset_id',
$installer->getTable('eav_form_fieldset'),
'fieldset_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_form_fieldset_label', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Form Fieldset Label'
@@ -1431,21 +1396,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('eav_form_element', 'fieldset_id', 'eav_form_fieldset', 'fieldset_id'),
'fieldset_id',
$installer->getTable('eav_form_fieldset'),
'fieldset_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->addForeignKey(
$installer->getFkName('eav_form_element', 'type_id', 'eav_form_type', 'type_id'),
'type_id',
$installer->getTable('eav_form_type'),
'type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Eav Form Element'
diff --git a/app/code/Magento/GoogleOptimizer/Setup/InstallSchema.php b/app/code/Magento/GoogleOptimizer/Setup/InstallSchema.php
index a43eb599a8d72..e15c6b957e223 100644
--- a/app/code/Magento/GoogleOptimizer/Setup/InstallSchema.php
+++ b/app/code/Magento/GoogleOptimizer/Setup/InstallSchema.php
@@ -78,7 +78,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Google Experiment code');
diff --git a/app/code/Magento/Integration/Setup/InstallSchema.php b/app/code/Magento/Integration/Setup/InstallSchema.php
index f3522a162f2fc..7c6bfda56692b 100644
--- a/app/code/Magento/Integration/Setup/InstallSchema.php
+++ b/app/code/Magento/Integration/Setup/InstallSchema.php
@@ -211,21 +211,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'admin_id',
$adminTable,
'user_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('oauth_token', 'consumer_id', 'oauth_consumer', 'entity_id'),
'consumer_id',
$installer->getTable('oauth_consumer'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('oauth_token', 'customer_id', 'customer_entity', 'entity_id'),
'customer_id',
$customerTable,
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'OAuth Tokens'
@@ -268,7 +265,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'consumer_id',
$installer->getTable('oauth_consumer'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'OAuth Nonce'
@@ -361,7 +357,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'consumer_id',
$installer->getTable('oauth_consumer'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
);
diff --git a/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Database.php b/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Database.php
index 6c77da1c9f7f4..1d1c0c7224c38 100644
--- a/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Database.php
+++ b/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Database.php
@@ -109,7 +109,6 @@ public function createDatabaseScheme()
'directory_id',
$dirStorageTable,
'directory_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'File Storage'
diff --git a/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Directory/Database.php b/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Directory/Database.php
index 8291cd2257117..0ea6567f6404a 100644
--- a/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Directory/Database.php
+++ b/app/code/Magento/MediaStorage/Model/Resource/File/Storage/Directory/Database.php
@@ -81,7 +81,6 @@ public function createDatabaseScheme()
'parent_id',
$table,
'directory_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Directory Storage'
diff --git a/app/code/Magento/Newsletter/Setup/InstallSchema.php b/app/code/Magento/Newsletter/Setup/InstallSchema.php
index 87ad2e8adcca1..f567558d0550f 100644
--- a/app/code/Magento/Newsletter/Setup/InstallSchema.php
+++ b/app/code/Magento/Newsletter/Setup/InstallSchema.php
@@ -92,8 +92,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Newsletter Subscriber');
$installer->getConnection()->createTable($table);
@@ -293,7 +292,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'template_id',
$installer->getTable('newsletter_template'),
'template_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Newsletter Queue');
@@ -345,7 +343,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'queue_id',
$installer->getTable('newsletter_queue'),
'queue_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -358,7 +355,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'subscriber_id',
$installer->getTable('newsletter_subscriber'),
'subscriber_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Newsletter Queue Link');
@@ -392,7 +388,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'queue_id',
$installer->getTable('newsletter_queue'),
'queue_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -400,7 +395,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Newsletter Queue Store Link');
@@ -459,7 +453,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'queue_id',
$installer->getTable('newsletter_queue'),
'queue_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -467,7 +460,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'subscriber_id',
$installer->getTable('newsletter_subscriber'),
'subscriber_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Newsletter Problems');
diff --git a/app/code/Magento/ProductAlert/Setup/InstallSchema.php b/app/code/Magento/ProductAlert/Setup/InstallSchema.php
index 6b8e6b732f368..8ccda0176f768 100644
--- a/app/code/Magento/ProductAlert/Setup/InstallSchema.php
+++ b/app/code/Magento/ProductAlert/Setup/InstallSchema.php
@@ -97,21 +97,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('product_alert_price', 'product_id', 'catalog_product_entity', 'entity_id'),
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('product_alert_price', 'website_id', 'store_website', 'website_id'),
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Product Alert Price'
@@ -185,21 +182,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('product_alert_stock', 'customer_id', 'customer_entity', 'entity_id'),
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('product_alert_stock', 'product_id', 'catalog_product_entity', 'entity_id'),
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Product Alert Stock'
diff --git a/app/code/Magento/Quote/Setup/InstallSchema.php b/app/code/Magento/Quote/Setup/InstallSchema.php
index 5e736acaaabe1..7e9947028060c 100644
--- a/app/code/Magento/Quote/Setup/InstallSchema.php
+++ b/app/code/Magento/Quote/Setup/InstallSchema.php
@@ -334,7 +334,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Quote'
@@ -684,7 +683,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'quote_id',
$installer->getTable('quote'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Quote Address'
@@ -965,29 +963,25 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_item_id',
$installer->getTable('quote_item'),
'item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('quote_item', 'product_id', 'catalog_product_entity', 'entity_id'),
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('quote_item', 'quote_id', 'quote', 'entity_id'),
'quote_id',
$installer->getTable('quote'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('quote_item', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Quote Item'
);
@@ -1245,7 +1239,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'quote_address_id',
$installer->getTable('quote_address'),
'address_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -1257,14 +1250,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_item_id',
$installer->getTable('quote_address_item'),
'address_item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('quote_address_item', 'quote_item_id', 'quote_item', 'item_id'),
'quote_item_id',
$installer->getTable('quote_item'),
'item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Quote Address Item'
@@ -1314,7 +1305,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'item_id',
$installer->getTable('quote_item'),
'item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Quote Item Option'
@@ -1448,7 +1438,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'quote_id',
$installer->getTable('quote'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Quote Payment'
@@ -1540,7 +1529,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'address_id',
$installer->getTable('quote_address'),
'address_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Quote Shipping Rate'
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
index 6de66a60e04a8..347405789dc2e 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
@@ -57,14 +57,7 @@ protected function _construct()
protected function _prepareCollection()
{
$collection = $this->_quotesFactory->create();
- if ($this->queryResolver->isSingleQuery()) {
- $collection->prepareForProductsInCarts();
- $collection->setSelectCountSqlType(
- \Magento\Reports\Model\Resource\Quote\Collection::SELECT_COUNT_SQL_TYPE_CART
- );
- } else {
- $collection->prepareActiveCartItems();
- }
+ $collection->prepareActiveCartItems();
$this->setCollection($collection);
return parent::_prepareCollection();
}
@@ -80,6 +73,7 @@ protected function _prepareColumns()
'header' => __('ID'),
'align' => 'right',
'index' => 'entity_id',
+ 'sortable' => false,
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
@@ -90,6 +84,7 @@ protected function _prepareColumns()
[
'header' => __('Product'),
'index' => 'name',
+ 'sortable' => false,
'header_css_class' => 'col-product',
'column_css_class' => 'col-product'
]
@@ -104,6 +99,7 @@ protected function _prepareColumns()
'type' => 'currency',
'currency_code' => $currencyCode,
'index' => 'price',
+ 'sortable' => false,
'renderer' => 'Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency',
'rate' => $this->getRate($currencyCode),
'header_css_class' => 'col-price',
@@ -117,6 +113,7 @@ protected function _prepareColumns()
'header' => __('Carts'),
'align' => 'right',
'index' => 'carts',
+ 'sortable' => false,
'header_css_class' => 'col-carts',
'column_css_class' => 'col-carts'
]
@@ -128,6 +125,7 @@ protected function _prepareColumns()
'header' => __('Orders'),
'align' => 'right',
'index' => 'orders',
+ 'sortable' => false,
'header_css_class' => 'col-qty',
'column_css_class' => 'col-qty'
]
diff --git a/app/code/Magento/Reports/Model/Resource/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Customer/Collection.php
index a4b9fee5599ca..c602eb91ae9b4 100644
--- a/app/code/Magento/Reports/Model/Resource/Customer/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Customer/Collection.php
@@ -66,6 +66,11 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection
*/
protected $_quoteItemFactory;
+ /**
+ * @var \Magento\Sales\Model\Resource\Order\Collection
+ */
+ protected $orderResource;
+
/**
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
* @param \Psr\Log\LoggerInterface $logger
@@ -79,6 +84,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection
* @param \Magento\Framework\Object\Copy\Config $fieldsetConfig
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
* @param \Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemFactory
+ * @param \Magento\Sales\Model\Resource\Order\Collection $orderResource
* @param mixed $connection
* @param string $modelName
*
@@ -97,6 +103,7 @@ public function __construct(
\Magento\Framework\Object\Copy\Config $fieldsetConfig,
\Magento\Quote\Model\QuoteRepository $quoteRepository,
\Magento\Quote\Model\Resource\Quote\Item\CollectionFactory $quoteItemFactory,
+ \Magento\Sales\Model\Resource\Order\Collection $orderResource,
$connection = null,
$modelName = self::CUSTOMER_MODEL_NAME
) {
@@ -114,6 +121,7 @@ public function __construct(
$connection,
$modelName
);
+ $this->orderResource = $orderResource;
$this->quoteRepository = $quoteRepository;
$this->_quoteItemFactory = $quoteItemFactory;
}
@@ -152,90 +160,6 @@ public function addCustomerName()
return $this;
}
- /**
- * Order for each customer
- *
- * @param string $fromDate
- * @param string $toDate
- * @return $this
- */
- public function joinOrders($fromDate = '', $toDate = '')
- {
- if ($fromDate != '' && $toDate != '') {
- $dateFilter = " AND orders.created_at BETWEEN '{$fromDate}' AND '{$toDate}'";
- } else {
- $dateFilter = '';
- }
-
- $this->getSelect()->joinLeft(
- ['orders' => $this->getTable('sales_order')],
- "orders.customer_id = e.entity_id" . $dateFilter,
- []
- );
-
- return $this;
- }
-
- /**
- * Add orders count
- *
- * @return $this
- */
- public function addOrdersCount()
- {
- $this->getSelect()->columns(
- ["orders_count" => "COUNT(orders.entity_id)"]
- )->where(
- 'orders.state <> ?',
- \Magento\Sales\Model\Order::STATE_CANCELED
- )->group(
- "e.entity_id"
- );
-
- return $this;
- }
-
- /**
- * Order summary info for each customer such as orders_count, orders_avg_amount, orders_total_amount
- *
- * @param int $storeId
- * @return $this
- */
- public function addSumAvgTotals($storeId = 0)
- {
- $adapter = $this->getConnection();
- $baseSubtotalRefunded = $adapter->getIfNullSql('orders.base_subtotal_refunded', 0);
- $baseSubtotalCanceled = $adapter->getIfNullSql('orders.base_subtotal_canceled', 0);
-
- /**
- * calculate average and total amount
- */
- $expr = $storeId ==
- 0 ?
- "(orders.base_subtotal - {$baseSubtotalCanceled} - {$baseSubtotalRefunded}) * orders.base_to_global_rate" :
- "orders.base_subtotal - {$baseSubtotalCanceled} - {$baseSubtotalRefunded}";
-
- $this->getSelect()->columns(
- ["orders_avg_amount" => "AVG({$expr})"]
- )->columns(
- ["orders_sum_amount" => "SUM({$expr})"]
- );
-
- return $this;
- }
-
- /**
- * Order by total amount
- *
- * @param string $dir
- * @return $this
- */
- public function orderByTotalAmount($dir = self::SORT_ORDER_DESC)
- {
- $this->getSelect()->order("orders_sum_amount {$dir}");
- return $this;
- }
-
/**
* Add order statistics
*
@@ -259,7 +183,7 @@ protected function _addOrdersStatistics()
$customerIds = $this->getColumnValues($this->getResource()->getIdFieldName());
if ($this->_addOrderStatistics && !empty($customerIds)) {
- $adapter = $this->getConnection();
+ $adapter = $this->orderResource->getConnection();
$baseSubtotalRefunded = $adapter->getIfNullSql('orders.base_subtotal_refunded', 0);
$baseSubtotalCanceled = $adapter->getIfNullSql('orders.base_subtotal_canceled', 0);
@@ -267,9 +191,9 @@ protected function _addOrdersStatistics()
"(orders.base_subtotal-{$baseSubtotalCanceled}-{$baseSubtotalRefunded})*orders.base_to_global_rate" :
"orders.base_subtotal-{$baseSubtotalCanceled}-{$baseSubtotalRefunded}";
- $select = $this->getConnection()->select();
+ $select = $this->orderResource->getConnection()->select();
$select->from(
- ['orders' => $this->getTable('sales_order')],
+ ['orders' => $this->orderResource->getTable('sales_order')],
[
'orders_avg_amount' => "AVG({$totalExpr})",
'orders_sum_amount' => "SUM({$totalExpr})",
@@ -286,7 +210,7 @@ protected function _addOrdersStatistics()
'orders.customer_id'
);
- foreach ($this->getConnection()->fetchAll($select) as $ordersInfo) {
+ foreach ($this->orderResource->getConnection()->fetchAll($select) as $ordersInfo) {
$this->getItemById($ordersInfo['customer_id'])->addData($ordersInfo);
}
}
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php
index 3e77d75e16eb6..3eb9ac629a26e 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php
@@ -56,6 +56,11 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
*/
protected $_productType;
+ /**
+ * @var \Magento\Quote\Model\Resource\Quote\Collection
+ */
+ protected $quoteResource;
+
/**
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
* @param \Psr\Log\LoggerInterface $logger
@@ -79,6 +84,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
* @param \Magento\Catalog\Model\Resource\Product $product
* @param \Magento\Reports\Model\Event\TypeFactory $eventTypeFactory
* @param \Magento\Catalog\Model\Product\Type $productType
+ * @param \Magento\Quote\Model\Resource\Quote\Collection $quoteResource
* @param mixed $connection
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -106,6 +112,7 @@ public function __construct(
\Magento\Catalog\Model\Resource\Product $product,
\Magento\Reports\Model\Event\TypeFactory $eventTypeFactory,
\Magento\Catalog\Model\Product\Type $productType,
+ \Magento\Quote\Model\Resource\Quote\Collection $quoteResource,
$connection = null
) {
$this->setProductEntityId($product->getEntityIdField());
@@ -135,6 +142,7 @@ public function __construct(
);
$this->_eventTypeFactory = $eventTypeFactory;
$this->_productType = $productType;
+ $this->quoteResource = $quoteResource;
}
/**
@@ -239,7 +247,7 @@ protected function _joinFields()
public function getSelectCountSql()
{
if ($this->_selectCountSqlType == self::SELECT_COUNT_SQL_TYPE_CART) {
- $countSelect = clone $this->getSelect();
+ $countSelect = clone $this->quoteResource->getSelect();
$countSelect->reset()->from(
['quote_item_table' => $this->getTable('quote_item')],
['COUNT(DISTINCT quote_item_table.product_id)']
@@ -263,102 +271,6 @@ public function getSelectCountSql()
return $countSelect;
}
- /**
- * Add orders count
- *
- * @param string $from
- * @param string $to
- * @return $this
- */
- public function addOrdersCount($from = '', $to = '')
- {
- $orderItemTableName = $this->getTable('sales_order_item');
- $productFieldName = sprintf('e.%s', $this->getProductEntityId());
-
- $this->getSelect()->joinLeft(
- ['order_items' => $orderItemTableName],
- "order_items.product_id = {$productFieldName}",
- []
- )->columns(
- ['orders' => 'COUNT(order_items2.item_id)']
- )->group(
- $productFieldName
- );
-
- $dateFilter = ['order_items2.item_id = order_items.item_id'];
- if ($from != '' && $to != '') {
- $dateFilter[] = $this->_prepareBetweenSql('order_items2.created_at', $from, $to);
- }
-
- $this->getSelect()->joinLeft(
- ['order_items2' => $orderItemTableName],
- implode(' AND ', $dateFilter),
- []
- );
-
- return $this;
- }
-
- /**
- * Add ordered qty's
- *
- * @param string $from
- * @param string $to
- * @return $this
- */
- public function addOrderedQty($from = '', $to = '')
- {
- $adapter = $this->getConnection();
- $compositeTypeIds = $this->_productType->getCompositeTypes();
- $orderTableAliasName = $adapter->quoteIdentifier('order');
-
- $orderJoinCondition = [
- $orderTableAliasName . '.entity_id = order_items.order_id',
- $adapter->quoteInto("{$orderTableAliasName}.state <> ?", \Magento\Sales\Model\Order::STATE_CANCELED),
- ];
-
- $productJoinCondition = [
- $adapter->quoteInto('(e.type_id NOT IN (?))', $compositeTypeIds),
- 'e.entity_id = order_items.product_id',
- $adapter->quoteInto('e.attribute_set_id = ?', $this->getProductAttributeSetId()),
- ];
-
- if ($from != '' && $to != '') {
- $fieldName = $orderTableAliasName . '.created_at';
- $orderJoinCondition[] = $this->_prepareBetweenSql($fieldName, $from, $to);
- }
-
- $this->getSelect()->reset()->from(
- ['order_items' => $this->getTable('sales_order_item')],
- ['ordered_qty' => 'SUM(order_items.qty_ordered)', 'order_items_name' => 'order_items.name']
- )->joinInner(
- ['order' => $this->getTable('sales_order')],
- implode(' AND ', $orderJoinCondition),
- []
- )->joinLeft(
- ['e' => $this->getProductEntityTableName()],
- implode(' AND ', $productJoinCondition),
- [
- 'entity_id' => 'order_items.product_id',
- 'attribute_set_id' => 'e.attribute_set_id',
- 'type_id' => 'e.type_id',
- 'sku' => 'e.sku',
- 'has_options' => 'e.has_options',
- 'required_options' => 'e.required_options',
- 'created_at' => 'e.created_at',
- 'updated_at' => 'e.updated_at'
- ]
- )->where(
- 'parent_item_id IS NULL'
- )->group(
- 'order_items.product_id'
- )->having(
- 'SUM(order_items.qty_ordered) > ?',
- 0
- );
- return $this;
- }
-
/**
* Set order
*
@@ -368,7 +280,7 @@ public function addOrderedQty($from = '', $to = '')
*/
public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
{
- if (in_array($attribute, ['carts', 'orders', 'ordered_qty'])) {
+ if (in_array($attribute, ['carts'])) {
$this->getSelect()->order($attribute . ' ' . $dir);
} else {
parent::setOrder($attribute, $dir);
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php
index 521135eeb0422..0c71c26aa69eb 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php
@@ -68,6 +68,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection
* @param \Magento\Catalog\Model\Resource\Product $product
* @param \Magento\Reports\Model\Event\TypeFactory $eventTypeFactory
* @param \Magento\Catalog\Model\Product\Type $productType
+ * @param \Magento\Quote\Model\Resource\Quote\Collection $quoteResource
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
* @param \Magento\CatalogInventory\Model\Resource\Stock\Item $itemResource
@@ -98,6 +99,7 @@ public function __construct(
\Magento\Catalog\Model\Resource\Product $product,
\Magento\Reports\Model\Event\TypeFactory $eventTypeFactory,
\Magento\Catalog\Model\Product\Type $productType,
+ \Magento\Quote\Model\Resource\Quote\Collection $quoteResource,
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
\Magento\CatalogInventory\Model\Resource\Stock\Item $itemResource,
@@ -126,6 +128,7 @@ public function __construct(
$product,
$eventTypeFactory,
$productType,
+ $quoteResource,
$connection
);
$this->stockRegistry = $stockRegistry;
diff --git a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php
index 0b91b4a360e71..2959e2cd45165 100644
--- a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php
@@ -11,7 +11,7 @@
*/
namespace Magento\Reports\Model\Resource\Product\Sold;
-class Collection extends \Magento\Reports\Model\Resource\Product\Collection
+class Collection extends \Magento\Reports\Model\Resource\Order\Collection
{
/**
* Set Date range to collection
@@ -34,6 +34,46 @@ public function setDateRange($from, $to)
return $this;
}
+ /**
+ * Add ordered qty's
+ *
+ * @param string $from
+ * @param string $to
+ * @return $this
+ */
+ public function addOrderedQty($from = '', $to = '')
+ {
+ $adapter = $this->getConnection();
+ $orderTableAliasName = $adapter->quoteIdentifier('order');
+
+ $orderJoinCondition = [
+ $orderTableAliasName . '.entity_id = order_items.order_id',
+ $adapter->quoteInto("{$orderTableAliasName}.state <> ?", \Magento\Sales\Model\Order::STATE_CANCELED),
+ ];
+
+ if ($from != '' && $to != '') {
+ $fieldName = $orderTableAliasName . '.created_at';
+ $orderJoinCondition[] = $this->prepareBetweenSql($fieldName, $from, $to);
+ }
+
+ $this->getSelect()->reset()->from(
+ ['order_items' => $this->getTable('sales_order_item')],
+ ['ordered_qty' => 'SUM(order_items.qty_ordered)', 'order_items_name' => 'order_items.name']
+ )->joinInner(
+ ['order' => $this->getTable('sales_order')],
+ implode(' AND ', $orderJoinCondition),
+ []
+ )->where(
+ 'parent_item_id IS NULL'
+ )->group(
+ 'order_items.product_id'
+ )->having(
+ 'SUM(order_items.qty_ordered) > ?',
+ 0
+ );
+ return $this;
+ }
+
/**
* Set store filter to collection
*
@@ -49,29 +89,38 @@ public function setStoreIds($storeIds)
}
/**
- * Add website product limitation
+ * Set order
*
+ * @param string $attribute
+ * @param string $dir
* @return $this
*/
- protected function _productLimitationJoinWebsite()
+ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
{
- $filters = $this->_productLimitationFilters;
- $conditions = ['product_website.product_id=e.entity_id'];
- if (isset($filters['website_ids'])) {
- $conditions[] = $this->getConnection()->quoteInto(
- 'product_website.website_id IN(?)',
- $filters['website_ids']
- );
-
- $subQuery = $this->getConnection()->select()->from(
- ['product_website' => $this->getTable('catalog_product_website')],
- ['product_website.product_id']
- )->where(
- join(' AND ', $conditions)
- );
- $this->getSelect()->where('e.entity_id IN( ' . $subQuery . ' )');
+ if (in_array($attribute, ['orders', 'ordered_qty'])) {
+ $this->getSelect()->order($attribute . ' ' . $dir);
+ } else {
+ parent::setOrder($attribute, $dir);
}
return $this;
}
+
+ /**
+ * Prepare between sql
+ *
+ * @param string $fieldName Field name with table suffix ('created_at' or 'main_table.created_at')
+ * @param string $from
+ * @param string $to
+ * @return string Formatted sql string
+ */
+ protected function prepareBetweenSql($fieldName, $from, $to)
+ {
+ return sprintf(
+ '(%s BETWEEN %s AND %s)',
+ $fieldName,
+ $this->getConnection()->quote($from),
+ $this->getConnection()->quote($to)
+ );
+ }
}
diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php
index 38ba00038520a..cb2a9333fe01e 100644
--- a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php
+++ b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php
@@ -13,6 +13,10 @@
*/
namespace Magento\Reports\Model\Resource\Quote;
+/**
+ * Class Collection
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class Collection extends \Magento\Quote\Model\Resource\Quote\Collection
{
const SELECT_COUNT_SQL_TYPE_CART = 1;
@@ -39,12 +43,17 @@ class Collection extends \Magento\Quote\Model\Resource\Quote\Collection
/**
* @var \Magento\Catalog\Model\Resource\Product\Collection
*/
- protected $_productResource;
+ protected $productResource;
/**
* @var \Magento\Customer\Model\Resource\Customer
*/
- protected $_customerResource;
+ protected $customerResource;
+
+ /**
+ * @var \Magento\Sales\Model\Resource\Order\Collection
+ */
+ protected $orderResource;
/**
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
@@ -53,6 +62,7 @@ class Collection extends \Magento\Quote\Model\Resource\Quote\Collection
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Catalog\Model\Resource\Product\Collection $productResource
* @param \Magento\Customer\Model\Resource\Customer $customerResource
+ * @param \Magento\Sales\Model\Resource\Order\Collection $orderResource
* @param null $connection
* @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource
*/
@@ -63,12 +73,14 @@ public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Catalog\Model\Resource\Product\Collection $productResource,
\Magento\Customer\Model\Resource\Customer $customerResource,
+ \Magento\Sales\Model\Resource\Order\Collection $orderResource,
$connection = null,
\Magento\Framework\Model\Resource\Db\AbstractDb $resource = null
) {
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
- $this->_productResource = $productResource;
- $this->_customerResource = $customerResource;
+ $this->productResource = $productResource;
+ $this->customerResource = $customerResource;
+ $this->orderResource = $orderResource;
}
/**
@@ -120,75 +132,47 @@ public function prepareForAbandonedReport($storeIds, $filter = null)
/**
* Prepare select query for products in carts report
*
- * @return $this
+ * @return \Magento\Framework\DB\Select
*/
- public function prepareForProductsInCarts()
+ public function prepareActiveCartItems()
{
- $productAttrName = $this->_productResource->getAttribute('name');
- $productAttrNameId = (int)$productAttrName->getAttributeId();
- $productAttrNameTable = $productAttrName->getBackend()->getTable();
- $productAttrPrice = $this->_productResource->getAttribute('price');
- $productAttrPriceId = (int)$productAttrPrice->getAttributeId();
- $productAttrPriceTable = $productAttrPrice->getBackend()->getTable();
-
- $this->getSelect()->useStraightJoin(
- true
- )->reset(
- \Zend_Db_Select::COLUMNS
- )->joinInner(
- ['quote_items' => $this->getTable('quote_item')],
- 'quote_items.quote_id = main_table.entity_id',
- null
- )->joinInner(
- ['e' => $this->getTable('catalog_product_entity')],
- 'e.entity_id = quote_items.product_id',
- null
- )->joinInner(
- ['product_name' => $productAttrNameTable],
- 'product_name.entity_id = e.entity_id'
- . ' AND product_name.attribute_id = ' . $productAttrNameId
- . ' AND product_name.store_id = ' . \Magento\Store\Model\Store::DEFAULT_STORE_ID,
- ['name' => 'product_name.value']
- )->joinInner(
- ['product_price' => $productAttrPriceTable],
- "product_price.entity_id = e.entity_id AND product_price.attribute_id = {$productAttrPriceId}",
- ['price' => new \Zend_Db_Expr('product_price.value * main_table.base_to_global_rate')]
- )->joinLeft(
- ['order_items' => new \Zend_Db_Expr(sprintf('(%s)', $this->getOrdersSubSelect()))],
- 'order_items.product_id = e.entity_id',
- []
- )->columns(
- 'e.*'
- )->columns(
- ['carts' => new \Zend_Db_Expr('COUNT(quote_items.item_id)')]
- )->columns(
- 'order_items.orders'
- )->where(
- 'main_table.is_active = ?',
- 1
- )->group(
- 'quote_items.product_id'
- );
+ $quoteItemsSelect = $this->getSelect();
+ $quoteItemsSelect->reset()
+ ->from(['main_table' => $this->getTable('quote')], '')
+ ->columns('quote_items.product_id')
+ ->columns(['carts' => new \Zend_Db_Expr('COUNT(quote_items.item_id)')])
+ ->columns('main_table.base_to_global_rate')
+ ->joinInner(
+ ['quote_items' => $this->getTable('quote_item')],
+ 'quote_items.quote_id = main_table.entity_id',
+ null
+ )->where(
+ 'main_table.is_active = ?',
+ 1
+ )->group(
+ 'quote_items.product_id'
+ );
- return $this;
+ return $quoteItemsSelect;
}
/**
- * Orders quantity subselect
+ * Orders quantity data
*
- * @return \Magento\Framework\DB\Select
+ * @param array $productIds
+ * @return array
*/
- protected function getOrdersSubSelect()
+ protected function getOrdersData(array $productIds)
{
- $ordersSubSelect = clone $this->getSelect();
+ $ordersSubSelect = clone $this->orderResource->getSelect();
$ordersSubSelect->reset()->from(
['oi' => $this->getTable('sales_order_item')],
- ['orders' => new \Zend_Db_Expr('COUNT(1)'), 'product_id']
- )->group(
+ ['product_id', 'orders' => new \Zend_Db_Expr('COUNT(1)')]
+ )->where('oi.product_id IN (?)', $productIds)->group(
'oi.product_id'
);
- return $ordersSubSelect;
+ return $this->orderResource->getConnection()->fetchAssoc($ordersSubSelect);
}
/**
@@ -211,7 +195,7 @@ public function addStoreFilter($storeIds)
*/
public function addCustomerData($filter = null)
{
- $customersSelect = $this->_customerResource->getReadConnection()->select();
+ $customersSelect = $this->customerResource->getReadConnection()->select();
$customersSelect->from(['customer' => 'customer_entity'], 'entity_id');
if (isset($filter['customer_name'])) {
$customersSelect = $this->getCustomerNames($customersSelect);
@@ -223,7 +207,7 @@ public function addCustomerData($filter = null)
if (isset($filter['email'])) {
$customersSelect->where('customer.email LIKE ?', '%' . $filter['email'] . '%');
}
- $filteredCustomers = $this->_customerResource->getReadConnection()->fetchCol($customersSelect);
+ $filteredCustomers = $this->customerResource->getReadConnection()->fetchCol($customersSelect);
$this->getSelect()->where('main_table.customer_id IN (?)', $filteredCustomers);
return $this;
}
@@ -270,24 +254,14 @@ public function addSubtotal($storeIds = '', $filter = null)
/**
* Get select count sql
*
- * @return string
+ * @return \Magento\Framework\DB\Select
*/
public function getSelectCountSql()
{
- $countSelect = clone $this->getSelect();
- $countSelect->reset(\Zend_Db_Select::ORDER);
- $countSelect->reset(\Zend_Db_Select::LIMIT_COUNT);
- $countSelect->reset(\Zend_Db_Select::LIMIT_OFFSET);
- $countSelect->reset(\Zend_Db_Select::COLUMNS);
- $countSelect->reset(\Zend_Db_Select::GROUP);
- $countSelect->resetJoinLeft();
-
- if ($this->_selectCountSqlType == self::SELECT_COUNT_SQL_TYPE_CART) {
- $countSelect->columns("COUNT(DISTINCT e.entity_id)");
- } else {
- $countSelect->columns("COUNT(DISTINCT main_table.entity_id)");
- }
-
+ $countSelect = clone $this->prepareActiveCartItems();
+ $countSelect->reset(\Zend_Db_Select::COLUMNS)
+ ->reset(\Zend_Db_Select::GROUP)
+ ->columns('COUNT(DISTINCT quote_items.product_id)');
return $countSelect;
}
@@ -297,10 +271,10 @@ public function getSelectCountSql()
*/
protected function getCustomerNames($select)
{
- $attrFirstname = $this->_customerResource->getAttribute('firstname');
+ $attrFirstname = $this->customerResource->getAttribute('firstname');
$attrFirstnameId = (int)$attrFirstname->getAttributeId();
$attrFirstnameTableName = $attrFirstname->getBackend()->getTable();
- $attrLastname = $this->_customerResource->getAttribute('lastname');
+ $attrLastname = $this->customerResource->getAttribute('lastname');
$attrLastnameId = (int)$attrLastname->getAttributeId();
$attrLastnameTableName = $attrLastname->getBackend()->getTable();
$select->joinInner(
@@ -326,7 +300,7 @@ protected function getCustomerNames($select)
*/
public function resolveCustomerNames()
{
- $select = $this->_customerResource->getReadConnection()->select();
+ $select = $this->customerResource->getReadConnection()->select();
$customerName = $select->getAdapter()->getConcatSql(['cust_fname.value', 'cust_lname.value'], ' ');
$select->from(
@@ -343,4 +317,69 @@ public function resolveCustomerNames()
next($customersData);
}
}
+
+ /**
+ * Separate query for product and order data
+ *
+ * @param array $productIds
+ * @return array
+ * @throws \Magento\Eav\Exception
+ */
+ protected function getProductData(array $productIds)
+ {
+ $productConnection = $this->productResource->getConnection('read');
+ $productAttrName = $this->productResource->getAttribute('name');
+ $productAttrNameId = (int)$productAttrName->getAttributeId();
+ $productAttrPrice = $this->productResource->getAttribute('price');
+ $productAttrPriceId = (int)$productAttrPrice->getAttributeId();
+
+ $select = clone $this->productResource->getSelect();
+ $select->reset();
+ $select->from(
+ ['main_table' => $this->getTable('catalog_product_entity')]
+ )->useStraightJoin(
+ true
+ )->joinInner(
+ ['product_name' => $productAttrName->getBackend()->getTable()],
+ 'product_name.entity_id = main_table.entity_id'
+ . ' AND product_name.attribute_id = ' . $productAttrNameId
+ . ' AND product_name.store_id = ' . \Magento\Store\Model\Store::DEFAULT_STORE_ID,
+ ['name' => 'product_name.value']
+ )->joinInner(
+ ['product_price' => $productAttrPrice->getBackend()->getTable()],
+ "product_price.entity_id = main_table.entity_id AND product_price.attribute_id = {$productAttrPriceId}",
+ ['price' => new \Zend_Db_Expr('product_price.value')]
+ )->where('main_table.entity_id IN (?)', $productIds);
+
+ $productData = $productConnection->fetchAssoc($select);
+ return $productData;
+ }
+
+ /**
+ * Add data fetched from another database
+ *
+ * @return $this
+ */
+ protected function _afterLoad()
+ {
+ parent::_afterLoad();
+ $items = $this->getItems();
+ $productIds = [];
+ foreach ($items as $item) {
+ $productIds[] = $item->getProductId();
+ }
+ $productData = $this->getProductData($productIds);
+ $orderData = $this->getOrdersData($productIds);
+ foreach ($items as $item) {
+ $item->setId($item->getProductId());
+ $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate());
+ $item->setName($productData[$item->getProductId()]['name']);
+ $item->setOrders(0);
+ if (isset($orderData[$item->getProductId()])) {
+ $item->setOrders($orderData[$item->getProductId()]['orders']);
+ }
+ }
+
+ return $this;
+ }
}
diff --git a/app/code/Magento/Reports/Setup/InstallSchema.php b/app/code/Magento/Reports/Setup/InstallSchema.php
index bea0fc3cb2e67..707597f5a747a 100644
--- a/app/code/Magento/Reports/Setup/InstallSchema.php
+++ b/app/code/Magento/Reports/Setup/InstallSchema.php
@@ -111,7 +111,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -124,7 +123,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -132,8 +130,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Reports Compared Product Index Table');
$installer->getConnection()->createTable($table);
@@ -222,7 +219,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -235,7 +231,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -243,8 +238,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Reports Viewed Product Index Table');
$installer->getConnection()->createTable($table);
@@ -357,7 +351,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -365,7 +358,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'event_type_id',
$installer->getTable('report_event_types'),
'event_type_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Reports Event Table');
@@ -452,7 +444,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -465,7 +456,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -473,8 +463,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Reports Compared Product Index Table');
$installer->getConnection()->createTable($table);
@@ -556,7 +545,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -569,7 +557,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -577,8 +564,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Reports Viewed Product Index Table');
$installer->getConnection()->createTable($table);
@@ -667,7 +653,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -680,7 +665,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Most Viewed Products Aggregated Daily');
@@ -769,7 +753,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -782,7 +765,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Most Viewed Products Aggregated Monthly');
@@ -871,7 +853,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -884,7 +865,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Most Viewed Products Aggregated Yearly');
diff --git a/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php
new file mode 100644
index 0000000000000..d3b7eadd6da68
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Unit/Model/Resource/Report/Quote/CollectionTest.php
@@ -0,0 +1,154 @@
+objectManager = new ObjectManager($this);
+ $this->selectMock = $this->getMock('\Magento\Framework\DB\Select', [], [], '', false);
+ }
+
+ public function testGetSelectCountSql()
+ {
+ /** @var $collection \PHPUnit_Framework_MockObject_MockObject */
+ $constructArgs = $this->objectManager
+ ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Collection');
+ $collection = $this->getMock(
+ 'Magento\Reports\Model\Resource\Quote\Collection',
+ ['prepareActiveCartItems', 'getSelect'],
+ $constructArgs,
+ '',
+ false
+ );
+
+ $collection->expects($this->once())->method('prepareActiveCartItems')->willReturn($this->selectMock);
+ $this->selectMock->expects($this->atLeastOnce())->method('reset')->willReturnSelf();
+ $this->selectMock->expects($this->once())
+ ->method('columns')
+ ->with('COUNT(DISTINCT quote_items.product_id)')
+ ->willReturnSelf();
+ $this->assertEquals($this->selectMock, $collection->getSelectCountSql());
+ }
+
+ public function testPrepareActiveCartItems()
+ {
+ /** @var $collection \PHPUnit_Framework_MockObject_MockObject */
+ $constructArgs = $this->objectManager
+ ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Collection');
+ $collection = $this->getMock(
+ 'Magento\Reports\Model\Resource\Quote\Collection',
+ ['getSelect', 'getTable'],
+ $constructArgs,
+ '',
+ false
+ );
+
+ $collection->expects($this->once())->method('getSelect')->willReturn($this->selectMock);
+ $this->selectMock->expects($this->once())->method('reset')->willReturnSelf();
+ $this->selectMock->expects($this->once())->method('from')->willReturnSelf();
+ $this->selectMock->expects($this->atLeastOnce())->method('columns')->willReturnSelf();
+ $this->selectMock->expects($this->once())->method('joinInner')->willReturnSelf();
+ $this->selectMock->expects($this->once())->method('where')->willReturnSelf();
+ $this->selectMock->expects($this->once())->method('group')->willReturnSelf();
+ $collection->expects($this->exactly(2))->method('getTable')->willReturn('table');
+ $collection->prepareActiveCartItems();
+ }
+
+ public function testLoadWithFilter()
+ {
+ /** @var $collection \PHPUnit_Framework_MockObject_MockObject */
+ $constructArgs = $this->objectManager
+ ->getConstructArguments('Magento\Reports\Model\Resource\Quote\Collection');
+ $constructArgs['eventManager'] = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false);
+ $readConnectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false);
+ $resourceMock = $this->getMock('\Magento\Quote\Model\Resource\Quote', [], [], '', false);
+ $constructArgs['resource'] = $resourceMock;
+ $productResourceMock = $this->getMock('\Magento\Catalog\Model\Resource\Product\Collection', [], [], '', false);
+ $constructArgs['productResource'] = $productResourceMock;
+ $orderResourceMock = $this->getMock('\Magento\Sales\Model\Resource\Order\Collection', [], [], '', false);
+ $constructArgs['orderResource'] = $orderResourceMock;
+
+ $collection = $this->getMock(
+ 'Magento\Reports\Model\Resource\Quote\Collection',
+ [
+ '_beforeLoad',
+ '_renderFilters',
+ '_renderOrders',
+ '_renderLimit',
+ 'printLogQuery',
+ 'getData',
+ '_setIsLoaded',
+ 'setConnection',
+ '_initSelect',
+ 'getTable',
+ 'getItems',
+ 'getOrdersData',
+ ],
+ $constructArgs
+ );
+ //load()
+ $collection->expects($this->once())->method('_beforeLoad')->willReturnSelf();
+ $collection->expects($this->once())->method('_renderFilters')->willReturnSelf();
+ $collection->expects($this->once())->method('_renderOrders')->willReturnSelf();
+ $collection->expects($this->once())->method('_renderLimit')->willReturnSelf();
+ $collection->expects($this->once())->method('printLogQuery')->willReturnSelf();
+ $collection->expects($this->once())->method('getData')->willReturn(null);
+ $collection->expects($this->once())->method('_setIsLoaded')->willReturnSelf();
+
+ //productLoad()
+ $productAttributeMock = $this->getMock(
+ '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute',
+ [],
+ [],
+ '',
+ false
+ );
+ $priceAttributeMock = $this->getMock(
+ '\Magento\Eav\Model\Entity\Attribute\AbstractAttribute',
+ [],
+ [],
+ '',
+ false
+ );
+ $productResourceMock->expects($this->once())
+ ->method('getConnection')
+ ->with('read')
+ ->willReturn($readConnectionMock);
+ $productResourceMock->expects($this->any())
+ ->method('getAttribute')
+ ->willReturnMap([['name', $productAttributeMock], ['price', $priceAttributeMock]]);
+ $productResourceMock->expects($this->once())->method('getSelect')->willReturn($this->selectMock);
+ $this->selectMock->expects($this->once())->method('reset')->willReturnSelf();
+ $this->selectMock->expects($this->once())->method('from')->willReturnSelf();
+ $this->selectMock->expects($this->once())->method('useStraightJoin')->willReturnSelf();
+ $this->selectMock->expects($this->exactly(2))->method('joinInner')->willReturnSelf();
+ $collection->expects($this->once())->method('getOrdersData')->willReturn([]);
+
+ $productAttributeMock->expects($this->once())->method('getBackend')->willReturnSelf();
+ $priceAttributeMock->expects($this->once())->method('getBackend')->willReturnSelf();
+ $readConnectionMock->expects($this->once())->method('fetchAssoc')->willReturn([1, 2, 3]);
+
+ //_afterLoad()
+ $collection->expects($this->once())->method('getItems')->willReturn([]);
+
+ $collection->loadWithFilter();
+ }
+}
diff --git a/app/code/Magento/Review/Setup/InstallSchema.php b/app/code/Magento/Review/Setup/InstallSchema.php
index 6d5a14fe2880f..276b7389bff8f 100644
--- a/app/code/Magento/Review/Setup/InstallSchema.php
+++ b/app/code/Magento/Review/Setup/InstallSchema.php
@@ -125,7 +125,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('review_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -133,7 +132,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'status_id',
$installer->getTable('review_status'),
'status_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION,
\Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
)
->setComment('Review base information');
@@ -210,15 +208,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->addForeignKey(
$installer->getFkName('review_detail', 'review_id', 'review', 'review_id'),
'review_id',
$installer->getTable('review'),
'review_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -226,8 +222,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)
->setComment('Review detail information');
$installer->getConnection()->createTable($table);
@@ -288,7 +283,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Review aggregates');
@@ -322,7 +316,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'review_id',
$installer->getTable('review'),
'review_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -330,7 +323,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Review Store');
@@ -425,7 +417,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('rating_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Ratings');
@@ -480,7 +471,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rating_id',
$installer->getTable('rating'),
'rating_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Rating options');
@@ -570,7 +560,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'option_id',
$installer->getTable('rating_option'),
'option_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -578,7 +567,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'review_id',
$installer->getTable('review'),
'review_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Rating option values');
@@ -658,7 +646,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rating_id',
$installer->getTable('rating'),
'rating_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -666,7 +653,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Rating vote aggregated');
@@ -700,7 +686,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -708,8 +693,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rating_id',
$installer->getTable('rating'),
'rating_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Rating Store');
$installer->getConnection()->createTable($table);
@@ -749,7 +733,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rating_id',
$installer->getTable('rating'),
'rating_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->addForeignKey(
@@ -757,7 +740,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Rating Title');
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php
index 63b1f9055bdd1..832aed45797e9 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php
@@ -6,7 +6,7 @@
namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo;
use Magento\Backend\App\Action;
-use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender;
+use Magento\Sales\Model\Order\Email\Sender\CreditmemoCommentSender;
class AddComment extends \Magento\Backend\App\Action
{
@@ -16,9 +16,9 @@ class AddComment extends \Magento\Backend\App\Action
protected $creditmemoLoader;
/**
- * @var CreditmemoSender
+ * @var CreditmemoCommentSender
*/
- protected $creditmemoSender;
+ protected $creditmemoCommentSender;
/**
* @var \Magento\Framework\View\Result\PageFactory
@@ -38,7 +38,7 @@ class AddComment extends \Magento\Backend\App\Action
/**
* @param Action\Context $context
* @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader
- * @param CreditmemoSender $creditmemoSender
+ * @param CreditmemoCommentSender $creditmemoCommentSender
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
@@ -46,13 +46,13 @@ class AddComment extends \Magento\Backend\App\Action
public function __construct(
Action\Context $context,
\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader,
- CreditmemoSender $creditmemoSender,
+ CreditmemoCommentSender $creditmemoCommentSender,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
\Magento\Framework\Controller\Result\RawFactory $resultRawFactory
) {
$this->creditmemoLoader = $creditmemoLoader;
- $this->creditmemoSender = $creditmemoSender;
+ $this->creditmemoCommentSender = $creditmemoCommentSender;
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
$this->resultRawFactory = $resultRawFactory;
@@ -94,7 +94,7 @@ public function execute()
);
$comment->save();
- $this->creditmemoSender->send($creditmemo, !empty($data['is_customer_notified']), $data['comment']);
+ $this->creditmemoCommentSender->send($creditmemo, !empty($data['is_customer_notified']), $data['comment']);
$resultPage = $this->resultPageFactory->create();
$response = $resultPage->getLayout()->getBlock('creditmemo_comments')->toHtml();
} catch (\Magento\Framework\Exception\LocalizedException $e) {
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php
index 6ba3acd497b1f..dbbd9dd55e33e 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php
@@ -81,16 +81,15 @@ public function execute()
);
}
- $comment = '';
if (!empty($data['comment_text'])) {
$creditmemo->addComment(
$data['comment_text'],
isset($data['comment_customer_notify']),
isset($data['is_visible_on_front'])
);
- if (isset($data['comment_customer_notify'])) {
- $comment = $data['comment_text'];
- }
+
+ $creditmemo->setCustomerNote($data['comment_text']);
+ $creditmemo->setCustomerNoteNotify(isset($data['comment_customer_notify']));
}
if (isset($data['do_refund'])) {
@@ -107,9 +106,6 @@ public function execute()
}
$creditmemo->register();
- if (!empty($data['send_email'])) {
- $creditmemo->setEmailSent(true);
- }
$creditmemo->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
$transactionSave = $this->_objectManager->create(
@@ -123,7 +119,10 @@ public function execute()
$transactionSave->addObject($creditmemo->getInvoice());
}
$transactionSave->save();
- $this->creditmemoSender->send($creditmemo, !empty($data['send_email']), $comment);
+
+ if (!empty($data['send_email'])) {
+ $this->creditmemoSender->send($creditmemo);
+ }
$this->messageManager->addSuccess(__('You created the credit memo.'));
$this->_getSession()->getCommentText(true);
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
index 1fffaf8a03ee1..3758ad060f0dc 100755
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
@@ -9,7 +9,7 @@
use Magento\Backend\App\Action;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
-use Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender;
+use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Sales\Model\Order\Email\Sender\ShipmentSender;
use Magento\Sales\Model\Order\Invoice;
@@ -19,9 +19,9 @@
class Save extends \Magento\Backend\App\Action
{
/**
- * @var InvoiceCommentSender
+ * @var InvoiceSender
*/
- protected $invoiceCommentSender;
+ protected $invoiceSender;
/**
* @var ShipmentSender
@@ -36,17 +36,17 @@ class Save extends \Magento\Backend\App\Action
/**
* @param Action\Context $context
* @param Registry $registry
- * @param InvoiceCommentSender $invoiceCommentSender
+ * @param InvoiceSender $invoiceSender
* @param ShipmentSender $shipmentSender
*/
public function __construct(
Action\Context $context,
Registry $registry,
- InvoiceCommentSender $invoiceCommentSender,
+ InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender
) {
$this->registry = $registry;
- $this->invoiceCommentSender = $invoiceCommentSender;
+ $this->invoiceSender = $invoiceSender;
$this->shipmentSender = $shipmentSender;
parent::__construct($context);
}
@@ -153,14 +153,13 @@ public function execute()
isset($data['comment_customer_notify']),
isset($data['is_visible_on_front'])
);
+
+ $invoice->setCustomerNote($data['comment_text']);
+ $invoice->setCustomerNoteNotify(isset($data['comment_customer_notify']));
}
$invoice->register();
- if (!empty($data['send_email'])) {
- $invoice->setEmailSent(true);
- }
-
$invoice->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
$invoice->getOrder()->setIsInProcess(true);
@@ -175,7 +174,6 @@ public function execute()
if (!empty($data['do_shipment']) || (int)$invoice->getOrder()->getForcedShipmentWithInvoice()) {
$shipment = $this->_prepareShipment($invoice);
if ($shipment) {
- $shipment->setEmailSent($invoice->getEmailSent());
$transactionSave->addObject($shipment);
}
}
@@ -195,19 +193,19 @@ public function execute()
}
// send invoice/shipment emails
- $comment = '';
- if (isset($data['comment_customer_notify'])) {
- $comment = $data['comment_text'];
- }
try {
- $this->invoiceCommentSender->send($invoice, !empty($data['send_email']), $comment);
+ if (!empty($data['send_email'])) {
+ $this->invoiceSender->send($invoice);
+ }
} catch (\Exception $e) {
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
$this->messageManager->addError(__('We can\'t send the invoice email.'));
}
if ($shipment) {
try {
- $this->shipmentSender->send($shipment, !empty($data['send_email']));
+ if (!empty($data['send_email'])) {
+ $this->shipmentSender->send($shipment);
+ }
} catch (\Exception $e) {
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
$this->messageManager->addError(__('We can\'t send the shipment.'));
diff --git a/app/code/Magento/Sales/Model/Config/Backend/Email/AsyncSending.php b/app/code/Magento/Sales/Model/Config/Backend/Email/AsyncSending.php
new file mode 100644
index 0000000000000..b872e5b9de289
--- /dev/null
+++ b/app/code/Magento/Sales/Model/Config/Backend/Email/AsyncSending.php
@@ -0,0 +1,38 @@
+isValueChanged()) {
+ $state = $this->getValue() ? 'enabled' : 'disabled';
+
+ $this->_eventManager->dispatch(
+ $this->_eventPrefix . '_sales_email_general_async_sending_' . $state,
+ $this->_getEventData()
+ );
+ }
+
+ return $this;
+ }
+}
diff --git a/app/code/Magento/Sales/Model/Observer/SendEmails.php b/app/code/Magento/Sales/Model/Observer/SendEmails.php
new file mode 100644
index 0000000000000..b8c8d00cddb52
--- /dev/null
+++ b/app/code/Magento/Sales/Model/Observer/SendEmails.php
@@ -0,0 +1,91 @@
+emailSender = $emailSender;
+ $this->entityResource = $entityResource;
+ $this->entityCollection = $entityCollection;
+ $this->globalConfig = $globalConfig;
+ }
+
+ /**
+ * Handles asynchronous email sending during corresponding
+ * cron job.
+ *
+ * Also method is used in the next events:
+ *
+ * - config_data_sales_email_general_async_sending_disabled
+ *
+ * Works only if asynchronous email sending is enabled
+ * in global settings.
+ *
+ * @return void
+ */
+ public function execute()
+ {
+ if ($this->globalConfig->getValue('sales_email/general/async_sending')) {
+ $this->entityCollection->addFieldToFilter('send_email', ['eq' => 1]);
+ $this->entityCollection->addFieldToFilter('email_sent', ['null' => true]);
+
+ /** @var \Magento\Sales\Model\AbstractModel $item */
+ foreach ($this->entityCollection->getItems() as $item) {
+ if ($this->emailSender->send($item, true)) {
+ $this->entityResource->save(
+ $item->setEmailSent(true)
+ );
+ }
+ }
+ }
+ }
+}
diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php
index 667678cc71d24..517a40fe28ed1 100644
--- a/app/code/Magento/Sales/Model/Order.php
+++ b/app/code/Magento/Sales/Model/Order.php
@@ -45,6 +45,7 @@
* @method bool hasForcedCanCreditmemo()
* @method bool getIsInProcess()
* @method \Magento\Customer\Model\Customer getCustomer()
+ * @method \Magento\Sales\Model\Order setSendEmail(bool $value)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php
index ec5829dc30e18..9e77f5afd8635 100644
--- a/app/code/Magento/Sales/Model/Order/Creditmemo.php
+++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php
@@ -21,6 +21,11 @@
* @method \Magento\Sales\Model\Resource\Order\Creditmemo _getResource()
* @method \Magento\Sales\Model\Resource\Order\Creditmemo getResource()
* @method \Magento\Sales\Model\Order\Creditmemo setCreatedAt(string $value)
+ * @method \Magento\Sales\Model\Order\Invoice setSendEmail(bool $value)
+ * @method \Magento\Sales\Model\Order\Invoice setCustomerNote(string $value)
+ * @method string getCustomerNote()
+ * @method \Magento\Sales\Model\Order\Invoice setCustomerNoteNotify(bool $value)
+ * @method bool getCustomerNoteNotify()
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php
index 50441777e01ca..e476e5ec8b544 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php
@@ -10,7 +10,7 @@
use Magento\Sales\Model\Order\Creditmemo;
use Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity;
use Magento\Sales\Model\Order\Email\Container\Template;
-use Magento\Sales\Model\Order\Email\NotifySender;
+use Magento\Sales\Model\Order\Email\Sender;
use Magento\Sales\Model\Resource\Order\Creditmemo as CreditmemoResource;
use Magento\Sales\Model\Order\Address\Renderer;
@@ -19,7 +19,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreditmemoSender extends NotifySender
+class CreditmemoSender extends Sender
{
/**
* @var PaymentHelper
@@ -32,14 +32,16 @@ class CreditmemoSender extends NotifySender
protected $creditmemoResource;
/**
- * @var Renderer
+ * Global configuration storage.
+ *
+ * @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
- protected $addressRenderer;
+ protected $globalConfig;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var Renderer
*/
- protected $loggerMock;
+ protected $addressRenderer;
/**
* @param Template $templateContainer
@@ -48,6 +50,7 @@ class CreditmemoSender extends NotifySender
* @param \Psr\Log\LoggerInterface $logger
* @param PaymentHelper $paymentHelper
* @param CreditmemoResource $creditmemoResource
+ * @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig
* @param Renderer $addressRenderer
*/
public function __construct(
@@ -57,50 +60,71 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
PaymentHelper $paymentHelper,
CreditmemoResource $creditmemoResource,
+ \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig,
Renderer $addressRenderer
) {
parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory, $logger);
$this->paymentHelper = $paymentHelper;
$this->creditmemoResource = $creditmemoResource;
+ $this->globalConfig = $globalConfig;
$this->addressRenderer = $addressRenderer;
}
/**
- * Send email to customer
+ * Sends order creditmemo email to the customer.
+ *
+ * Email will be sent immediately in two cases:
+ *
+ * - if asynchronous email sending is disabled in global settings
+ * - if $forceSyncMode parameter is set to TRUE
+ *
+ * Otherwise, email will be sent later during running of
+ * corresponding cron job.
*
* @param Creditmemo $creditmemo
- * @param bool $notify
- * @param string $comment
+ * @param bool $forceSyncMode
* @return bool
*/
- public function send(Creditmemo $creditmemo, $notify = true, $comment = '')
+ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
{
- $order = $creditmemo->getOrder();
- if ($order->getShippingAddress()) {
- $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
- } else {
- $formattedShippingAddress = '';
- }
- $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
- $this->templateContainer->setTemplateVars(
- [
- 'order' => $creditmemo->getOrder(),
- 'creditmemo' => $creditmemo,
- 'comment' => $comment,
- 'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
- 'store' => $order->getStore(),
- 'formattedShippingAddress' => $formattedShippingAddress,
- 'formattedBillingAddress' => $formattedBillingAddress,
- ]
- );
+ $creditmemo->setSendEmail(true);
+
+ if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
+ $order = $creditmemo->getOrder();
+
+ if ($order->getShippingAddress()) {
+ $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
+ } else {
+ $formattedShippingAddress = '';
+ }
+
+ $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
+
+ $this->templateContainer->setTemplateVars(
+ [
+ 'order' => $order,
+ 'creditmemo' => $creditmemo,
+ 'comment' => $creditmemo->getCustomerNoteNotify() ? $creditmemo->getCustomerNote() : '',
+ 'billing' => $order->getBillingAddress(),
+ 'payment_html' => $this->getPaymentHtml($order),
+ 'store' => $order->getStore(),
+ 'formattedShippingAddress' => $formattedShippingAddress,
+ 'formattedBillingAddress' => $formattedBillingAddress,
+ ]
+ );
- $result = $this->checkAndSend($order, $notify);
- if ($result) {
- $creditmemo->setEmailSent(true);
- $this->creditmemoResource->saveAttribute($creditmemo, 'email_sent');
+ if ($this->checkAndSend($order)) {
+ $creditmemo->setEmailSent(true);
+
+ $this->creditmemoResource->saveAttribute($creditmemo, ['send_email', 'email_sent']);
+
+ return true;
+ }
}
- return $result;
+
+ $this->creditmemoResource->saveAttribute($creditmemo, 'send_email');
+
+ return false;
}
/**
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php
index b26d038222bd8..0796ff0443b19 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php
@@ -9,15 +9,17 @@
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Email\Container\InvoiceIdentity;
use Magento\Sales\Model\Order\Email\Container\Template;
-use Magento\Sales\Model\Order\Email\NotifySender;
+use Magento\Sales\Model\Order\Email\Sender;
use Magento\Sales\Model\Order\Invoice;
use Magento\Sales\Model\Resource\Order\Invoice as InvoiceResource;
use Magento\Sales\Model\Order\Address\Renderer;
/**
* Class InvoiceSender
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class InvoiceSender extends NotifySender
+class InvoiceSender extends Sender
{
/**
* @var PaymentHelper
@@ -29,6 +31,13 @@ class InvoiceSender extends NotifySender
*/
protected $invoiceResource;
+ /**
+ * Global configuration storage.
+ *
+ * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ */
+ protected $globalConfig;
+
/**
* @var Renderer
*/
@@ -41,6 +50,7 @@ class InvoiceSender extends NotifySender
* @param \Psr\Log\LoggerInterface $logger
* @param PaymentHelper $paymentHelper
* @param InvoiceResource $invoiceResource
+ * @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig
* @param Renderer $addressRenderer
*/
public function __construct(
@@ -50,49 +60,70 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
PaymentHelper $paymentHelper,
InvoiceResource $invoiceResource,
+ \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig,
Renderer $addressRenderer
) {
parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory, $logger);
$this->paymentHelper = $paymentHelper;
$this->invoiceResource = $invoiceResource;
+ $this->globalConfig = $globalConfig;
$this->addressRenderer = $addressRenderer;
}
/**
- * Send email to customer
+ * Sends order invoice email to the customer.
+ *
+ * Email will be sent immediately in two cases:
+ *
+ * - if asynchronous email sending is disabled in global settings
+ * - if $forceSyncMode parameter is set to TRUE
+ *
+ * Otherwise, email will be sent later during running of
+ * corresponding cron job.
*
* @param Invoice $invoice
- * @param bool $notify
- * @param string $comment
+ * @param bool $forceSyncMode
* @return bool
*/
- public function send(Invoice $invoice, $notify = true, $comment = '')
+ public function send(Invoice $invoice, $forceSyncMode = false)
{
- $order = $invoice->getOrder();
- if ($order->getShippingAddress()) {
- $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
- } else {
- $formattedShippingAddress = '';
- }
- $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
- $this->templateContainer->setTemplateVars(
- [
- 'order' => $order,
- 'invoice' => $invoice,
- 'comment' => $comment,
- 'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
- 'store' => $order->getStore(),
- 'formattedShippingAddress' => $formattedShippingAddress,
- 'formattedBillingAddress' => $formattedBillingAddress,
- ]
- );
- $result = $this->checkAndSend($order, $notify);
- if ($result) {
- $invoice->setEmailSent(true);
- $this->invoiceResource->saveAttribute($invoice, 'email_sent');
+ $invoice->setSendEmail(true);
+
+ if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
+ $order = $invoice->getOrder();
+
+ if ($order->getShippingAddress()) {
+ $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
+ } else {
+ $formattedShippingAddress = '';
+ }
+ $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
+
+ $this->templateContainer->setTemplateVars(
+ [
+ 'order' => $order,
+ 'invoice' => $invoice,
+ 'comment' => $invoice->getCustomerNoteNotify() ? $invoice->getCustomerNote() : '',
+ 'billing' => $order->getBillingAddress(),
+ 'payment_html' => $this->getPaymentHtml($order),
+ 'store' => $order->getStore(),
+ 'formattedShippingAddress' => $formattedShippingAddress,
+ 'formattedBillingAddress' => $formattedBillingAddress
+ ]
+ );
+
+ if ($this->checkAndSend($order)) {
+ $invoice->setEmailSent(true);
+
+ $this->invoiceResource->saveAttribute($invoice, ['send_email', 'email_sent']);
+
+ return true;
+ }
}
- return $result;
+
+ $this->invoiceResource->saveAttribute($invoice, 'send_email');
+
+ return false;
}
/**
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php
index 9388270c7db30..dc2d544d335bd 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php
@@ -28,6 +28,13 @@ class OrderSender extends Sender
*/
protected $orderResource;
+ /**
+ * Global configuration storage.
+ *
+ * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ */
+ protected $globalConfig;
+
/**
* @var Renderer
*/
@@ -40,6 +47,7 @@ class OrderSender extends Sender
* @param \Psr\Log\LoggerInterface $logger
* @param PaymentHelper $paymentHelper
* @param OrderResource $orderResource
+ * @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig
* @param Renderer $addressRenderer
*/
public function __construct(
@@ -49,28 +57,48 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
PaymentHelper $paymentHelper,
OrderResource $orderResource,
+ \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig,
Renderer $addressRenderer
) {
parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory, $logger);
$this->paymentHelper = $paymentHelper;
$this->orderResource = $orderResource;
+ $this->globalConfig = $globalConfig;
$this->addressRenderer = $addressRenderer;
}
/**
- * Send email to customer
+ * Sends order email to the customer.
+ *
+ * Email will be sent immediately in two cases:
+ *
+ * - if asynchronous email sending is disabled in global settings
+ * - if $forceSyncMode parameter is set to TRUE
+ *
+ * Otherwise, email will be sent later during running of
+ * corresponding cron job.
*
* @param Order $order
+ * @param bool $forceSyncMode
* @return bool
*/
- public function send(Order $order)
+ public function send(Order $order, $forceSyncMode = false)
{
- $result = $this->checkAndSend($order);
- if ($result) {
- $order->setEmailSent(true);
- $this->orderResource->saveAttribute($order, 'email_sent');
+ $order->setSendEmail(true);
+
+ if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
+ if ($this->checkAndSend($order)) {
+ $order->setEmailSent(true);
+
+ $this->orderResource->saveAttribute($order, ['send_email', 'email_sent']);
+
+ return true;
+ }
}
- return $result;
+
+ $this->orderResource->saveAttribute($order, 'send_email');
+
+ return false;
}
/**
diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php
index 811f894968358..cedd82ae34d64 100644
--- a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php
+++ b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php
@@ -9,15 +9,17 @@
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Email\Container\ShipmentIdentity;
use Magento\Sales\Model\Order\Email\Container\Template;
-use Magento\Sales\Model\Order\Email\NotifySender;
+use Magento\Sales\Model\Order\Email\Sender;
use Magento\Sales\Model\Order\Shipment;
use Magento\Sales\Model\Resource\Order\Shipment as ShipmentResource;
use Magento\Sales\Model\Order\Address\Renderer;
/**
* Class ShipmentSender
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class ShipmentSender extends NotifySender
+class ShipmentSender extends Sender
{
/**
* @var PaymentHelper
@@ -29,6 +31,13 @@ class ShipmentSender extends NotifySender
*/
protected $shipmentResource;
+ /**
+ * Global configuration storage.
+ *
+ * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ */
+ protected $globalConfig;
+
/**
* @var Renderer
*/
@@ -41,6 +50,7 @@ class ShipmentSender extends NotifySender
* @param \Psr\Log\LoggerInterface $logger
* @param PaymentHelper $paymentHelper
* @param ShipmentResource $shipmentResource
+ * @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig
* @param Renderer $addressRenderer
*/
public function __construct(
@@ -50,49 +60,70 @@ public function __construct(
\Psr\Log\LoggerInterface $logger,
PaymentHelper $paymentHelper,
ShipmentResource $shipmentResource,
+ \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig,
Renderer $addressRenderer
) {
parent::__construct($templateContainer, $identityContainer, $senderBuilderFactory, $logger);
$this->paymentHelper = $paymentHelper;
$this->shipmentResource = $shipmentResource;
+ $this->globalConfig = $globalConfig;
$this->addressRenderer = $addressRenderer;
}
/**
- * Send email to customer
+ * Sends order shipment email to the customer.
+ *
+ * Email will be sent immediately in two cases:
+ *
+ * - if asynchronous email sending is disabled in global settings
+ * - if $forceSyncMode parameter is set to TRUE
+ *
+ * Otherwise, email will be sent later during running of
+ * corresponding cron job.
*
* @param Shipment $shipment
- * @param bool $notify
- * @param string $comment
+ * @param bool $forceSyncMode
* @return bool
*/
- public function send(Shipment $shipment, $notify = true, $comment = '')
+ public function send(Shipment $shipment, $forceSyncMode = false)
{
- $order = $shipment->getOrder();
- if ($order->getShippingAddress()) {
- $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
- } else {
- $formattedShippingAddress = '';
- }
- $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
- $this->templateContainer->setTemplateVars(
- [
- 'order' => $order,
- 'shipment' => $shipment,
- 'comment' => $comment,
- 'billing' => $order->getBillingAddress(),
- 'payment_html' => $this->getPaymentHtml($order),
- 'store' => $order->getStore(),
- 'formattedShippingAddress' => $formattedShippingAddress,
- 'formattedBillingAddress' => $formattedBillingAddress,
- ]
- );
- $result = $this->checkAndSend($order, $notify);
- if ($result) {
- $shipment->setEmailSent(true);
- $this->shipmentResource->saveAttribute($shipment, 'email_sent');
+ $shipment->setSendEmail(true);
+
+ if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
+ $order = $shipment->getOrder();
+
+ if ($order->getShippingAddress()) {
+ $formattedShippingAddress = $this->addressRenderer->format($order->getShippingAddress(), 'html');
+ } else {
+ $formattedShippingAddress = '';
+ }
+ $formattedBillingAddress = $this->addressRenderer->format($order->getBillingAddress(), 'html');
+
+ $this->templateContainer->setTemplateVars(
+ [
+ 'order' => $order,
+ 'shipment' => $shipment,
+ 'comment' => $shipment->getCustomerNoteNotify() ? $shipment->getCustomerNote() : '',
+ 'billing' => $order->getBillingAddress(),
+ 'payment_html' => $this->getPaymentHtml($order),
+ 'store' => $order->getStore(),
+ 'formattedShippingAddress' => $formattedShippingAddress,
+ 'formattedBillingAddress' => $formattedBillingAddress
+ ]
+ );
+
+ if ($this->checkAndSend($order)) {
+ $shipment->setEmailSent(true);
+
+ $this->shipmentResource->saveAttribute($shipment, ['send_email', 'email_sent']);
+
+ return true;
+ }
}
- return $result;
+
+ $this->shipmentResource->saveAttribute($shipment, 'send_email');
+
+ return false;
}
/**
diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php
index d88dfa1d8850a..8317b7041d61f 100644
--- a/app/code/Magento/Sales/Model/Order/Invoice.php
+++ b/app/code/Magento/Sales/Model/Order/Invoice.php
@@ -12,6 +12,11 @@
/**
* @method \Magento\Sales\Model\Order\Invoice setCreatedAt(string $value)
+ * @method \Magento\Sales\Model\Order\Invoice setSendEmail(bool $value)
+ * @method \Magento\Sales\Model\Order\Invoice setCustomerNote(string $value)
+ * @method string getCustomerNote()
+ * @method \Magento\Sales\Model\Order\Invoice setCustomerNoteNotify(bool $value)
+ * @method bool getCustomerNoteNotify()
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php
index ec3a0561cf262..3472e9663ad33 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment.php
@@ -16,6 +16,11 @@
* @method \Magento\Sales\Model\Resource\Order\Shipment _getResource()
* @method \Magento\Sales\Model\Resource\Order\Shipment getResource()
* @method \Magento\Sales\Model\Order\Shipment setCreatedAt(string $value)
+ * @method \Magento\Sales\Model\Order\Invoice setSendEmail(bool $value)
+ * @method \Magento\Sales\Model\Order\Invoice setCustomerNote(string $value)
+ * @method string getCustomerNote()
+ * @method \Magento\Sales\Model\Order\Invoice setCustomerNoteNotify(bool $value)
+ * @method bool getCustomerNoteNotify()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
*/
diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php
index e4c43d8767677..fd517941e38a0 100644
--- a/app/code/Magento/Sales/Setup/InstallSchema.php
+++ b/app/code/Magento/Sales/Setup/InstallSchema.php
@@ -876,15 +876,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \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,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Order'
);
@@ -1037,22 +1035,19 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->addForeignKey(
$installer->getFkName('sales_order_grid', 'entity_id', 'sales_order', 'entity_id'),
'entity_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('sales_order_grid', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Order Grid'
);
@@ -1197,7 +1192,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'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 Address'
@@ -1699,15 +1693,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'order_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Order Item'
);
@@ -2050,7 +2042,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'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 Payment'
@@ -2180,15 +2171,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'order_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Shipment'
);
@@ -2296,15 +2285,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('sales_shipment'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('sales_shipment_grid', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Shipment Grid'
);
@@ -2395,7 +2382,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_shipment'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Shipment Item'
@@ -2487,7 +2473,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_shipment'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Shipment Track'
@@ -2546,7 +2531,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_shipment'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Shipment Comment'
@@ -2850,15 +2834,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'order_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Invoice'
);
@@ -2996,15 +2978,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('sales_invoice'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('sales_invoice_grid', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Invoice Grid'
);
@@ -3173,7 +3153,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_invoice'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Invoice Item'
@@ -3232,7 +3211,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_invoice'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Invoice Comment'
@@ -3560,15 +3538,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'order_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Creditmemo'
);
@@ -3748,15 +3724,13 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
$installer->getTable('sales_creditmemo'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('sales_creditmemo_grid', 'store_id', 'store', 'store_id'),
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Flat Creditmemo Grid'
);
@@ -3925,7 +3899,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_creditmemo'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Creditmemo Item'
@@ -3984,7 +3957,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_creditmemo'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Flat Creditmemo Comment'
@@ -4066,8 +4038,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Invoiced Aggregated'
);
@@ -4148,8 +4119,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Invoiced Aggregated Order'
);
@@ -4296,8 +4266,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Order Aggregated Created'
);
@@ -4394,7 +4363,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'order_id',
$installer->getTable('sales_order'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -4406,14 +4374,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'parent_id',
$installer->getTable('sales_payment_transaction'),
'transaction_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Payment Transaction'
@@ -4489,8 +4455,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Refunded Aggregated'
);
@@ -4565,8 +4530,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Refunded Aggregated Order'
);
@@ -4641,8 +4605,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Shipping Aggregated'
);
@@ -4717,8 +4680,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Sales Shipping Aggregated Order'
);
@@ -4796,7 +4758,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -4808,7 +4769,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Bestsellers Aggregated Daily'
@@ -4887,7 +4847,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -4899,7 +4858,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Bestsellers Aggregated Monthly'
@@ -4978,7 +4936,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -4990,7 +4947,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Bestsellers Aggregated Yearly'
@@ -5138,7 +5094,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'status',
$installer->getTable('sales_order_status'),
'status',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Order Status Table'
@@ -5176,14 +5131,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'status',
$installer->getTable('sales_order_status'),
'status',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Order Status Label Table'
diff --git a/app/code/Magento/Sales/Setup/UpgradeSchema.php b/app/code/Magento/Sales/Setup/UpgradeSchema.php
index b1178f1268f0d..99823503bd2e1 100644
--- a/app/code/Magento/Sales/Setup/UpgradeSchema.php
+++ b/app/code/Magento/Sales/Setup/UpgradeSchema.php
@@ -20,6 +20,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
@@ -111,6 +112,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
);
}
}
+
if (version_compare($context->getVersion(), '2.0.3') < 0) {
$dropIncrementIndexTables = [
'sales_creditmemo',
@@ -155,5 +157,79 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
);
}
}
+
+ if (version_compare($context->getVersion(), '2.0.4') < 0) {
+
+ /**
+ * Adding 'send_email' columns.
+ */
+
+ $tables = ['sales_order', 'sales_invoice', 'sales_shipment', 'sales_creditmemo'];
+
+ foreach ($tables as $table) {
+ $table = $setup->getTable($table);
+
+ $setup->getConnection()
+ ->addColumn(
+ $table,
+ 'send_email',
+ [
+ 'type' => Table::TYPE_SMALLINT,
+ 'after' => 'email_sent',
+ 'comment' => 'Send Email',
+ 'unsigned' => true
+ ]
+ );
+
+ $setup->getConnection()
+ ->addIndex($table, $setup->getIdxName($table, ['email_sent']), 'email_sent');
+
+ $setup->getConnection()
+ ->addIndex($table, $setup->getIdxName($table, ['send_email']), 'send_email');
+ }
+
+ /**
+ * Adding 'customer_note' columns.
+ */
+
+ $tables = ['sales_invoice', 'sales_shipment', 'sales_creditmemo'];
+
+ foreach ($tables as $table) {
+ $table = $setup->getTable($table);
+
+ $setup->getConnection()
+ ->addColumn(
+ $table,
+ 'customer_note',
+ [
+ 'type' => Table::TYPE_TEXT,
+ 'after' => 'updated_at',
+ 'comment' => 'Customer Note'
+ ]
+ );
+ }
+
+ /**
+ * Adding 'customer_note_notify' columns.
+ */
+
+ $tables = ['sales_invoice', 'sales_shipment', 'sales_creditmemo'];
+
+ foreach ($tables as $table) {
+ $table = $setup->getTable($table);
+
+ $setup->getConnection()
+ ->addColumn(
+ $table,
+ 'customer_note_notify',
+ [
+ 'type' => Table::TYPE_SMALLINT,
+ 'after' => 'customer_note',
+ 'comment' => 'Customer Note Notify',
+ 'unsigned' => true
+ ]
+ );
+ }
+ }
}
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php
new file mode 100644
index 0000000000000..69f3f6e0df310
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Unit/Model/Config/Backend/Email/AsyncSendingTest.php
@@ -0,0 +1,93 @@
+config = $this->getMock('Magento\Framework\App\Config', [], [], '', false);
+
+ $this->eventManager = $this->getMock('Magento\Framework\Event\Manager\Proxy', [], [], '', false);
+
+ $this->context = $this->getMock('Magento\Framework\Model\Context', ['getEventDispatcher'], [], '', false);
+ $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManager);
+
+ $this->object = $objectManager->getObject(
+ '\Magento\Sales\Model\Config\Backend\Email\AsyncSending',
+ [
+ 'config' => $this->config,
+ 'context' => $this->context
+ ]
+ );
+ }
+
+ /**
+ * @param int $value
+ * @param int $oldValue
+ * @param string $eventName
+ * @dataProvider afterSaveDataProvider
+ * @return void
+ */
+ public function testAfterSave($value, $oldValue, $eventName)
+ {
+ $path = 'sales_email/general/async_sending';
+ $scope = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT;
+
+ $this->object->setData(['value' => $value, 'path' => $path, 'scope' => $scope]);
+
+ $this->config->expects($this->once())->method('getValue')->with($path, $scope)->willReturn($oldValue);
+
+ if ($value == $oldValue) {
+ $this->eventManager->expects($this->never())->method('dispatch');
+ } else {
+ $this->eventManager->expects($this->once())->method('dispatch')->with($eventName);
+ }
+
+ $this->object->afterSave();
+ }
+
+ /**
+ * @return array
+ */
+ public function afterSaveDataProvider()
+ {
+ return [
+ [0, 0, null],
+ [1, 1, null],
+ [0, 1, 'config_data_sales_email_general_async_sending_disabled'],
+ [1, 0, 'config_data_sales_email_general_async_sending_enabled']
+ ];
+ }
+}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Observer/SendEmailsTest.php b/app/code/Magento/Sales/Test/Unit/Model/Observer/SendEmailsTest.php
new file mode 100644
index 0000000000000..0b3e4a9905a17
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Unit/Model/Observer/SendEmailsTest.php
@@ -0,0 +1,184 @@
+emailSender = $this->getMock(
+ 'Magento\Sales\Model\Order\Email\Sender',
+ ['send'],
+ [],
+ '',
+ false
+ );
+
+ $this->entityResource = $this->getMockForAbstractClass(
+ 'Magento\Sales\Model\Resource\EntityAbstract',
+ [],
+ '',
+ false,
+ false,
+ true,
+ ['save']
+ );
+
+ $this->entityCollection = $this->getMockForAbstractClass(
+ 'Magento\Sales\Model\Resource\Collection\AbstractCollection',
+ [],
+ '',
+ false,
+ false,
+ true,
+ ['addFieldToFilter', 'getItems']
+ );
+
+ $this->globalConfig = $this->getMock(
+ 'Magento\Framework\App\Config',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $this->object = $objectManager->getObject(
+ 'Magento\Sales\Model\Observer\SendEmails',
+ [
+ 'emailSender' => $this->emailSender,
+ 'entityResource' => $this->entityResource,
+ 'entityCollection' => $this->entityCollection,
+ 'globalConfig' => $this->globalConfig
+ ]
+ );
+ }
+
+ /**
+ * @param int $configValue
+ * @param array|null $collectionItems
+ * @param bool|null $emailSendingResult
+ * @dataProvider executeDataProvider
+ * @return void
+ */
+ public function testExecute($configValue, $collectionItems, $emailSendingResult)
+ {
+ $path = 'sales_email/general/async_sending';
+
+ $this->globalConfig
+ ->expects($this->once())
+ ->method('getValue')
+ ->with($path)
+ ->willReturn($configValue);
+
+ if ($configValue) {
+ $this->entityCollection
+ ->expects($this->at(0))
+ ->method('addFieldToFilter')
+ ->with('send_email', ['eq' => 1]);
+
+ $this->entityCollection
+ ->expects($this->at(1))
+ ->method('addFieldToFilter')
+ ->with('email_sent', ['null' => true]);
+
+ $this->entityCollection
+ ->expects($this->any())
+ ->method('getItems')
+ ->willReturn($collectionItems);
+
+ if ($collectionItems) {
+ /** @var \Magento\Sales\Model\AbstractModel|\PHPUnit_Framework_MockObject_MockObject $collectionItem */
+ $collectionItem = $collectionItems[0];
+
+ $this->emailSender
+ ->expects($this->once())
+ ->method('send')
+ ->with($collectionItem, true)
+ ->willReturn($emailSendingResult);
+
+ if ($emailSendingResult) {
+ $collectionItem
+ ->expects($this->once())
+ ->method('setEmailSent')
+ ->with(true)
+ ->willReturn($collectionItem);
+
+ $this->entityResource
+ ->expects($this->once())
+ ->method('save')
+ ->with($collectionItem);
+ }
+ }
+ }
+
+ $this->object->execute();
+ }
+
+ /**
+ * @return array
+ */
+ public function executeDataProvider()
+ {
+ $entityModel = $this->getMockForAbstractClass(
+ 'Magento\Sales\Model\AbstractModel',
+ [],
+ '',
+ false,
+ false,
+ true,
+ ['setEmailSent']
+ );
+
+ return [
+ [1, [$entityModel], true],
+ [1, [$entityModel], false],
+ [1, [], null],
+ [0, null, null]
+ ];
+ }
+}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php
index f57cac671fa58..cd70e51424497 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php
@@ -10,6 +10,11 @@
*/
abstract class AbstractSenderTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var \Magento\Sales\Model\Order\Email\Sender|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $senderMock;
+
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
@@ -36,12 +41,24 @@ abstract class AbstractSenderTest extends \PHPUnit_Framework_TestCase
protected $orderMock;
/**
- * @var \Magento\Sales\Model\Order\Address\Renderer | \PHPUnit_Framework_MockObject_MockObject
+ * @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $addressRendererMock;
+ protected $paymentHelper;
/**
- * @var \Magento\Sales\Model\Order\Address | \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Order\Address\Renderer|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $addressRenderer;
+
+ /**
+ * Global configuration storage mock.
+ *
+ * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $globalConfig;
+
+ /**
+ * @var \Magento\Sales\Model\Order\Address|\PHPUnit_Framework_MockObject_MockObject
*/
protected $addressMock;
@@ -52,6 +69,14 @@ abstract class AbstractSenderTest extends \PHPUnit_Framework_TestCase
public function stepMockSetup()
{
+ $this->senderMock = $this->getMock(
+ 'Magento\Sales\Model\Order\Email\Sender',
+ ['send', 'sendCopyTo'],
+ [],
+ '',
+ false
+ );
+
$this->senderBuilderFactoryMock = $this->getMock(
'\Magento\Sales\Model\Order\Email\SenderBuilderFactory',
['create'],
@@ -77,20 +102,46 @@ public function stepMockSetup()
$this->orderMock = $this->getMock(
'\Magento\Sales\Model\Order',
- [],
+ [
+ 'getStore', 'getBillingAddress', 'getPayment',
+ '__wakeup', 'getCustomerIsGuest', 'getCustomerName',
+ 'getCustomerEmail', 'getShippingAddress', 'setSendEmail',
+ 'setEmailSent'
+ ],
[],
'',
false
);
-
$this->orderMock->expects($this->any())
->method('getStore')
->will($this->returnValue($this->storeMock));
+ $paymentInfoMock = $this->getMock(
+ '\Magento\Payment\Model\Info',
+ [],
+ [],
+ '',
+ false
+ );
+ $this->orderMock->expects($this->any())
+ ->method('getPayment')
+ ->will($this->returnValue($paymentInfoMock));
-
- $this->addressRendererMock = $this->getMock('Magento\Sales\Model\Order\Address\Renderer', [], [], '', false);
+ $this->addressRenderer = $this->getMock('Magento\Sales\Model\Order\Address\Renderer', [], [], '', false);
$this->addressMock = $this->getMock('Magento\Sales\Model\Order\Address', [], [], '', false);
- $this->addressRendererMock->expects($this->any())->method('format')->willReturn(1);
+
+ $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false);
+ $this->paymentHelper->expects($this->any())
+ ->method('getInfoBlockHtml')
+ ->will($this->returnValue('payment'));
+
+ $this->globalConfig = $this->getMock(
+ 'Magento\Framework\App\Config',
+ ['getValue'],
+ [],
+ '',
+ false
+ );
+
$this->loggerMock = $this->getMock(
'\Psr\Log\LoggerInterface',
[],
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php
index c15aed06c125e..977ded72038ee 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php
@@ -26,6 +26,7 @@ protected function setUp()
{
$this->stepMockSetup();
$this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity');
+ $this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
$this->creditmemoMock = $this->getMock(
'\Magento\Sales\Model\Order\Creditmemo',
['getStore', '__wakeup', 'getOrder'],
@@ -44,7 +45,7 @@ protected function setUp()
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
- $this->addressRendererMock
+ $this->addressRenderer
);
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php
index eff59e2afe8a9..cfe7bfc22e54f 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoSenderTest.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Sales\Test\Unit\Model\Order\Email\Sender;
-use \Magento\Sales\Model\Order\Email\Sender\CreditmemoSender;
+use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender;
class CreditmemoSenderTest extends AbstractSenderTest
{
@@ -15,52 +15,34 @@ class CreditmemoSenderTest extends AbstractSenderTest
protected $sender;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Order\Creditmemo|\PHPUnit_Framework_MockObject_MockObject
*/
protected $creditmemoMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $paymentHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\EntityAbstract|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $creditmemoResource;
+ protected $creditmemoResourceMock;
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
protected function setUp()
{
$this->stepMockSetup();
- $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false);
- $this->paymentHelper->expects($this->any())
- ->method('getInfoBlockHtml')
- ->will($this->returnValue('payment'));
- $this->creditmemoResource = $this->getMock(
+ $this->creditmemoResourceMock = $this->getMock(
'\Magento\Sales\Model\Resource\Order\Creditmemo',
- [],
+ ['saveAttribute'],
[],
'',
false
);
- $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity');
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
- [],
- '',
- false
- );
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
$this->creditmemoMock = $this->getMock(
'\Magento\Sales\Model\Order\Creditmemo',
- ['getStore', '__wakeup', 'getOrder'],
+ [
+ 'getStore', '__wakeup', 'getOrder',
+ 'setSendEmail', 'setEmailSent', 'getCustomerNoteNotify',
+ 'getCustomerNote'
+ ],
[],
'',
false
@@ -71,95 +53,156 @@ protected function setUp()
$this->creditmemoMock->expects($this->any())
->method('getOrder')
->will($this->returnValue($this->orderMock));
+
+ $this->identityContainerMock = $this->getMock(
+ '\Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity',
+ ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'],
+ [],
+ '',
+ false
+ );
+ $this->identityContainerMock->expects($this->any())
+ ->method('getStore')
+ ->will($this->returnValue($this->storeMock));
+
$this->sender = new CreditmemoSender(
$this->templateContainerMock,
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
$this->paymentHelper,
- $this->creditmemoResource,
- $this->addressRendererMock
+ $this->creditmemoResourceMock,
+ $this->globalConfig,
+ $this->addressRenderer
);
}
- public function testSendFalse()
- {
- $this->stepAddressFormat($this->addressMock);
- $result = $this->sender->send($this->creditmemoMock);
- $this->assertFalse($result);
- }
-
- public function testSendTrueWithCustomerCopy()
+ /**
+ * @param int $configValue
+ * @param bool|null $forceSyncMode
+ * @param bool|null $customerNoteNotify
+ * @param bool|null $emailSendingResult
+ * @dataProvider sendDataProvider
+ * @return void
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $emailSendingResult)
{
- $billingAddress = $this->addressMock;
- $this->stepAddressFormat($this->addressMock);
$comment = 'comment_test';
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
+ $address = 'address_test';
+ $configPath = 'sales_email/general/async_sending';
+
+ $this->creditmemoMock->expects($this->once())
+ ->method('setSendEmail')
+ ->with(true);
+
+ $this->globalConfig->expects($this->once())
+ ->method('getValue')
+ ->with($configPath)
+ ->willReturn($configValue);
+
+ if (!$configValue || $forceSyncMode) {
+ $addressMock = $this->getMock(
+ 'Magento\Sales\Model\Order\Address',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $this->addressRenderer->expects($this->any())
+ ->method('format')
+ ->with($addressMock, 'html')
+ ->willReturn($address);
+
+ $this->orderMock->expects($this->any())
+ ->method('getBillingAddress')
+ ->willReturn($addressMock);
+
+ $this->orderMock->expects($this->any())
+ ->method('getShippingAddress')
+ ->willReturn($addressMock);
+
+ $this->creditmemoMock->expects($this->once())
+ ->method('getCustomerNoteNotify')
+ ->willReturn($customerNoteNotify);
+
+ $this->creditmemoMock->expects($this->any())
+ ->method('getCustomerNote')
+ ->willReturn($comment);
+
+ $this->templateContainerMock->expects($this->once())
+ ->method('setTemplateVars')
+ ->with(
[
'order' => $this->orderMock,
'creditmemo' => $this->creditmemoMock,
- 'comment' => $comment,
- 'billing' => $billingAddress,
+ 'comment' => $customerNoteNotify ? $comment : '',
+ 'billing' => $addressMock,
'payment_html' => 'payment',
'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
+ 'formattedShippingAddress' => $address,
+ 'formattedBillingAddress' => $address
]
- )
+ );
+
+ $this->identityContainerMock->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn($emailSendingResult);
+
+ if ($emailSendingResult) {
+ $this->senderBuilderFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->senderMock);
+
+ $this->senderMock->expects($this->once())->method('send');
+
+ $this->senderMock->expects($this->once())->method('sendCopyTo');
+
+ $this->creditmemoMock->expects($this->once())
+ ->method('setEmailSent')
+ ->with(true);
+
+ $this->creditmemoResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->creditmemoMock, ['send_email', 'email_sent']);
+
+ $this->assertTrue(
+ $this->sender->send($this->creditmemoMock)
+ );
+ } else {
+ $this->creditmemoResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->creditmemoMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->creditmemoMock)
+ );
+ }
+ } else {
+ $this->creditmemoResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->creditmemoMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->creditmemoMock)
);
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
- [],
- '',
- false
- );
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
- $this->stepSendWithoutSendCopy();
- $result = $this->sender->send($this->creditmemoMock, true, $comment);
- $this->assertTrue($result);
+ }
}
- public function testSendTrueWithoutCustomerCopy()
+ /**
+ * @return array
+ */
+ public function sendDataProvider()
{
- $billingAddress = $this->addressMock;
- $this->stepAddressFormat($billingAddress);
- $comment = 'comment_test';
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
- [
- 'order' => $this->orderMock,
- 'creditmemo' => $this->creditmemoMock,
- 'billing' => $billingAddress,
- 'payment_html' => 'payment',
- 'comment' => $comment,
- 'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
- ]
- )
- );
- $this->stepSendWithCallSendCopyTo();
- $result = $this->sender->send($this->creditmemoMock, false, $comment);
- $this->assertTrue($result);
+ return [
+ [0, 0, 1, true],
+ [0, 0, 0, true],
+ [0, 0, 1, false],
+ [0, 0, 0, false],
+ [0, 1, 1, true],
+ [0, 1, 0, true],
+ [1, null, null, null]
+ ];
}
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php
index 28888804481dc..30b838341b5ce 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php
@@ -40,6 +40,8 @@ protected function setUp()
$this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity');
+ $this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
+
$this->invoiceMock = $this->getMock(
'\Magento\Sales\Model\Order\Invoice',
['getStore', '__wakeup', 'getOrder'],
@@ -59,7 +61,7 @@ protected function setUp()
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
- $this->addressRendererMock
+ $this->addressRenderer
);
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php
index 3cb4e27fc4312..35cb0e84b6566 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceSenderTest.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Sales\Test\Unit\Model\Order\Email\Sender;
-use \Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
+use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
class InvoiceSenderTest extends AbstractSenderTest
{
@@ -15,54 +15,34 @@ class InvoiceSenderTest extends AbstractSenderTest
protected $sender;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Order\Invoice|\PHPUnit_Framework_MockObject_MockObject
*/
protected $invoiceMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $paymentHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\EntityAbstract|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $invoiceResource;
+ protected $invoiceResourceMock;
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
protected function setUp()
{
$this->stepMockSetup();
- $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false);
- $this->paymentHelper->expects($this->any())
- ->method('getInfoBlockHtml')
- ->will($this->returnValue('payment'));
- $this->invoiceResource = $this->getMock(
+ $this->invoiceResourceMock = $this->getMock(
'\Magento\Sales\Model\Resource\Order\Invoice',
- [],
- [],
- '',
- false
- );
-
- $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\InvoiceIdentity');
-
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
+ ['saveAttribute'],
[],
'',
false
);
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
$this->invoiceMock = $this->getMock(
'\Magento\Sales\Model\Order\Invoice',
- ['getStore', '__wakeup', 'getOrder'],
+ [
+ 'getStore', '__wakeup', 'getOrder',
+ 'setSendEmail', 'setEmailSent', 'getCustomerNoteNotify',
+ 'getCustomerNote'
+ ],
[],
'',
false
@@ -74,100 +54,155 @@ protected function setUp()
->method('getOrder')
->will($this->returnValue($this->orderMock));
+ $this->identityContainerMock = $this->getMock(
+ '\Magento\Sales\Model\Order\Email\Container\InvoiceIdentity',
+ ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'],
+ [],
+ '',
+ false
+ );
+ $this->identityContainerMock->expects($this->any())
+ ->method('getStore')
+ ->will($this->returnValue($this->storeMock));
+
$this->sender = new InvoiceSender(
$this->templateContainerMock,
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
$this->paymentHelper,
- $this->invoiceResource,
- $this->addressRendererMock
+ $this->invoiceResourceMock,
+ $this->globalConfig,
+ $this->addressRenderer
);
}
- public function testSendFalse()
- {
- $billingAddress = $this->addressMock;
- $this->stepAddressFormat($billingAddress);
- $result = $this->sender->send($this->invoiceMock);
- $this->assertFalse($result);
- }
-
- public function testSendTrueWithCustomerCopy()
+ /**
+ * @param int $configValue
+ * @param bool|null $forceSyncMode
+ * @param bool|null $customerNoteNotify
+ * @param bool|null $emailSendingResult
+ * @dataProvider sendDataProvider
+ * @return void
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $emailSendingResult)
{
- $billingAddress = $this->addressMock;
- $this->stepAddressFormat($billingAddress);
$comment = 'comment_test';
+ $address = 'address_test';
+ $configPath = 'sales_email/general/async_sending';
+
+ $this->invoiceMock->expects($this->once())
+ ->method('setSendEmail')
+ ->with(true);
+
+ $this->globalConfig->expects($this->once())
+ ->method('getValue')
+ ->with($configPath)
+ ->willReturn($configValue);
+
+ if (!$configValue || $forceSyncMode) {
+ $addressMock = $this->getMock(
+ 'Magento\Sales\Model\Order\Address',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $this->addressRenderer->expects($this->any())
+ ->method('format')
+ ->with($addressMock, 'html')
+ ->willReturn($address);
+
+ $this->orderMock->expects($this->any())
+ ->method('getBillingAddress')
+ ->willReturn($addressMock);
+
+ $this->orderMock->expects($this->any())
+ ->method('getShippingAddress')
+ ->willReturn($addressMock);
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
-
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
+ $this->invoiceMock->expects($this->once())
+ ->method('getCustomerNoteNotify')
+ ->willReturn($customerNoteNotify);
+
+ $this->invoiceMock->expects($this->any())
+ ->method('getCustomerNote')
+ ->willReturn($comment);
+
+ $this->templateContainerMock->expects($this->once())
+ ->method('setTemplateVars')
+ ->with(
[
'order' => $this->orderMock,
'invoice' => $this->invoiceMock,
- 'comment' => $comment,
- 'billing' => $billingAddress,
+ 'comment' => $customerNoteNotify ? $comment : '',
+ 'billing' => $addressMock,
'payment_html' => 'payment',
'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
+ 'formattedShippingAddress' => $address,
+ 'formattedBillingAddress' => $address
]
- )
+ );
+
+ $this->identityContainerMock->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn($emailSendingResult);
+
+ if ($emailSendingResult) {
+ $this->senderBuilderFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->senderMock);
+
+ $this->senderMock->expects($this->once())->method('send');
+
+ $this->senderMock->expects($this->once())->method('sendCopyTo');
+
+ $this->invoiceMock->expects($this->once())
+ ->method('setEmailSent')
+ ->with(true);
+
+ $this->invoiceResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->invoiceMock, ['send_email', 'email_sent']);
+
+ $this->assertTrue(
+ $this->sender->send($this->invoiceMock)
+ );
+ } else {
+ $this->invoiceResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->invoiceMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->invoiceMock)
+ );
+ }
+ } else {
+ $this->invoiceResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->invoiceMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->invoiceMock)
);
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
- [],
- '',
- false
- );
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
- $this->stepSendWithoutSendCopy();
- $result = $this->sender->send($this->invoiceMock, true, $comment);
- $this->assertTrue($result);
+ }
}
- public function testSendTrueWithoutCustomerCopy()
+ /**
+ * @return array
+ */
+ public function sendDataProvider()
{
- $billingAddress = $this->addressMock;
- $this->stepAddressFormat($billingAddress);
- $comment = 'comment_test';
-
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
-
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
- [
- 'order' => $this->orderMock,
- 'invoice' => $this->invoiceMock,
- 'billing' => $billingAddress,
- 'payment_html' => 'payment',
- 'comment' => $comment,
- 'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
- ]
- )
- );
- $this->stepSendWithCallSendCopyTo();
- $result = $this->sender->send($this->invoiceMock, false, $comment);
- $this->assertTrue($result);
+ return [
+ [0, 0, 1, true],
+ [0, 0, 0, true],
+ [0, 0, 1, false],
+ [0, 0, 0, false],
+ [0, 1, 1, true],
+ [0, 1, 0, true],
+ [1, null, null, null]
+ ];
}
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php
index 1ddc4e3724cd4..9bb5745162152 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderCommentSenderTest.php
@@ -18,12 +18,13 @@ protected function setUp()
{
$this->stepMockSetup();
$this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity');
+ $this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
$this->sender = new OrderCommentSender(
$this->templateContainerMock,
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
- $this->addressRendererMock
+ $this->addressRenderer
);
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php
index b6453f501acb0..5350c1924f023 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/OrderSenderTest.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Sales\Test\Unit\Model\Order\Email\Sender;
-use \Magento\Sales\Model\Order\Email\Sender\OrderSender;
+use Magento\Sales\Model\Order\Email\Sender\OrderSender;
class OrderSenderTest extends AbstractSenderTest
{
@@ -15,42 +15,32 @@ class OrderSenderTest extends AbstractSenderTest
protected $sender;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\EntityAbstract|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $paymentHelper;
+ protected $orderResourceMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $orderResource;
-
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $loggerMock;
-
protected function setUp()
{
$this->stepMockSetup();
- $this->paymentHelper = $this->getMock(
- '\Magento\Payment\Helper\Data',
- ['getInfoBlockHtml'],
+
+ $this->orderResourceMock = $this->getMock(
+ '\Magento\Sales\Model\Resource\Order',
+ ['saveAttribute'],
[],
'',
false
);
- $this->paymentHelper->expects($this->any())
- ->method('getInfoBlockHtml')
- ->will($this->returnValue('payment'));
- $this->orderResource = $this->getMock(
- '\Magento\Sales\Model\Resource\Order',
- [],
+ $this->identityContainerMock = $this->getMock(
+ '\Magento\Sales\Model\Order\Email\Container\OrderIdentity',
+ ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'],
[],
'',
false
);
- $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\OrderIdentity');
+ $this->identityContainerMock->expects($this->any())
+ ->method('getStore')
+ ->will($this->returnValue($this->storeMock));
$this->sender = new OrderSender(
$this->templateContainerMock,
@@ -58,110 +48,125 @@ protected function setUp()
$this->senderBuilderFactoryMock,
$this->loggerMock,
$this->paymentHelper,
- $this->orderResource,
- $this->addressRendererMock
+ $this->orderResourceMock,
+ $this->globalConfig,
+ $this->addressRenderer
);
}
- public function testSendFalse()
- {
- $this->stepAddressFormat($this->addressMock);
- $result = $this->sender->send($this->orderMock);
- $this->assertFalse($result);
- }
-
- public function testSendTrueForCustomer()
+ /**
+ * @param int $configValue
+ * @param bool|null $forceSyncMode
+ * @param bool|null $emailSendingResult
+ * @dataProvider sendDataProvider
+ * @return void
+ */
+ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
{
- $billingAddress = $this->addressMock;
+ $address = 'address_test';
+ $configPath = 'sales_email/general/async_sending';
$this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
- $this->stepAddressFormat($billingAddress);
+ ->method('setSendEmail')
+ ->with(true);
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
- [],
- '',
- false
- );
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
-
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
- [
- 'order' => $this->orderMock,
- 'billing' => $billingAddress,
- 'payment_html' => 'payment',
- 'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
- ]
- )
+ $this->globalConfig->expects($this->once())
+ ->method('getValue')
+ ->with($configPath)
+ ->willReturn($configValue);
+
+ if (!$configValue || $forceSyncMode) {
+ $this->identityContainerMock->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn($emailSendingResult);
+
+ if ($emailSendingResult) {
+ $addressMock = $this->getMock(
+ 'Magento\Sales\Model\Order\Address',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $this->addressRenderer->expects($this->any())
+ ->method('format')
+ ->with($addressMock, 'html')
+ ->willReturn($address);
+
+ $this->orderMock->expects($this->any())
+ ->method('getBillingAddress')
+ ->willReturn($addressMock);
+
+ $this->orderMock->expects($this->any())
+ ->method('getShippingAddress')
+ ->willReturn($addressMock);
+
+ $this->templateContainerMock->expects($this->once())
+ ->method('setTemplateVars')
+ ->with(
+ [
+ 'order' => $this->orderMock,
+ 'billing' => $addressMock,
+ 'payment_html' => 'payment',
+ 'store' => $this->storeMock,
+ 'formattedShippingAddress' => $address,
+ 'formattedBillingAddress' => $address
+ ]
+ );
+
+ $this->senderBuilderFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->senderMock);
+
+ $this->senderMock->expects($this->once())->method('send');
+
+ $this->senderMock->expects($this->once())->method('sendCopyTo');
+
+ $this->orderMock->expects($this->once())
+ ->method('setEmailSent')
+ ->with(true);
+
+ $this->orderResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->orderMock, ['send_email', 'email_sent']);
+
+ $this->assertTrue(
+ $this->sender->send($this->orderMock)
+ );
+ } else {
+ $this->orderResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->orderMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->orderMock)
+ );
+ }
+ } else {
+ $this->orderResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->orderMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->orderMock)
);
- $this->stepSend($this->once(), $this->once());
- $result = $this->sender->send($this->orderMock);
- $this->assertTrue($result);
+ }
}
- public function testSendTrueForGuest()
+ /**
+ * @return array
+ */
+ public function sendDataProvider()
{
- $billingAddress = $this->getMock(
- '\Magento\Sales\Model\Order\Address',
- [],
- [],
- '',
- false
- );
- $this->stepAddressFormat($billingAddress);
- $billingAddress->expects($this->any())
- ->method('getName')
- ->will($this->returnValue('name'));
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(true));
- $this->orderMock->expects($this->any())
- ->method('getBillingAddress')
- ->will($this->returnValue($billingAddress));
-
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
- [],
- '',
- false
- );
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
-
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
- [
- 'order' => $this->orderMock,
- 'billing' => $billingAddress,
- 'payment_html' => 'payment',
- 'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
- ]
- )
- );
- $this->stepSend($this->once(), $this->once());
- $result = $this->sender->send($this->orderMock);
- $this->assertTrue($result);
+ return [
+ [0, 0, true],
+ [0, 0, true],
+ [0, 0, false],
+ [0, 0, false],
+ [0, 1, true],
+ [0, 1, true],
+ [1, null, null, null]
+ ];
}
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php
index 6d4c4f26fc030..0a69bb2fcf85d 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php
@@ -23,6 +23,7 @@ protected function setUp()
{
$this->stepMockSetup();
$this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity');
+ $this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
$this->shipmentMock = $this->getMock(
'\Magento\Sales\Model\Order\Shipment',
['getStore', '__wakeup', 'getOrder'],
@@ -42,7 +43,7 @@ protected function setUp()
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
- $this->addressRendererMock
+ $this->addressRenderer
);
}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php
index 1f57f234e409c..a13619f0423ea 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentSenderTest.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Sales\Test\Unit\Model\Order\Email\Sender;
-use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender;
+use Magento\Sales\Model\Order\Email\Sender\ShipmentSender;
class ShipmentSenderTest extends AbstractSenderTest
{
@@ -15,54 +15,34 @@ class ShipmentSenderTest extends AbstractSenderTest
protected $sender;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject
*/
protected $shipmentMock;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $paymentHelper;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Resource\EntityAbstract|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $shipmentResource;
+ protected $shipmentResourceMock;
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
protected function setUp()
{
$this->stepMockSetup();
- $this->paymentHelper = $this->getMock('\Magento\Payment\Helper\Data', ['getInfoBlockHtml'], [], '', false);
- $this->paymentHelper->expects($this->any())
- ->method('getInfoBlockHtml')
- ->will($this->returnValue('payment'));
- $this->shipmentResource = $this->getMock(
+ $this->shipmentResourceMock = $this->getMock(
'\Magento\Sales\Model\Resource\Order\Shipment',
- [],
- [],
- '',
- false
- );
-
- $this->stepIdentityContainerInit('\Magento\Sales\Model\Order\Email\Container\ShipmentIdentity');
-
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
+ ['saveAttribute'],
[],
'',
false
);
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
$this->shipmentMock = $this->getMock(
'\Magento\Sales\Model\Order\Shipment',
- ['getStore', '__wakeup', 'getOrder'],
+ [
+ 'getStore', '__wakeup', 'getOrder',
+ 'setSendEmail', 'setEmailSent', 'getCustomerNoteNotify',
+ 'getCustomerNote'
+ ],
[],
'',
false
@@ -74,99 +54,155 @@ protected function setUp()
->method('getOrder')
->will($this->returnValue($this->orderMock));
+ $this->identityContainerMock = $this->getMock(
+ '\Magento\Sales\Model\Order\Email\Container\ShipmentIdentity',
+ ['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'],
+ [],
+ '',
+ false
+ );
+ $this->identityContainerMock->expects($this->any())
+ ->method('getStore')
+ ->will($this->returnValue($this->storeMock));
+
$this->sender = new ShipmentSender(
$this->templateContainerMock,
$this->identityContainerMock,
$this->senderBuilderFactoryMock,
$this->loggerMock,
$this->paymentHelper,
- $this->shipmentResource,
- $this->addressRendererMock
+ $this->shipmentResourceMock,
+ $this->globalConfig,
+ $this->addressRenderer
);
}
- public function testSendFalse()
- {
- $this->stepAddressFormat($this->addressMock);
- $result = $this->sender->send($this->shipmentMock);
- $this->assertFalse($result);
- }
-
- public function testSendTrueWithCustomerCopy()
+ /**
+ * @param int $configValue
+ * @param bool|null $forceSyncMode
+ * @param bool|null $customerNoteNotify
+ * @param bool|null $emailSendingResult
+ * @dataProvider sendDataProvider
+ * @return void
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $emailSendingResult)
{
- $billingAddress = $this->addressMock;
$comment = 'comment_test';
+ $address = 'address_test';
+ $configPath = 'sales_email/general/async_sending';
+
+ $this->shipmentMock->expects($this->once())
+ ->method('setSendEmail')
+ ->with(true);
+
+ $this->globalConfig->expects($this->once())
+ ->method('getValue')
+ ->with($configPath)
+ ->willReturn($configValue);
+
+ if (!$configValue || $forceSyncMode) {
+ $addressMock = $this->getMock(
+ 'Magento\Sales\Model\Order\Address',
+ [],
+ [],
+ '',
+ false
+ );
+
+ $this->addressRenderer->expects($this->any())
+ ->method('format')
+ ->with($addressMock, 'html')
+ ->willReturn($address);
+
+ $this->orderMock->expects($this->any())
+ ->method('getBillingAddress')
+ ->willReturn($addressMock);
+
+ $this->orderMock->expects($this->any())
+ ->method('getShippingAddress')
+ ->willReturn($addressMock);
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
- $this->stepAddressFormat($billingAddress);
-
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
+ $this->shipmentMock->expects($this->once())
+ ->method('getCustomerNoteNotify')
+ ->willReturn($customerNoteNotify);
+
+ $this->shipmentMock->expects($this->any())
+ ->method('getCustomerNote')
+ ->willReturn($comment);
+
+ $this->templateContainerMock->expects($this->once())
+ ->method('setTemplateVars')
+ ->with(
[
'order' => $this->orderMock,
'shipment' => $this->shipmentMock,
- 'comment' => $comment,
- 'billing' => $billingAddress,
+ 'comment' => $customerNoteNotify ? $comment : '',
+ 'billing' => $addressMock,
'payment_html' => 'payment',
'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
+ 'formattedShippingAddress' => $address,
+ 'formattedBillingAddress' => $address
]
- )
+ );
+
+ $this->identityContainerMock->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn($emailSendingResult);
+
+ if ($emailSendingResult) {
+ $this->senderBuilderFactoryMock->expects($this->once())
+ ->method('create')
+ ->willReturn($this->senderMock);
+
+ $this->senderMock->expects($this->once())->method('send');
+
+ $this->senderMock->expects($this->once())->method('sendCopyTo');
+
+ $this->shipmentMock->expects($this->once())
+ ->method('setEmailSent')
+ ->with(true);
+
+ $this->shipmentResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->shipmentMock, ['send_email', 'email_sent']);
+
+ $this->assertTrue(
+ $this->sender->send($this->shipmentMock)
+ );
+ } else {
+ $this->shipmentResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->shipmentMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->shipmentMock)
+ );
+ }
+ } else {
+ $this->shipmentResourceMock->expects($this->once())
+ ->method('saveAttribute')
+ ->with($this->shipmentMock, 'send_email');
+
+ $this->assertFalse(
+ $this->sender->send($this->shipmentMock)
);
- $paymentInfoMock = $this->getMock(
- '\Magento\Payment\Model\Info',
- [],
- [],
- '',
- false
- );
- $this->orderMock->expects($this->once())
- ->method('getPayment')
- ->will($this->returnValue($paymentInfoMock));
- $this->stepSendWithoutSendCopy();
- $result = $this->sender->send($this->shipmentMock, true, $comment);
- $this->assertTrue($result);
+ }
}
- public function testSendTrueWithoutCustomerCopy()
+ /**
+ * @return array
+ */
+ public function sendDataProvider()
{
- $billingAddress = $this->addressMock;
- $comment = 'comment_test';
-
- $this->orderMock->expects($this->once())
- ->method('getCustomerIsGuest')
- ->will($this->returnValue(false));
- $this->stepAddressFormat($billingAddress);
-
- $this->identityContainerMock->expects($this->once())
- ->method('isEnabled')
- ->will($this->returnValue(true));
- $this->templateContainerMock->expects($this->once())
- ->method('setTemplateVars')
- ->with(
- $this->equalTo(
- [
- 'order' => $this->orderMock,
- 'shipment' => $this->shipmentMock,
- 'billing' => $billingAddress,
- 'payment_html' => 'payment',
- 'comment' => $comment,
- 'store' => $this->storeMock,
- 'formattedShippingAddress' => 1,
- 'formattedBillingAddress' => 1
- ]
- )
- );
- $this->stepSendWithCallSendCopyTo();
- $result = $this->sender->send($this->shipmentMock, false, $comment);
- $this->assertTrue($result);
+ return [
+ [0, 0, 1, true],
+ [0, 0, 0, true],
+ [0, 0, 1, false],
+ [0, 0, 0, false],
+ [0, 1, 1, true],
+ [0, 1, 0, true],
+ [1, null, null, null]
+ ];
}
}
diff --git a/app/code/Magento/Sales/etc/adminhtml/system.xml b/app/code/Magento/Sales/etc/adminhtml/system.xml
index e7482704e39ad..c153f0973838f 100644
--- a/app/code/Magento/Sales/etc/adminhtml/system.xml
+++ b/app/code/Magento/Sales/etc/adminhtml/system.xml
@@ -119,6 +119,14 @@
sales
Magento_Sales::sales_email
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+ Magento\Sales\Model\Config\Backend\Email\AsyncSending
+
+
diff --git a/app/code/Magento/Sales/etc/config.xml b/app/code/Magento/Sales/etc/config.xml
index f88cf2955f60e..e786d5e45149b 100644
--- a/app/code/Magento/Sales/etc/config.xml
+++ b/app/code/Magento/Sales/etc/config.xml
@@ -23,6 +23,9 @@
+
+ 0
+
1
sales_email_order_template
diff --git a/app/code/Magento/Sales/etc/crontab.xml b/app/code/Magento/Sales/etc/crontab.xml
index 1bd5b3e3e2478..15264798d8f1f 100644
--- a/app/code/Magento/Sales/etc/crontab.xml
+++ b/app/code/Magento/Sales/etc/crontab.xml
@@ -37,5 +37,17 @@
*/1 * * * *
+
+ */1 * * * *
+
+
+ */1 * * * *
+
+
+ */1 * * * *
+
+
+ */1 * * * *
+
diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml
index ba45f06f9d73e..9e20997c62f00 100644
--- a/app/code/Magento/Sales/etc/di.xml
+++ b/app/code/Magento/Sales/etc/di.xml
@@ -157,6 +157,34 @@
Magento\Sales\Model\Resource\Order\Creditmemo\Grid
+
+
+ Magento\Sales\Model\Order\Email\Sender\OrderSender
+ Magento\Sales\Model\Resource\Order
+ Magento\Sales\Model\Resource\Order\Collection
+
+
+
+
+ Magento\Sales\Model\Order\Email\Sender\InvoiceSender
+ Magento\Sales\Model\Resource\Order\Invoice
+ Magento\Sales\Model\Resource\Order\Invoice\Collection
+
+
+
+
+ Magento\Sales\Model\Order\Email\Sender\ShipmentSender
+ Magento\Sales\Model\Resource\Order\Shipment
+ Magento\Sales\Model\Resource\Order\Shipment\Collection
+
+
+
+
+ Magento\Sales\Model\Order\Email\Sender\CreditmemoSender
+ Magento\Sales\Model\Resource\Order\Creditmemo
+ Magento\Sales\Model\Resource\Order\Creditmemo\Collection
+
+
diff --git a/app/code/Magento/Sales/etc/events.xml b/app/code/Magento/Sales/etc/events.xml
index 1260e97f8d9d4..9e38abcd68e8c 100644
--- a/app/code/Magento/Sales/etc/events.xml
+++ b/app/code/Magento/Sales/etc/events.xml
@@ -39,6 +39,12 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml
index eb894f667baef..931f2ab5884d8 100644
--- a/app/code/Magento/Sales/etc/module.xml
+++ b/app/code/Magento/Sales/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/SalesRule/Setup/InstallSchema.php b/app/code/Magento/SalesRule/Setup/InstallSchema.php
index 700bdac3b587d..0e319cccfc9fb 100644
--- a/app/code/Magento/SalesRule/Setup/InstallSchema.php
+++ b/app/code/Magento/SalesRule/Setup/InstallSchema.php
@@ -264,7 +264,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('salesrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Salesrule Coupon'
@@ -302,14 +301,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'coupon_id',
$installer->getTable('salesrule_coupon'),
'coupon_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Salesrule Coupon Usage'
@@ -356,14 +353,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Salesrule Customer'
@@ -415,14 +410,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('salesrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Salesrule Label'
@@ -472,8 +465,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'attribute_id',
$installer->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
'salesrule_product_attribute',
@@ -484,22 +476,19 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$installer->getTable('customer_group'),
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
+ \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,
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
+ \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,
- \Magento\Framework\DB\Ddl\Table::ACTION_NO_ACTION
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Salesrule Product Attribute'
);
@@ -607,7 +596,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Coupon Aggregated'
@@ -705,7 +693,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Coupon Aggregated Order'
@@ -743,14 +730,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('salesrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('salesrule_website', 'website_id', 'core/website', 'website_id'),
'website_id',
$websitesTable,
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Rules To Websites Relations'
@@ -784,7 +769,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'rule_id',
$installer->getTable('salesrule'),
'rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -796,7 +780,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_group_id',
$customerGroupsTable,
'customer_group_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Rules To Customer Groups Relations'
diff --git a/app/code/Magento/Search/Setup/InstallSchema.php b/app/code/Magento/Search/Setup/InstallSchema.php
index 8a4acf9042b8e..3c20f81310ed0 100644
--- a/app/code/Magento/Search/Setup/InstallSchema.php
+++ b/app/code/Magento/Search/Setup/InstallSchema.php
@@ -124,7 +124,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)
->setComment('Search query table');
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php
index 70310d404c6fa..c1fdc5ecd880d 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php
@@ -6,7 +6,7 @@
*/
namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment;
-use Magento\Sales\Model\Order\Email\Sender\ShipmentSender;
+use Magento\Sales\Model\Order\Email\Sender\ShipmentCommentSender;
use Magento\Backend\App\Action;
use Magento\Framework\View\Result\LayoutFactory;
@@ -18,9 +18,9 @@ class AddComment extends \Magento\Backend\App\Action
protected $shipmentLoader;
/**
- * @var ShipmentSender
+ * @var ShipmentCommentSender
*/
- protected $shipmentSender;
+ protected $shipmentCommentSender;
/**
* @var LayoutFactory
@@ -30,17 +30,17 @@ class AddComment extends \Magento\Backend\App\Action
/**
* @param Action\Context $context
* @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader
- * @param ShipmentSender $shipmentSender
+ * @param ShipmentCommentSender $shipmentCommentSender
* @param LayoutFactory $resultLayoutFactory
*/
public function __construct(
Action\Context $context,
\Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader,
- ShipmentSender $shipmentSender,
+ ShipmentCommentSender $shipmentCommentSender,
LayoutFactory $resultLayoutFactory
) {
$this->shipmentLoader = $shipmentLoader;
- $this->shipmentSender = $shipmentSender;
+ $this->shipmentCommentSender = $shipmentCommentSender;
$this->resultLayoutFactory = $resultLayoutFactory;
parent::__construct($context);
}
@@ -79,7 +79,7 @@ public function execute()
isset($data['is_visible_on_front'])
);
- $this->shipmentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']);
+ $this->shipmentCommentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']);
$shipment->save();
$resultLayout = $this->resultLayoutFactory->create();
$resultLayout->addDefaultHandle();
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php
index 7bb56f5087c0f..c187d9bb21b55 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php
@@ -100,23 +100,19 @@ public function execute()
return;
}
- $shipment->register();
- $comment = '';
if (!empty($data['comment_text'])) {
$shipment->addComment(
$data['comment_text'],
isset($data['comment_customer_notify']),
isset($data['is_visible_on_front'])
);
- if (isset($data['comment_customer_notify'])) {
- $comment = $data['comment_text'];
- }
- }
- if (!empty($data['send_email'])) {
- $shipment->setEmailSent(true);
+ $shipment->setCustomerNote($data['comment_text']);
+ $shipment->setCustomerNoteNotify(isset($data['comment_customer_notify']));
}
+ $shipment->register();
+
$shipment->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
$responseAjax = new \Magento\Framework\Object();
$isNeedCreateLabel = isset($data['create_shipping_label']) && $data['create_shipping_label'];
@@ -128,7 +124,9 @@ public function execute()
$this->_saveShipment($shipment);
- $this->shipmentSender->send($shipment, !empty($data['send_email']), $comment);
+ if (!empty($data['send_email'])) {
+ $this->shipmentSender->send($shipment);
+ }
$shipmentCreatedMessage = __('The shipment has been created.');
$labelCreatedMessage = __('You created the shipping label.');
diff --git a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/AddCommentTest.php b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/AddCommentTest.php
index 4bc12ca365165..6a60d69bdfe58 100644
--- a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/AddCommentTest.php
+++ b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/AddCommentTest.php
@@ -16,9 +16,9 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
protected $shipmentLoaderMock;
/**
- * @var \Magento\Sales\Model\Order\Email\Sender\ShipmentSender|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Sales\Model\Order\Email\Sender\ShipmentCommentSender|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $shipmentSenderMock;
+ protected $shipmentCommentSenderMock;
/**
* @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject
@@ -69,8 +69,8 @@ protected function setUp()
'',
false
);
- $this->shipmentSenderMock = $this->getMock(
- 'Magento\Sales\Model\Order\Email\Sender\ShipmentSender',
+ $this->shipmentCommentSenderMock = $this->getMock(
+ 'Magento\Sales\Model\Order\Email\Sender\ShipmentCommentSender',
['send', '__wakeup'],
[],
'',
@@ -139,7 +139,7 @@ protected function setUp()
$this->controller = new \Magento\Shipping\Controller\Adminhtml\Order\Shipment\AddComment(
$contextMock,
$this->shipmentLoaderMock,
- $this->shipmentSenderMock,
+ $this->shipmentCommentSenderMock,
$this->resultLayoutFactoryMock
);
}
@@ -210,7 +210,7 @@ public function testExecute()
->method('load')
->will($this->returnValue($this->shipmentMock));
$this->shipmentMock->expects($this->once())->method('addComment');
- $this->shipmentSenderMock->expects($this->once())->method('send');
+ $this->shipmentCommentSenderMock->expects($this->once())->method('send');
$this->shipmentMock->expects($this->once())->method('save');
$layoutMock = $this->getMock('Magento\Framework\View\Layout', ['getBlock'], [], '', false);
$blockMock = $this->getMock('Magento\Shipping\Block\Adminhtml\View\Comments', ['toHtml'], [], '', false);
@@ -318,7 +318,7 @@ public function testExecuteExceptionSave()
->method('load')
->will($this->returnValue($this->shipmentMock));
$this->shipmentMock->expects($this->once())->method('addComment');
- $this->shipmentSenderMock->expects($this->once())->method('send');
+ $this->shipmentCommentSenderMock->expects($this->once())->method('send');
$this->shipmentMock->expects($this->once())->method('save')->will($this->throwException(new \Exception()));
$this->exceptionResponse();
diff --git a/app/code/Magento/Sitemap/Setup/InstallSchema.php b/app/code/Magento/Sitemap/Setup/InstallSchema.php
index 202d222ec8ff8..bca997246b74d 100644
--- a/app/code/Magento/Sitemap/Setup/InstallSchema.php
+++ b/app/code/Magento/Sitemap/Setup/InstallSchema.php
@@ -73,7 +73,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'XML Sitemap'
diff --git a/app/code/Magento/Store/Setup/InstallSchema.php b/app/code/Magento/Store/Setup/InstallSchema.php
index f76cc884777a8..948659c8c3422 100644
--- a/app/code/Magento/Store/Setup/InstallSchema.php
+++ b/app/code/Magento/Store/Setup/InstallSchema.php
@@ -133,7 +133,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'website_id',
$installer->getTable('store_website'),
'website_id',
- Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)->setComment(
'Store Groups'
@@ -209,14 +208,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'group_id',
$installer->getTable('store_group'),
'group_id',
- Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('store', 'website_id', 'store_website', 'website_id'),
'website_id',
$installer->getTable('store_website'),
'website_id',
- Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)->setComment(
'Stores'
diff --git a/app/code/Magento/Tax/Setup/InstallSchema.php b/app/code/Magento/Tax/Setup/InstallSchema.php
index 85218d2195b72..6d708d5862f56 100644
--- a/app/code/Magento/Tax/Setup/InstallSchema.php
+++ b/app/code/Magento/Tax/Setup/InstallSchema.php
@@ -228,14 +228,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_tax_class_id',
$setup->getTable('tax_class'),
'class_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName('tax_calculation', 'customer_tax_class_id', 'tax_class', 'class_id'),
'customer_tax_class_id',
$setup->getTable('tax_class'),
'class_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName(
@@ -247,7 +245,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'tax_calculation_rate_id',
$setup->getTable('tax_calculation_rate'),
'tax_calculation_rate_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName(
@@ -259,7 +256,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'tax_calculation_rule_id',
$setup->getTable('tax_calculation_rule'),
'tax_calculation_rule_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Tax Calculation'
@@ -306,7 +302,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$setup->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName(
@@ -318,7 +313,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'tax_calculation_rate_id',
$setup->getTable('tax_calculation_rate'),
'tax_calculation_rate_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Tax Calculation Rate Title'
@@ -394,7 +388,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$setup->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Tax Order Aggregation'
@@ -492,21 +485,18 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'associated_item_id',
$setup->getTable('sales_order_item'),
'item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\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,
\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,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Sales Order Tax Item'
diff --git a/app/code/Magento/Theme/Setup/InstallSchema.php b/app/code/Magento/Theme/Setup/InstallSchema.php
index f2135e0c1e4df..b7f6d0edb3775 100644
--- a/app/code/Magento/Theme/Setup/InstallSchema.php
+++ b/app/code/Magento/Theme/Setup/InstallSchema.php
@@ -150,7 +150,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'theme_id',
$installer->getTable('theme'),
'theme_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Core theme files'
@@ -200,7 +199,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Design Changes'
diff --git a/app/code/Magento/Translation/Setup/InstallSchema.php b/app/code/Magento/Translation/Setup/InstallSchema.php
index a7d4df05902bc..24afcc2039693 100644
--- a/app/code/Magento/Translation/Setup/InstallSchema.php
+++ b/app/code/Magento/Translation/Setup/InstallSchema.php
@@ -96,7 +96,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment('Translations');
$installer->getConnection()->createTable($table);
diff --git a/app/code/Magento/Variable/Setup/InstallSchema.php b/app/code/Magento/Variable/Setup/InstallSchema.php
index b2af66d257b7c..043ccaad3360d 100644
--- a/app/code/Magento/Variable/Setup/InstallSchema.php
+++ b/app/code/Magento/Variable/Setup/InstallSchema.php
@@ -17,6 +17,7 @@ class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
@@ -135,7 +136,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
);
$connection->addForeignKey(
@@ -144,12 +144,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'variable_id',
$installer->getTable('variable'),
'variable_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
);
$installer->endSetup();
-
}
-
}
diff --git a/app/code/Magento/Weee/Setup/InstallSchema.php b/app/code/Magento/Weee/Setup/InstallSchema.php
index c304dd40f5a09..6c098098c409c 100644
--- a/app/code/Magento/Weee/Setup/InstallSchema.php
+++ b/app/code/Magento/Weee/Setup/InstallSchema.php
@@ -86,28 +86,24 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'country',
$setup->getTable('directory_country'),
'country_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName('weee_tax', 'entity_id', 'catalog_product_entity', 'entity_id'),
'entity_id',
$setup->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName('weee_tax', 'website_id', 'store_website', 'website_id'),
'website_id',
$setup->getTable('store_website'),
'website_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$setup->getFkName('weee_tax', 'attribute_id', 'eav_attribute', 'attribute_id'),
'attribute_id',
$setup->getTable('eav_attribute'),
'attribute_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Weee Tax'
diff --git a/app/code/Magento/Widget/Setup/InstallSchema.php b/app/code/Magento/Widget/Setup/InstallSchema.php
index 4d71df5ef6ca6..60a95b70f7b5c 100644
--- a/app/code/Magento/Widget/Setup/InstallSchema.php
+++ b/app/code/Magento/Widget/Setup/InstallSchema.php
@@ -167,7 +167,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'theme_id',
$installer->getTable('theme'),
'theme_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Instances of Widget for Package Theme'
@@ -235,7 +234,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'instance_id',
$installer->getTable('widget_instance'),
'instance_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Instance of Widget on Page'
@@ -275,7 +273,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'page_id',
$installer->getTable('widget_instance_page'),
'page_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName(
@@ -287,7 +284,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'layout_update_id',
$installer->getTable('layout_update'),
'layout_update_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Layout updates'
@@ -380,7 +376,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'layout_update_id',
$installer->getTable('layout_update'),
'layout_update_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addIndex(
$installer->getIdxName(
@@ -394,14 +389,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addForeignKey(
$installer->getFkName('layout_link', 'theme_id', 'theme', 'theme_id'),
'theme_id',
$installer->getTable('theme'),
'theme_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Layout Link'
diff --git a/app/code/Magento/Wishlist/Setup/InstallSchema.php b/app/code/Magento/Wishlist/Setup/InstallSchema.php
index cde21e7ff4865..f2894e5fbec2e 100644
--- a/app/code/Magento/Wishlist/Setup/InstallSchema.php
+++ b/app/code/Magento/Wishlist/Setup/InstallSchema.php
@@ -76,7 +76,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'customer_id',
$installer->getTable('customer_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Wishlist main Table'
@@ -138,7 +137,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'wishlist_id',
$installer->getTable('wishlist'),
'wishlist_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addIndex(
$installer->getIdxName('wishlist_item', 'product_id'),
@@ -148,7 +146,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'product_id',
$installer->getTable('catalog_product_entity'),
'entity_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->addIndex(
$installer->getIdxName('wishlist_item', 'store_id'),
@@ -158,8 +155,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'store_id',
$installer->getTable('store'),
'store_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL,
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ \Magento\Framework\DB\Ddl\Table::ACTION_SET_NULL
)->setComment(
'Wishlist items'
);
@@ -205,7 +201,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'wishlist_item_id',
$installer->getTable('wishlist_item'),
'wishlist_item_id',
- \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE,
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
)->setComment(
'Wishlist Item Option Table'
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php
index 1d5e17894031e..8ed450ec926d9 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php
@@ -322,7 +322,7 @@ private function collectDependency($dependency, $currentModule, &$undeclared)
/**
* Collect redundant dependencies
- *
+ * @SuppressWarnings(PHPMD.NPathComplexity)
* @test
* @depends testUndeclared
*/
@@ -331,6 +331,7 @@ public function collectRedundant()
foreach (array_keys(self::$_mapDependencies) as $module) {
$declared = $this->_getDependencies($module, self::TYPE_HARD, self::MAP_TYPE_DECLARED);
$found = $this->_getDependencies($module, self::TYPE_HARD, self::MAP_TYPE_FOUND);
+ $found['Magento\Framework'] = 'Magento\Framework';
$this->_setDependencies($module, self::TYPE_HARD, self::MAP_TYPE_REDUNDANT, array_diff($declared, $found));
}
}
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
index 7baeb9bac60b7..36a143317f30e 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
@@ -2155,4 +2155,12 @@
['_isCacheEnabled', 'Magento\Eav\Model\Config'],
['_createCustomerAttribute', '\Magento\Customer\Model\Customer'],
['prepareCatalogProductPriceIndexTable', 'Magento\CatalogRule\Model\Observer'],
+ ['joinOrders', 'Magento\Reports\Model\Resource\Customer\Collection'],
+ ['addOrdersCount', 'Magento\Reports\Model\Resource\Customer\Collection'],
+ ['addSumAvgTotals', 'Magento\Reports\Model\Resource\Customer\Collection'],
+ ['orderByTotalAmount', 'Magento\Reports\Model\Resource\Customer\Collection'],
+ ['addOrdersCount', 'Magento\Reports\Model\Resource\Product\Collection'],
+ ['addOrderedQty', 'Magento\Reports\Model\Resource\Product\Collection'],
+ ['prepareForProductsInCarts', 'Magento\Reports\Model\Resource\Quote\Collection'],
+ ['getOrdersSubSelect', 'Magento\Reports\Model\Resource\Quote\Collection'],
];
diff --git a/dev/tools/performance-toolkit/fixtures/configurable_products.php b/dev/tools/performance-toolkit/fixtures/configurable_products.php
index af3a5b5c6cd2b..a3aa8f8ba8d24 100644
--- a/dev/tools/performance-toolkit/fixtures/configurable_products.php
+++ b/dev/tools/performance-toolkit/fixtures/configurable_products.php
@@ -885,7 +885,7 @@ public function execute()
/** @var \Magento\ImportExport\Model\Import $import */
$import = $this->application->getObjectManager()->create(
'Magento\ImportExport\Model\Import',
- ['data' => ['entity' => 'catalog_product', 'behavior' => 'append']]
+ ['data' => ['entity' => 'catalog_product', 'behavior' => 'replace']]
);
$source = new \Magento\ToolkitFramework\ImportExport\Fixture\Complex\Generator($pattern, $configurablesCount);
diff --git a/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php b/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php
index 84ab04e316702..ac5f33263ec03 100644
--- a/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php
+++ b/lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php
@@ -375,7 +375,6 @@ public function addForeignKey(
$refTableName,
$refColumnName,
$onDelete = self::FK_ACTION_CASCADE,
- $onUpdate = self::FK_ACTION_CASCADE,
$purge = false,
$schemaName = null,
$refSchemaName = null
diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
index c46f71cf9ebe4..f3bf8e12d893c 100644
--- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
+++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
@@ -1071,7 +1071,6 @@ public function getCreateTable($tableName, $schemaName = null)
* REF_TABLE_NAME => string; reference table name
* REF_COLUMN_NAME => string; reference column name
* ON_DELETE => string; action type on delete row
- * ON_UPDATE => string; action type on update row
*
* @param string $tableName
* @param string $schemaName
@@ -1101,8 +1100,7 @@ public function getForeignKeys($tableName, $schemaName = null)
'REF_SHEMA_NAME' => isset($match[4]) ? $match[4] : $schemaName,
'REF_TABLE_NAME' => $match[5],
'REF_COLUMN_NAME' => $match[6],
- 'ON_DELETE' => isset($match[7]) ? $match[8] : '',
- 'ON_UPDATE' => isset($match[9]) ? $match[10] : '',
+ 'ON_DELETE' => isset($match[7]) ? $match[8] : ''
];
}
@@ -1173,10 +1171,8 @@ public function modifyTables($tables)
unset($columnDefinition['identity'], $columnDefinition['primary'], $columnDefinition['comment']);
$onDelete = $options['ON_DELETE'];
- $onUpdate = $options['ON_UPDATE'];
- if ($onDelete == AdapterInterface::FK_ACTION_SET_NULL
- || $onUpdate == AdapterInterface::FK_ACTION_SET_NULL) {
+ if ($onDelete == AdapterInterface::FK_ACTION_SET_NULL) {
$columnDefinition['nullable'] = true;
}
$this->modifyColumn($options['TABLE_NAME'], $options['COLUMN_NAME'], $columnDefinition);
@@ -1186,8 +1182,7 @@ public function modifyTables($tables)
$options['COLUMN_NAME'],
$options['REF_TABLE_NAME'],
$options['REF_COLUMN_NAME'],
- ($onDelete) ? $onDelete : AdapterInterface::FK_ACTION_NO_ACTION,
- ($onUpdate) ? $onUpdate : AdapterInterface::FK_ACTION_NO_ACTION
+ ($onDelete) ? $onDelete : AdapterInterface::FK_ACTION_NO_ACTION
);
}
}
@@ -1633,15 +1628,13 @@ public function createTableByDdl($tableName, $newTableName)
$keyData['REF_COLUMN_NAME']
);
$onDelete = $this->_getDdlAction($keyData['ON_DELETE']);
- $onUpdate = $this->_getDdlAction($keyData['ON_UPDATE']);
$table->addForeignKey(
$fkName,
$keyData['COLUMN_NAME'],
$keyData['REF_TABLE_NAME'],
$keyData['REF_COLUMN_NAME'],
- $onDelete,
- $onUpdate
+ $onDelete
);
}
@@ -2139,16 +2132,13 @@ protected function _getForeignKeysDefinition(Table $table)
if (!empty($relations)) {
foreach ($relations as $fkData) {
$onDelete = $this->_getDdlAction($fkData['ON_DELETE']);
- $onUpdate = $this->_getDdlAction($fkData['ON_UPDATE']);
-
$definition[] = sprintf(
- ' CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s) ON DELETE %s ON UPDATE %s',
+ ' CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s) ON DELETE %s',
$this->quoteIdentifier($fkData['FK_NAME']),
$this->quoteIdentifier($fkData['COLUMN_NAME']),
$this->quoteIdentifier($fkData['REF_TABLE_NAME']),
$this->quoteIdentifier($fkData['REF_COLUMN_NAME']),
- $onDelete,
- $onUpdate
+ $onDelete
);
}
}
@@ -2579,7 +2569,6 @@ public function dropIndex($tableName, $keyName, $schemaName = null)
* @param string $refTableName
* @param string $refColumnName
* @param string $onDelete
- * @param string $onUpdate
* @param bool $purge trying remove invalid data
* @param string $schemaName
* @param string $refSchemaName
@@ -2593,7 +2582,6 @@ public function addForeignKey(
$refTableName,
$refColumnName,
$onDelete = AdapterInterface::FK_ACTION_CASCADE,
- $onUpdate = AdapterInterface::FK_ACTION_CASCADE,
$purge = false,
$schemaName = null,
$refSchemaName = null
@@ -2616,9 +2604,6 @@ public function addForeignKey(
if ($onDelete !== null) {
$query .= ' ON DELETE ' . strtoupper($onDelete);
}
- if ($onUpdate !== null) {
- $query .= ' ON UPDATE ' . strtoupper($onUpdate);
- }
$result = $this->rawQuery($query);
$this->resetDdlCache($tableName);
diff --git a/lib/internal/Magento/Framework/DB/Ddl/Table.php b/lib/internal/Magento/Framework/DB/Ddl/Table.php
index e42dfa1f6c2d7..eee5ed9bc320a 100644
--- a/lib/internal/Magento/Framework/DB/Ddl/Table.php
+++ b/lib/internal/Magento/Framework/DB/Ddl/Table.php
@@ -405,12 +405,11 @@ public function addColumn($name, $type, $size = null, $options = [], $comment =
* @param string $refTable the reference table name
* @param string $refColumn the reference table column name
* @param string $onDelete the action on delete row
- * @param string $onUpdate the action on update
* @return $this
* @throws \Zend_Db_Exception
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null, $onUpdate = null)
+ public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null)
{
$upperName = strtoupper($fkName);
@@ -429,23 +428,12 @@ public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete
$onDelete = self::ACTION_NO_ACTION;
}
- switch ($onUpdate) {
- case self::ACTION_CASCADE:
- case self::ACTION_RESTRICT:
- case self::ACTION_SET_DEFAULT:
- case self::ACTION_SET_NULL:
- break;
- default:
- $onUpdate = self::ACTION_NO_ACTION;
- }
-
$this->_foreignKeys[$upperName] = [
'FK_NAME' => $fkName,
'COLUMN_NAME' => $column,
'REF_TABLE_NAME' => $refTable,
'REF_COLUMN_NAME' => $refColumn,
- 'ON_DELETE' => $onDelete,
- 'ON_UPDATE' => $onUpdate,
+ 'ON_DELETE' => $onDelete
];
return $this;