diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e92d3e71..0ee778c2b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,18 @@
+2.1.8
+=============
+* Added support for versions:
+
+ * Magento CE: 1.9.3.4, 2.1.8
+ * Magento EE: 1.14.3.4, 2.1.8
+
+* Fixed bugs:
+
+ * Volume checks were missing when migrating data to EE
+ * Delta did not work on archived sales order grid
+ * Urlrewrites added unwanted extra dot to url suffix
+ * [Issue #306](https://github.com/magento/data-migration-tool/issues/306): Tables prefix was not added to the table `customer_entity` which triggered error
+ * [Issue #279](https://github.com/magento/data-migration-tool/issues/279): No warnings appeared when delta tables could not be created
+
2.1.7
=============
* Added support for versions:
diff --git a/composer.json b/composer.json
index 8a9f6cc9d..447d3b0a8 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "magento/data-migration-tool",
"description": "Migration Tool",
- "version": "2.1.7",
+ "version": "2.1.8",
"require": {
"symfony/console": "~2.3",
"magento/framework": "~100.1",
diff --git a/etc/ce-to-ce/1.9.3.4/config.xml.dist b/etc/ce-to-ce/1.9.3.4/config.xml.dist
new file mode 100644
index 000000000..dc6f1cca1
--- /dev/null
+++ b/etc/ce-to-ce/1.9.3.4/config.xml.dist
@@ -0,0 +1,144 @@
+
+
+
+
+
+ Migration\Step\Settings\Integrity
+ Migration\Step\Settings\Data
+
+
+ Migration\Step\Stores\Integrity
+ Migration\Step\Stores\Data
+ Migration\Step\Stores\Volume
+
+
+
+
+ Migration\Step\DataIntegrity\Integrity
+
+
+ Migration\Step\Eav\Integrity
+ Migration\Step\Eav\Data
+ Migration\Step\Eav\Volume
+
+
+ Migration\Step\Customer\Integrity
+ Migration\Step\Customer\Data
+ Migration\Step\Customer\Volume
+
+
+ Migration\Step\Map\Integrity
+ Migration\Step\Map\Data
+ Migration\Step\Map\Volume
+
+
+ Migration\Step\UrlRewrite\Version191to2000
+ Migration\Step\UrlRewrite\Version191to2000
+ Migration\Step\UrlRewrite\Version191to2000
+
+
+ Migration\Step\Log\Integrity
+ Migration\Step\Log\Data
+ Migration\Step\Log\Volume
+
+
+ Migration\Step\Ratings\Integrity
+ Migration\Step\Ratings\Data
+ Migration\Step\Ratings\Volume
+
+
+ Migration\Step\ConfigurablePrices\Integrity
+ Migration\Step\ConfigurablePrices\Data
+ Migration\Step\ConfigurablePrices\Volume
+
+
+ Migration\Step\OrderGrids\Integrity
+ Migration\Step\OrderGrids\Data
+ Migration\Step\OrderGrids\Volume
+
+
+ Migration\Step\TierPrice\Integrity
+ Migration\Step\TierPrice\Data
+ Migration\Step\TierPrice\Volume
+
+
+ Migration\Step\SalesIncrement\Integrity
+ Migration\Step\SalesIncrement\Data
+ Migration\Step\SalesIncrement\Volume
+
+
+ Migration\Step\PostProcessing\Data
+
+
+
+
+ Migration\Step\Customer\Delta
+ Migration\Step\Customer\Volume
+
+
+ Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
+
+
+ Migration\Step\Log\Delta
+ Migration\Step\Log\Volume
+
+
+ Migration\Step\OrderGrids\Delta
+ Migration\Step\OrderGrids\Volume
+
+
+ Migration\Step\SalesIncrement\Delta
+ Migration\Step\SalesIncrement\Volume
+
+
+
+
+
+
+
+ etc/ce-to-ce/1.9.3.4/map.xml.dist
+ etc/ce-to-ce/map-eav.xml.dist
+ etc/ce-to-ce/eav-document-groups.xml.dist
+ etc/ce-to-ce/eav-attribute-groups.xml.dist
+ etc/ce-to-ce/map-log.xml.dist
+ etc/ce-to-ce/log-document-groups.xml.dist
+ etc/ce-to-ce/settings.xml.dist
+ etc/ce-to-ce/map-customer.xml.dist
+ etc/ce-to-ce/customer-document-groups.xml.dist
+ etc/ce-to-ce/customer-attribute-groups.xml.dist
+ etc/ce-to-ce/deltalog.xml.dist
+ etc/ce-to-ce/order-grids-document-groups.xml.dist
+ etc/ce-to-ce/map-document-groups.xml.dist
+ etc/ce-to-ce/class-map.xml.dist
+ etc/ce-to-ce/1.9.3.4/map-tier-price.xml.dist
+
+ 0
+
+ 0
+
+
+ 0
+ migration.log
+ %percent%% [%bar%] Remaining Time: %remaining%
+ 1
+ ce-to-ce
+ 1.9.3.4
+ SET NAMES utf8;
+ SET NAMES utf8;
+
+
+
diff --git a/etc/ce-to-ce/1.9.3.4/map-tier-price.xml.dist b/etc/ce-to-ce/1.9.3.4/map-tier-price.xml.dist
new file mode 100644
index 000000000..153f530de
--- /dev/null
+++ b/etc/ce-to-ce/1.9.3.4/map-tier-price.xml.dist
@@ -0,0 +1,17 @@
+
+
+
diff --git a/etc/ce-to-ce/1.9.3.4/map.xml.dist b/etc/ce-to-ce/1.9.3.4/map.xml.dist
new file mode 100644
index 000000000..6da515682
--- /dev/null
+++ b/etc/ce-to-ce/1.9.3.4/map.xml.dist
@@ -0,0 +1,1777 @@
+
+
+
diff --git a/etc/ce-to-ee/1.9.3.4/config.xml.dist b/etc/ce-to-ee/1.9.3.4/config.xml.dist
new file mode 100644
index 000000000..32d59d688
--- /dev/null
+++ b/etc/ce-to-ee/1.9.3.4/config.xml.dist
@@ -0,0 +1,144 @@
+
+
+
+
+
+ Migration\Step\Settings\Integrity
+ Migration\Step\Settings\Data
+
+
+ Migration\Step\Stores\Integrity
+ Migration\Step\Stores\Data
+ Migration\Step\Stores\Volume
+
+
+
+
+ Migration\Step\DataIntegrity\Integrity
+
+
+ Migration\Step\Eav\Integrity
+ Migration\Step\Eav\Data
+ Migration\Step\Eav\Volume
+
+
+ Migration\Step\Customer\Integrity
+ Migration\Step\Customer\Data
+ Migration\Step\Customer\Volume
+
+
+ Migration\Step\Map\Integrity
+ Migration\Step\Map\Data
+ Migration\Step\Map\Volume
+
+
+ Migration\Step\UrlRewrite\Version191to2000
+ Migration\Step\UrlRewrite\Version191to2000
+ Migration\Step\UrlRewrite\Version191to2000
+
+
+ Migration\Step\Log\Integrity
+ Migration\Step\Log\Data
+ Migration\Step\Log\Volume
+
+
+ Migration\Step\Ratings\Integrity
+ Migration\Step\Ratings\Data
+ Migration\Step\Ratings\Volume
+
+
+ Migration\Step\ConfigurablePrices\Integrity
+ Migration\Step\ConfigurablePrices\Data
+ Migration\Step\ConfigurablePrices\Volume
+
+
+ Migration\Step\OrderGrids\Integrity
+ Migration\Step\OrderGrids\Data
+ Migration\Step\OrderGrids\Volume
+
+
+ Migration\Step\TierPrice\Integrity
+ Migration\Step\TierPrice\Data
+ Migration\Step\TierPrice\Volume
+
+
+ Migration\Step\SalesIncrement\Integrity
+ Migration\Step\SalesIncrement\Data
+ Migration\Step\SalesIncrement\Volume
+
+
+ Migration\Step\PostProcessing\Data
+
+
+
+
+ Migration\Step\Customer\Delta
+ Migration\Step\Customer\Volume
+
+
+ Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
+
+
+ Migration\Step\Log\Delta
+ Migration\Step\Log\Volume
+
+
+ Migration\Step\OrderGrids\Delta
+ Migration\Step\OrderGrids\Volume
+
+
+ Migration\Step\SalesIncrement\Delta
+ Migration\Step\SalesIncrement\Volume
+
+
+
+
+
+
+
+ etc/ce-to-ee/1.9.3.4/map.xml.dist
+ etc/ce-to-ee/map-eav.xml.dist
+ etc/ce-to-ee/eav-document-groups.xml.dist
+ etc/ce-to-ee/eav-attribute-groups.xml.dist
+ etc/ce-to-ee/map-log.xml.dist
+ etc/ce-to-ee/log-document-groups.xml.dist
+ etc/ce-to-ee/settings.xml.dist
+ etc/ce-to-ee/map-customer.xml.dist
+ etc/ce-to-ee/customer-document-groups.xml.dist
+ etc/ce-to-ee/customer-attribute-groups.xml.dist
+ etc/ce-to-ee/deltalog.xml.dist
+ etc/ce-to-ee/order-grids-document-groups.xml.dist
+ etc/ce-to-ee/map-document-groups.xml.dist
+ etc/ce-to-ee/class-map.xml.dist
+ etc/ce-to-ee/1.9.3.4/map-tier-price.xml.dist
+
+ 0
+
+ 0
+
+
+ 0
+ migration.log
+ %percent%% [%bar%] Remaining Time: %remaining%
+ 1
+ ce-to-ee
+ 1.9.3.4
+ SET NAMES utf8;
+ SET NAMES utf8;
+
+
+
diff --git a/etc/ce-to-ee/1.9.3.4/map-tier-price.xml.dist b/etc/ce-to-ee/1.9.3.4/map-tier-price.xml.dist
new file mode 100644
index 000000000..db03f1ff0
--- /dev/null
+++ b/etc/ce-to-ee/1.9.3.4/map-tier-price.xml.dist
@@ -0,0 +1,25 @@
+
+
+
diff --git a/etc/ce-to-ee/1.9.3.4/map.xml.dist b/etc/ce-to-ee/1.9.3.4/map.xml.dist
new file mode 100644
index 000000000..633f0f0c0
--- /dev/null
+++ b/etc/ce-to-ee/1.9.3.4/map.xml.dist
@@ -0,0 +1,2873 @@
+
+
+
diff --git a/etc/ee-to-ee/1.11.0.0/config.xml.dist b/etc/ee-to-ee/1.11.0.0/config.xml.dist
index 9e5c6b89e..b6305eacc 100644
--- a/etc/ee-to-ee/1.11.0.0/config.xml.dist
+++ b/etc/ee-to-ee/1.11.0.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.11.0.1/config.xml.dist b/etc/ee-to-ee/1.11.0.1/config.xml.dist
index d746ee6e8..2f3b6b1fd 100644
--- a/etc/ee-to-ee/1.11.0.1/config.xml.dist
+++ b/etc/ee-to-ee/1.11.0.1/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.11.0.2/config.xml.dist b/etc/ee-to-ee/1.11.0.2/config.xml.dist
index 8111f8e6d..394cf6e0a 100644
--- a/etc/ee-to-ee/1.11.0.2/config.xml.dist
+++ b/etc/ee-to-ee/1.11.0.2/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.11.1.0/config.xml.dist b/etc/ee-to-ee/1.11.1.0/config.xml.dist
index 4869685b4..dee21bc59 100644
--- a/etc/ee-to-ee/1.11.1.0/config.xml.dist
+++ b/etc/ee-to-ee/1.11.1.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.11.2.0/config.xml.dist b/etc/ee-to-ee/1.11.2.0/config.xml.dist
index 499b59e01..1f79f1b09 100644
--- a/etc/ee-to-ee/1.11.2.0/config.xml.dist
+++ b/etc/ee-to-ee/1.11.2.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.12.0.0/config.xml.dist b/etc/ee-to-ee/1.12.0.0/config.xml.dist
index 9952f62e0..ce5e585c4 100644
--- a/etc/ee-to-ee/1.12.0.0/config.xml.dist
+++ b/etc/ee-to-ee/1.12.0.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.12.0.1/config.xml.dist b/etc/ee-to-ee/1.12.0.1/config.xml.dist
index 83c4c0ae1..309ec034f 100644
--- a/etc/ee-to-ee/1.12.0.1/config.xml.dist
+++ b/etc/ee-to-ee/1.12.0.1/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.12.0.2/config.xml.dist b/etc/ee-to-ee/1.12.0.2/config.xml.dist
index 24d233085..403aed820 100644
--- a/etc/ee-to-ee/1.12.0.2/config.xml.dist
+++ b/etc/ee-to-ee/1.12.0.2/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.13.0.0/config.xml.dist b/etc/ee-to-ee/1.13.0.0/config.xml.dist
index 23418e705..ee85a18e0 100644
--- a/etc/ee-to-ee/1.13.0.0/config.xml.dist
+++ b/etc/ee-to-ee/1.13.0.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.13.0.1/config.xml.dist b/etc/ee-to-ee/1.13.0.1/config.xml.dist
index a526fc2d9..0ad854229 100644
--- a/etc/ee-to-ee/1.13.0.1/config.xml.dist
+++ b/etc/ee-to-ee/1.13.0.1/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.13.0.2/config.xml.dist b/etc/ee-to-ee/1.13.0.2/config.xml.dist
index 73b692d2b..65c339b75 100644
--- a/etc/ee-to-ee/1.13.0.2/config.xml.dist
+++ b/etc/ee-to-ee/1.13.0.2/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.13.1.0/config.xml.dist b/etc/ee-to-ee/1.13.1.0/config.xml.dist
index 56575cf15..9d08719ce 100644
--- a/etc/ee-to-ee/1.13.1.0/config.xml.dist
+++ b/etc/ee-to-ee/1.13.1.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.0.0/config.xml.dist b/etc/ee-to-ee/1.14.0.0/config.xml.dist
index e5cb4d43d..8e20e8f3c 100644
--- a/etc/ee-to-ee/1.14.0.0/config.xml.dist
+++ b/etc/ee-to-ee/1.14.0.0/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.0.1/config.xml.dist b/etc/ee-to-ee/1.14.0.1/config.xml.dist
index 10c4b4bf8..f730ca6c2 100644
--- a/etc/ee-to-ee/1.14.0.1/config.xml.dist
+++ b/etc/ee-to-ee/1.14.0.1/config.xml.dist
@@ -96,6 +96,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.1.0/config.xml.dist b/etc/ee-to-ee/1.14.1.0/config.xml.dist
index dab7ebff7..b6fcbf7bf 100644
--- a/etc/ee-to-ee/1.14.1.0/config.xml.dist
+++ b/etc/ee-to-ee/1.14.1.0/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.2.0/config.xml.dist b/etc/ee-to-ee/1.14.2.0/config.xml.dist
index 66404fd3c..2d3275ca0 100644
--- a/etc/ee-to-ee/1.14.2.0/config.xml.dist
+++ b/etc/ee-to-ee/1.14.2.0/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.2.1/config.xml.dist b/etc/ee-to-ee/1.14.2.1/config.xml.dist
index 6fb1e242c..e3b2adb01 100644
--- a/etc/ee-to-ee/1.14.2.1/config.xml.dist
+++ b/etc/ee-to-ee/1.14.2.1/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.2.2/config.xml.dist b/etc/ee-to-ee/1.14.2.2/config.xml.dist
index f8beae5ad..95ce7e449 100644
--- a/etc/ee-to-ee/1.14.2.2/config.xml.dist
+++ b/etc/ee-to-ee/1.14.2.2/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.2.3/config.xml.dist b/etc/ee-to-ee/1.14.2.3/config.xml.dist
index cd6dabd28..9ce9e14a2 100644
--- a/etc/ee-to-ee/1.14.2.3/config.xml.dist
+++ b/etc/ee-to-ee/1.14.2.3/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.2.4/config.xml.dist b/etc/ee-to-ee/1.14.2.4/config.xml.dist
index 355722859..cb255d4d4 100644
--- a/etc/ee-to-ee/1.14.2.4/config.xml.dist
+++ b/etc/ee-to-ee/1.14.2.4/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.3.0/config.xml.dist b/etc/ee-to-ee/1.14.3.0/config.xml.dist
index da28d78d2..00d4a783b 100644
--- a/etc/ee-to-ee/1.14.3.0/config.xml.dist
+++ b/etc/ee-to-ee/1.14.3.0/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.3.1/config.xml.dist b/etc/ee-to-ee/1.14.3.1/config.xml.dist
index 7118acd4b..57ebc048b 100644
--- a/etc/ee-to-ee/1.14.3.1/config.xml.dist
+++ b/etc/ee-to-ee/1.14.3.1/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.3.2/config.xml.dist b/etc/ee-to-ee/1.14.3.2/config.xml.dist
index 142c027fa..05276d393 100644
--- a/etc/ee-to-ee/1.14.3.2/config.xml.dist
+++ b/etc/ee-to-ee/1.14.3.2/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.3.3/config.xml.dist b/etc/ee-to-ee/1.14.3.3/config.xml.dist
index 87eac3264..a027734af 100644
--- a/etc/ee-to-ee/1.14.3.3/config.xml.dist
+++ b/etc/ee-to-ee/1.14.3.3/config.xml.dist
@@ -101,6 +101,7 @@
Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
Migration\Step\Log\Delta
diff --git a/etc/ee-to-ee/1.14.3.4/config.xml.dist b/etc/ee-to-ee/1.14.3.4/config.xml.dist
new file mode 100644
index 000000000..9eede7163
--- /dev/null
+++ b/etc/ee-to-ee/1.14.3.4/config.xml.dist
@@ -0,0 +1,173 @@
+
+
+
+
+
+ Migration\Step\Settings\Integrity
+ Migration\Step\Settings\Data
+
+
+ Migration\Step\Stores\Integrity
+ Migration\Step\Stores\Data
+ Migration\Step\Stores\Volume
+
+
+
+
+ Migration\Step\DataIntegrity\Integrity
+
+
+ Migration\Step\Eav\Integrity
+ Migration\Step\Eav\Data
+ Migration\Step\Eav\Volume
+
+
+ Migration\Step\CustomCustomerAttributes\Integrity
+ Migration\Step\CustomCustomerAttributes\Data
+ Migration\Step\CustomCustomerAttributes\Volume
+
+
+ Migration\Step\Customer\Integrity
+ Migration\Step\Customer\Data
+ Migration\Step\Customer\Volume
+
+
+ Migration\Step\Map\Integrity
+ Migration\Step\Map\Data
+ Migration\Step\Map\Volume
+
+
+ Migration\Step\UrlRewrite\Version11410to2000
+ Migration\Step\UrlRewrite\Version11410to2000
+ Migration\Step\UrlRewrite\Version11410to2000
+
+
+ Migration\Step\Log\Integrity
+ Migration\Step\Log\Data
+ Migration\Step\Log\Volume
+
+
+ Migration\Step\Ratings\Integrity
+ Migration\Step\Ratings\Data
+ Migration\Step\Ratings\Volume
+
+
+ Migration\Step\SalesOrder\Integrity
+ Migration\Step\SalesOrder\Data
+ Migration\Step\SalesOrder\Volume
+
+
+ Migration\Step\ConfigurablePrices\Integrity
+ Migration\Step\ConfigurablePrices\Data
+ Migration\Step\ConfigurablePrices\Volume
+
+
+ Migration\Step\OrderGridsEE\Integrity
+ Migration\Step\OrderGridsEE\Data
+ Migration\Step\OrderGridsEE\Volume
+
+
+ Migration\Step\TierPrice\Integrity
+ Migration\Step\TierPrice\Data
+ Migration\Step\TierPrice\Volume
+
+
+ Migration\Step\SalesIncrement\Integrity
+ Migration\Step\SalesIncrement\Data
+ Migration\Step\SalesIncrement\Volume
+
+
+ Migration\Step\VisualMerchandiser\Integrity
+ Migration\Step\VisualMerchandiser\Data
+ Migration\Step\VisualMerchandiser\Volume
+
+
+ Migration\Step\PostProcessing\Data
+
+
+
+
+ Migration\Step\CustomCustomerAttributes\Delta
+ Migration\Step\CustomCustomerAttributes\Volume
+
+
+ Migration\Step\Customer\Delta
+ Migration\Step\Customer\Volume
+
+
+ Migration\Step\Map\Delta
+ Migration\Step\Map\Volume
+
+
+ Migration\Step\Log\Delta
+ Migration\Step\Log\Volume
+
+
+ Migration\Step\SalesOrder\Delta
+ Migration\Step\SalesOrder\Volume
+
+
+ Migration\Step\OrderGridsEE\Delta
+ Migration\Step\OrderGridsEE\Volume
+
+
+ Migration\Step\SalesIncrement\Delta
+ Migration\Step\SalesIncrement\Volume
+
+
+
+
+
+
+
+ etc/ee-to-ee/1.14.3.4/map.xml.dist
+ etc/ee-to-ee/map-eav.xml.dist
+ etc/ee-to-ee/eav-document-groups.xml.dist
+ etc/ee-to-ee/eav-attribute-groups.xml.dist
+ etc/ee-to-ee/map-log.xml.dist
+ etc/ee-to-ee/log-document-groups.xml.dist
+ etc/ee-to-ee/settings.xml.dist
+ etc/ee-to-ee/map-customer.xml.dist
+ etc/ee-to-ee/customer-document-groups.xml.dist
+ etc/ee-to-ee/customer-attribute-groups.xml.dist
+ etc/ee-to-ee/map-sales.xml.dist
+ etc/ee-to-ee/deltalog.xml.dist
+ etc/ee-to-ee/customer-attr-map.xml.dist
+ etc/ee-to-ee/customer-attr-document-groups.xml.dist
+ etc/ee-to-ee/order-grids-document-groups.xml.dist
+ etc/ee-to-ee/class-map.xml.dist
+ etc/ee-to-ee/visual_merchandiser_map.xml.dist
+ etc/ee-to-ee/visual_merchandiser_document_groups.xml.dist
+ etc/ee-to-ee/visual_merchandiser_attribute_groups.xml.dist
+ etc/ee-to-ee/map-document-groups.xml.dist
+ etc/ee-to-ee/1.14.3.4/map-tier-price.xml.dist
+
+ 0
+
+ 0
+
+
+ 0
+ migration.log
+ %percent%% [%bar%] Remaining Time: %remaining%
+ 1
+ ee-to-ee
+ 1.14.3.4
+ SET NAMES utf8;
+ SET NAMES utf8;
+
+
+
diff --git a/etc/ee-to-ee/1.14.3.4/map-tier-price.xml.dist b/etc/ee-to-ee/1.14.3.4/map-tier-price.xml.dist
new file mode 100644
index 000000000..db03f1ff0
--- /dev/null
+++ b/etc/ee-to-ee/1.14.3.4/map-tier-price.xml.dist
@@ -0,0 +1,25 @@
+
+
+
diff --git a/etc/ee-to-ee/1.14.3.4/map.xml.dist b/etc/ee-to-ee/1.14.3.4/map.xml.dist
new file mode 100644
index 000000000..0f0f0768c
--- /dev/null
+++ b/etc/ee-to-ee/1.14.3.4/map.xml.dist
@@ -0,0 +1,2566 @@
+
+
+
diff --git a/src/Migration/App/SetupDeltaLog.php b/src/Migration/App/SetupDeltaLog.php
index deab4f6de..ad4f77aab 100644
--- a/src/Migration/App/SetupDeltaLog.php
+++ b/src/Migration/App/SetupDeltaLog.php
@@ -8,6 +8,7 @@
use Migration\Reader\Groups;
use Migration\App\Step\StageInterface;
use Migration\ResourceModel\Source;
+use Migration\Logger\Logger;
class SetupDeltaLog implements StageInterface
{
@@ -31,19 +32,27 @@ class SetupDeltaLog implements StageInterface
*/
private $groupsFactory;
+ /**
+ * @var Logger
+ */
+ private $logger;
+
/**
* @param Source $source
* @param \Migration\Reader\GroupsFactory $groupsFactory
* @param ProgressBar\LogLevelProcessor $progress
+ * @param Logger $logger
*/
public function __construct(
Source $source,
\Migration\Reader\GroupsFactory $groupsFactory,
- ProgressBar\LogLevelProcessor $progress
+ ProgressBar\LogLevelProcessor $progress,
+ Logger $logger
) {
$this->source = $source;
$this->groupsFactory = $groupsFactory;
$this->progress = $progress;
+ $this->logger = $logger;
}
/**
@@ -51,17 +60,29 @@ public function __construct(
*/
public function perform()
{
+ $countDeltaDocuments = 0;
+ $countDeltaDocumentsCreated = 0;
$deltaLogs = $this->getGroupsReader()->getGroups();
$this->progress->start(count($deltaLogs, 1) - count($deltaLogs));
foreach ($deltaLogs as $deltaDocuments) {
foreach ($deltaDocuments as $documentName => $idKey) {
$this->progress->advance();
+ $countDeltaDocuments++;
if ($this->source->getDocument($documentName)) {
- $this->source->createDelta($documentName, $idKey);
+ $countDeltaDocumentsCreated += (int) $this->source->createDelta($documentName, $idKey);
}
}
}
$this->progress->finish();
+ if ($countDeltaDocuments != $countDeltaDocumentsCreated) {
+ $this->logger->warning(
+ sprintf(
+ 'Some of the delta log tables were not created. Expected:%s. Actual:%s',
+ $countDeltaDocuments,
+ $countDeltaDocumentsCreated
+ )
+ );
+ }
return true;
}
diff --git a/src/Migration/ResourceModel/Adapter/Mysql.php b/src/Migration/ResourceModel/Adapter/Mysql.php
index cb4ef7d39..6bbf0bbf1 100644
--- a/src/Migration/ResourceModel/Adapter/Mysql.php
+++ b/src/Migration/ResourceModel/Adapter/Mysql.php
@@ -360,10 +360,11 @@ public function deleteBackup($documentName)
* @param string $documentName
* @param string $deltaLogName
* @param string $idKey
- * @return void
+ * @return boolean
*/
public function createDelta($documentName, $deltaLogName, $idKey)
{
+ $deltaCreated = true;
if (!$this->resourceAdapter->isTableExists($deltaLogName)) {
$triggerTable = $this->resourceAdapter->newTable($deltaLogName)
->addColumn(
@@ -381,6 +382,7 @@ public function createDelta($documentName, $deltaLogName, $idKey)
['nullable' => false, 'default' => 0]
);
$this->resourceAdapter->createTable($triggerTable);
+ $deltaCreated = $this->resourceAdapter->isTableExists($deltaLogName);
} else {
$this->deleteAllRecords($deltaLogName);
}
@@ -412,6 +414,7 @@ public function createDelta($documentName, $deltaLogName, $idKey)
}
unset($trigger);
}
+ return $deltaCreated;
}
/**
diff --git a/src/Migration/ResourceModel/AdapterInterface.php b/src/Migration/ResourceModel/AdapterInterface.php
index eeda07b44..ed5ad14dc 100644
--- a/src/Migration/ResourceModel/AdapterInterface.php
+++ b/src/Migration/ResourceModel/AdapterInterface.php
@@ -147,7 +147,7 @@ public function deleteBackup($documentName);
* @param string $documentName
* @param string $deltaLogName
* @param string $idKey
- * @return void
+ * @return boolean
*/
public function createDelta($documentName, $deltaLogName, $idKey);
diff --git a/src/Migration/ResourceModel/Record.php b/src/Migration/ResourceModel/Record.php
index 5b7ac7846..d6402fe49 100644
--- a/src/Migration/ResourceModel/Record.php
+++ b/src/Migration/ResourceModel/Record.php
@@ -104,6 +104,25 @@ public function getValue($columnName)
return isset($this->data[$columnName]) ? $this->data[$columnName] : null;
}
+ /**
+ * Get column default value
+ *
+ * @param string $columnName
+ * @return mixed
+ * @throws Exception
+ */
+ public function getValueDefault($columnName)
+ {
+ if ($this->structure && !$this->structure->hasField($columnName)) {
+ throw new Exception("Record structure does not contain field $columnName");
+ }
+ $fields = $this->structure->getFields();
+ if ($fields[$columnName]['DEFAULT'] === null && $fields[$columnName]['NULLABLE'] === false) {
+ return '';
+ }
+ return $fields[$columnName]['DEFAULT'];
+ }
+
/**
* Set column value
*
@@ -147,6 +166,24 @@ public function getData()
return $this->data;
}
+ /**
+ * Get record default data
+ *
+ * @return array
+ */
+ public function getDataDefault()
+ {
+ $fields = [];
+ foreach ($this->structure->getFields() as $code => $structure) {
+ if ($structure['DEFAULT'] === null && $structure['NULLABLE'] === false) {
+ $fields[$code] = '';
+ } else {
+ $fields[$code] = $structure['DEFAULT'];
+ }
+ }
+ return $fields;
+ }
+
/**
* @return array
* @throws Exception
diff --git a/src/Migration/ResourceModel/Source.php b/src/Migration/ResourceModel/Source.php
index eb41742f1..3767e38d9 100644
--- a/src/Migration/ResourceModel/Source.php
+++ b/src/Migration/ResourceModel/Source.php
@@ -125,15 +125,16 @@ protected function getIdentityField($documentName)
*
* @param string $documentName
* @param string $idKey
- * @return void
+ * @return boolean
*/
public function createDelta($documentName, $idKey)
{
- $this->getAdapter()->createDelta(
+ $result = $this->getAdapter()->createDelta(
$this->addDocumentPrefix($documentName),
$this->addDocumentPrefix($this->getDeltaLogName($documentName)),
$idKey
);
+ return $result;
}
/**
diff --git a/src/Migration/Step/Customer/Helper.php b/src/Migration/Step/Customer/Helper.php
index bca4846ea..3b84a81ee 100644
--- a/src/Migration/Step/Customer/Helper.php
+++ b/src/Migration/Step/Customer/Helper.php
@@ -252,6 +252,7 @@ public function updateAttributeData(
*/
protected function getFieldsWithDefaultValues($attributeCodes, $destinationDocName)
{
+ $destinationDocName = $this->destination->addDocumentPrefix($destinationDocName);
/** @var Mysql $adapter */
$adapter = $this->destination->getAdapter();
$structure = $adapter->getDocumentStructure($destinationDocName);
diff --git a/src/Migration/Step/Eav/Data.php b/src/Migration/Step/Eav/Data.php
index 4667c8199..3e31e60a1 100644
--- a/src/Migration/Step/Eav/Data.php
+++ b/src/Migration/Step/Eav/Data.php
@@ -223,7 +223,7 @@ protected function migrateEntityTypes()
$destinationRecordData = $destinationRecords[$mappingValue];
unset($destinationRecords[$mappingValue]);
} else {
- $destinationRecordData = array_fill_keys($destinationRecord->getFields(), null);
+ $destinationRecordData = $destinationRecord->getDataDefault();
}
$destinationRecord->setData($destinationRecordData);
$this->helper->getRecordTransformer($sourceDocument, $destinationDocument)
@@ -436,7 +436,7 @@ protected function migrateAttributes()
$destinationRecordData = $destinationRecords[$mappedKey];
unset($destinationRecords[$mappedKey]);
} else {
- $destinationRecordData = array_fill_keys($destinationRecord->getFields(), null);
+ $destinationRecordData = $destinationRecord->getDataDefault();
}
$destinationRecord->setData($destinationRecordData);
@@ -799,7 +799,7 @@ protected function migrateAttributesExtended()
$destinationRecordData = $destinationRecords[$mappedId];
unset($destinationRecords[$mappedId]);
} else {
- $destinationRecordData = array_fill_keys($destinationRecord->getFields(), null);
+ $destinationRecordData = $destinationRecord->getDataDefault();
}
$destinationRecord->setData($destinationRecordData);
$this->helper->getRecordTransformer($sourceDocument, $destinationDocument)
diff --git a/src/Migration/Step/OrderGridsEE/Delta.php b/src/Migration/Step/OrderGridsEE/Delta.php
index a2ea24b6a..543ce002e 100644
--- a/src/Migration/Step/OrderGridsEE/Delta.php
+++ b/src/Migration/Step/OrderGridsEE/Delta.php
@@ -49,7 +49,7 @@ public function perform()
if ($this->source->getRecordsCount($this->source->getDeltaLogName($sourceDocName)) == 0) {
continue;
}
- $items = $this->source->getDeletedRecords($sourceDocName, $idKey, 0, true);
+ $items = $this->source->getChangedRecords($sourceDocName, $idKey, 0, true);
if (empty($items)) {
continue;
}
diff --git a/src/Migration/Step/UrlRewrite/Model/Suffix.php b/src/Migration/Step/UrlRewrite/Model/Suffix.php
new file mode 100644
index 000000000..71c7bb717
--- /dev/null
+++ b/src/Migration/Step/UrlRewrite/Model/Suffix.php
@@ -0,0 +1,100 @@
+source = $source;
+ }
+
+ /**
+ * Get suffix query for product or category
+ *
+ * @param string $suffixFor Can be 'product' or 'category'
+ * @param string $mainTable
+ * @return string
+ */
+ public function getSuffix($suffixFor, $mainTable = 's')
+ {
+ $suffixDefault = '.html';
+ if (empty($this->suffixData[$suffixFor])) {
+ /** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
+ $adapter = $this->source->getAdapter();
+ $select = $adapter->getSelect();
+
+ $select->from(
+ ['s' => $this->source->addDocumentPrefix('core_store')],
+ ['store_id' => 's.store_id']
+ );
+
+ $select->joinLeft(
+ ['c1' => $this->source->addDocumentPrefix('core_config_data')],
+ "c1.scope='stores' AND c1.path = 'catalog/seo/{$suffixFor}_url_suffix' AND c1.scope_id=s.store_id",
+ ['store_path' => 'c1.path', 'store_value' => 'c1.value']
+ );
+ $select->joinLeft(
+ ['c2' => $this->source->addDocumentPrefix('core_config_data')],
+ "c2.scope='websites' AND c2.path = 'catalog/seo/{$suffixFor}_url_suffix' AND c2.scope_id=s.website_id",
+ ['website_path' => 'c2.path', 'website_value' => 'c2.value']
+ );
+ $select->joinLeft(
+ ['c3' => $this->source->addDocumentPrefix('core_config_data')],
+ "c3.scope='default' AND c3.path = 'catalog/seo/{$suffixFor}_url_suffix'",
+ ['admin_path' => 'c3.path', 'admin_value' => 'c3.value']
+ );
+
+ $result = $select->getAdapter()->fetchAll($select);
+ foreach ($result as $row) {
+ $suffix = $suffixDefault;
+ if ($row['admin_path'] !== null) {
+ $suffix = $row['admin_value'];
+ }
+ if ($row['website_path'] !== null) {
+ $suffix = $row['website_value'];
+ }
+ if ($row['store_path'] !== null) {
+ $suffix = $row['store_value'];
+ }
+ $this->suffixData[$suffixFor][] = [
+ 'store_id' => $row['store_id'],
+ 'suffix' => $suffix
+ ];
+ }
+ }
+
+ $suffix = "CASE {$mainTable}.store_id";
+ foreach ($this->suffixData[$suffixFor] as $row) {
+ $suffix .= sprintf(" WHEN '%s' THEN '%s'", $row['store_id'], $row['suffix']);
+ }
+ $suffix .= " ELSE '{$suffixDefault}' END";
+
+ return $suffix;
+ }
+}
diff --git a/src/Migration/Step/UrlRewrite/Model/TemporaryTable.php b/src/Migration/Step/UrlRewrite/Model/TemporaryTable.php
new file mode 100644
index 000000000..d136c6ba3
--- /dev/null
+++ b/src/Migration/Step/UrlRewrite/Model/TemporaryTable.php
@@ -0,0 +1,124 @@
+source = $source;
+ $this->sourceAdapter = $this->source->getAdapter();
+ $this->tableName = 'url_rewrite_m2' . md5('url_rewrite_m2');
+ }
+
+ /**
+ * Return name of temporary table
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->tableName;
+ }
+
+ /**
+ * Crete temporary table
+ *
+ * @return void
+ */
+ public function create()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $select->getAdapter()->dropTable($this->source->addDocumentPrefix($this->tableName));
+ /** @var \Magento\Framework\DB\Ddl\Table $table */
+ $table = $select->getAdapter()->newTable($this->source->addDocumentPrefix($this->tableName))
+ ->addColumn(
+ 'id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
+ null,
+ ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
+ )
+ ->addColumn(
+ 'request_path',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 255
+ )
+ ->addColumn(
+ 'target_path',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 255
+ )
+ ->addColumn(
+ 'is_system',
+ \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
+ null,
+ ['nullable' => false, 'default' => '0']
+ )
+ ->addColumn(
+ 'store_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
+ )
+ ->addColumn(
+ 'entity_type',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 32
+ )
+ ->addColumn(
+ 'redirect_type',
+ \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
+ null,
+ ['unsigned' => true, 'nullable' => false, 'default' => '0']
+ )
+ ->addColumn(
+ 'product_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
+ )
+ ->addColumn(
+ 'category_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
+ )
+ ->addColumn(
+ 'cms_page_id',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
+ )
+ ->addColumn(
+ 'priority',
+ \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
+ )
+ ->addIndex(
+ 'url_rewrite',
+ ['request_path', 'target_path', 'store_id'],
+ ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
+ ) ;
+ $select->getAdapter()->createTable($table);
+ }
+}
diff --git a/src/Migration/Step/UrlRewrite/Model/Version11300to2000/ProductRewritesIncludedIntoCategories.php b/src/Migration/Step/UrlRewrite/Model/Version11300to2000/ProductRewritesIncludedIntoCategories.php
new file mode 100644
index 000000000..d1ec615dd
--- /dev/null
+++ b/src/Migration/Step/UrlRewrite/Model/Version11300to2000/ProductRewritesIncludedIntoCategories.php
@@ -0,0 +1,231 @@
+source = $source;
+ $this->sourceAdapter = $this->source->getAdapter();
+ $this->suffix = $suffix;
+ $this->temporaryTable = $temporaryTable;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for default scope
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForDefaultScope()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $storeSubSelect = $this->getStoreSubSelect();
+ $categoriesSubSelect = $this->getCategoriesSubSelect();
+ $subConcatCategories = $select->getAdapter()->getConcatSql([
+ "($categoriesSubSelect)",
+ "'/'",
+ '`r`.`request_path`',
+ $this->suffix->getSuffix('product')
+ ]);
+ $targetPath = 'IF(ISNULL(c.category_id), r.target_path, CONCAT(r.target_path, "/category/", c.category_id))';
+ $select = $this->sourceAdapter->getSelect();
+ $select->from(
+ ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcatCategories,
+ 'target_path' => $targetPath,
+ 'is_system' => 'r.is_system',
+ 'store_id' => 's.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "c.category_id",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
+ 'ecpr.url_rewrite_id = r.url_rewrite_id',
+ []
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'r.value_id = p.value_id',
+ []
+ );
+ $select->join(
+ ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
+ 'p.entity_id = c.product_id',
+ []
+ );
+ $select->join(
+ ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
+ 'cu.entity_id = c.category_id',
+ []
+ );
+ $select->join(
+ ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
+ 'c.product_id = cpw.product_id',
+ []
+ );
+ $select->join(
+ ['s' => $this->source->addDocumentPrefix('core_store')],
+ sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
+ []
+ );
+ $select->where('`ecpr`.`store_id` = 0');
+
+ $query = $this->sourceAdapter->getSelect()->from(['result' => new \Zend_Db_Expr("($select)")])
+ ->where('result.request_path IS NOT NULL')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for particular store view
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForParticularStoreView()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $categoriesSubSelect = $this->getCategoriesSubSelect();
+ $subConcatCategories = $select->getAdapter()->getConcatSql([
+ "($categoriesSubSelect)",
+ "'/'",
+ '`s`.`request_path`',
+ $this->suffix->getSuffix('product', 'ecpr')
+ ]);
+ $select->from(
+ ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcatCategories,
+ 'target_path' => 's.target_path',
+ 'is_system' => 's.is_system',
+ 'store_id' => 'ecpr.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "c.category_id",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
+ 'ecpr.url_rewrite_id = s.url_rewrite_id',
+ []
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 's.value_id = p.value_id and `p`.`store_id` = ecpr.store_id',
+ []
+ );
+ $select->join(
+ ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
+ 'p.entity_id = c.product_id',
+ []
+ );
+ $select->join(
+ ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
+ 'cu.entity_id = c.category_id and cu.store_id = ecpr.store_id',
+ []
+ );
+ $query = $select
+ ->where('`ecpr`.`store_id` > 0')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return select for product url rewrite where store above 0
+ *
+ * @return DbSelect
+ */
+ private function getStoreSubSelect()
+ {
+ $storeSubSelect = $this->sourceAdapter->getSelect();
+ $storeSubSelect->from(
+ ['sr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ ['store_id' => 'ecpr.store_id']
+ );
+ $storeSubSelect->join(
+ ['srcu' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'srcu.value_id = sr.value_id',
+ []
+ );
+ $storeSubSelect->join(
+ ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
+ 'ecpr.url_rewrite_id = sr.url_rewrite_id',
+ []
+ );
+ $storeSubSelect
+ ->where('srcu.entity_id = p.entity_id')
+ ->where('ecpr.store_id > 0');
+ return $storeSubSelect;
+ }
+
+ /**
+ * Return sub-select for categories url rewrite
+ *
+ * @return DbSelect
+ */
+ private function getCategoriesSubSelect()
+ {
+ $subSelect = $this->sourceAdapter->getSelect();
+ $subSelect->from(
+ ['cr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ ['request_path' => 'cr.request_path']
+ );
+ $subSelect->join(
+ ['ccr' => $this->source->addDocumentPrefix('enterprise_catalog_category_rewrite')],
+ 'ccr.url_rewrite_id = cr.url_rewrite_id',
+ []
+ );
+ $subSelect->where('`cr`.`value_id` = `cu`.`value_id`');
+ $subSelect->where('`ccr`.`store_id` = ecpr.`store_id`');
+ return $subSelect;
+ }
+}
diff --git a/src/Migration/Step/UrlRewrite/Model/Version11300to2000/ProductRewritesWithoutCategories.php b/src/Migration/Step/UrlRewrite/Model/Version11300to2000/ProductRewritesWithoutCategories.php
new file mode 100644
index 000000000..c56e2bfde
--- /dev/null
+++ b/src/Migration/Step/UrlRewrite/Model/Version11300to2000/ProductRewritesWithoutCategories.php
@@ -0,0 +1,180 @@
+source = $source;
+ $this->sourceAdapter = $this->source->getAdapter();
+ $this->suffix = $suffix;
+ $this->temporaryTable = $temporaryTable;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for default scope
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForDefaultScope()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $storeSubSelect = $this->getStoreSubSelect();
+ $subConcat = $select->getAdapter()->getConcatSql([
+ '`r`.`request_path`',
+ $this->suffix->getSuffix('product')
+ ]);
+
+ $select->from(
+ ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcat,
+ 'target_path' => 'r.target_path',
+ 'is_system' => 'r.is_system',
+ 'store_id' => 's.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "trim('0')",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
+ 'ecpr.url_rewrite_id = r.url_rewrite_id',
+ []
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'r.value_id = p.value_id',
+ []
+ );
+ $select->join(
+ ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
+ 'p.entity_id = cpw.product_id',
+ []
+ );
+ $select->join(
+ ['s' => $this->source->addDocumentPrefix('core_store')],
+ sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
+ []
+ );
+ $query = $select
+ ->where('`ecpr`.`store_id` = 0')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for particular store view
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForParticularStoreView()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $subConcat = $select->getAdapter()->getConcatSql([
+ '`s`.`request_path`',
+ $this->suffix->getSuffix('product', 'ecpr')
+ ]);
+ $select->from(
+ ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcat,
+ 'target_path' => 's.target_path',
+ 'is_system' => 's.is_system',
+ 'store_id' => 'ecpr.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "trim('0')",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
+ 'ecpr.url_rewrite_id = s.url_rewrite_id',
+ []
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 's.value_id = p.value_id',
+ []
+ );
+ $query = $select
+ ->where('`ecpr`.`store_id` > 0')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return select for product url rewrite where store above 0
+ *
+ * @return DbSelect
+ */
+ private function getStoreSubSelect()
+ {
+ $storeSubSelect = $this->sourceAdapter->getSelect();
+ $storeSubSelect->from(
+ ['sr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ ['store_id' => 'ecpr.store_id']
+ );
+ $storeSubSelect->join(
+ ['srcu' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'srcu.value_id = sr.value_id',
+ []
+ );
+ $storeSubSelect->join(
+ ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
+ 'ecpr.url_rewrite_id = sr.url_rewrite_id',
+ []
+ );
+ $storeSubSelect
+ ->where('srcu.entity_id = p.entity_id')
+ ->where('ecpr.store_id > 0');
+ return $storeSubSelect;
+ }
+}
diff --git a/src/Migration/Step/UrlRewrite/Model/Version11410to2000/ProductRewritesIncludedIntoCategories.php b/src/Migration/Step/UrlRewrite/Model/Version11410to2000/ProductRewritesIncludedIntoCategories.php
new file mode 100644
index 000000000..91538c0fb
--- /dev/null
+++ b/src/Migration/Step/UrlRewrite/Model/Version11410to2000/ProductRewritesIncludedIntoCategories.php
@@ -0,0 +1,213 @@
+source = $source;
+ $this->sourceAdapter = $this->source->getAdapter();
+ $this->suffix = $suffix;
+ $this->temporaryTable = $temporaryTable;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for default scope
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForDefaultScope()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $storeSubSelect = $this->getStoreSubSelect();
+ $categoriesSubSelect = $this->getCategoriesSubSelect();
+ $subConcatCategories = $select->getAdapter()->getConcatSql([
+ "($categoriesSubSelect)",
+ "'/'",
+ '`r`.`request_path`',
+ $this->suffix->getSuffix('product')
+ ]);
+ $targetPath = 'IF(ISNULL(c.category_id), r.target_path, CONCAT(r.target_path, "/category/", c.category_id))';
+ $select = $this->sourceAdapter->getSelect();
+ $select->from(
+ ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcatCategories,
+ 'target_path' => $targetPath,
+ 'is_system' => 'r.is_system',
+ 'store_id' => 's.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "c.category_id",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'r.value_id = p.value_id',
+ []
+ );
+ $select->join(
+ ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
+ 'p.entity_id = c.product_id',
+ []
+ );
+ $select->join(
+ ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
+ 'cu.entity_id = c.category_id',
+ []
+ );
+ $select->join(
+ ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
+ 'c.product_id = cpw.product_id',
+ []
+ );
+ $select->join(
+ ['s' => $this->source->addDocumentPrefix('core_store')],
+ sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
+ []
+ );
+ $select->where('`r`.`entity_type` = 3')->where('`r`.`store_id` = 0');
+
+ $query = $this->sourceAdapter->getSelect()->from(['result' => new \Zend_Db_Expr("($select)")])
+ ->where('result.request_path IS NOT NULL')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()))
+ ;
+ return $query;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for particular store view
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForParticularStoreView()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $categoriesSubSelect = $this->getCategoriesSubSelect();
+ $subConcatCategories = $select->getAdapter()->getConcatSql([
+ "($categoriesSubSelect)",
+ "'/'",
+ '`s`.`request_path`',
+ $this->suffix->getSuffix('product')
+ ]);
+ $select->from(
+ ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcatCategories,
+ 'target_path' => 's.target_path',
+ 'is_system' => 's.is_system',
+ 'store_id' => 's.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "c.category_id",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 's.value_id = p.value_id',
+ []
+ );
+ $select->join(
+ ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
+ 'p.entity_id = c.product_id',
+ []
+ );
+ $select->join(
+ ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
+ 'cu.entity_id = c.category_id',
+ []
+ );
+ $query = $select->where('`s`.`entity_type` = 3')
+ ->where('`s`.`store_id` > 0')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return select for product url rewrite where store above 0
+ *
+ * @return DbSelect
+ */
+ private function getStoreSubSelect()
+ {
+ $storeSubSelect = $this->sourceAdapter->getSelect();
+ $storeSubSelect->from(
+ ['sr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ ['store_id' => 'sr.store_id']
+ );
+ $storeSubSelect->join(
+ ['srcu' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'srcu.value_id = sr.value_id',
+ []
+ );
+ $storeSubSelect->where('sr.entity_type = 3')
+ ->where('srcu.entity_id = p.entity_id')
+ ->where('sr.store_id > 0');
+ return $storeSubSelect;
+ }
+
+ /**
+ * Return sub-select for categories url rewrite
+ *
+ * @return DbSelect
+ */
+ private function getCategoriesSubSelect()
+ {
+ $subSelect = $this->sourceAdapter->getSelect();
+ $subSelect->from(
+ ['cr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ ['request_path' => 'cr.request_path']
+ );
+ $subSelect->where('`cr`.`value_id` = `cu`.`value_id`');
+ $subSelect->where('`cr`.`entity_type` = 2');
+ $subSelect->where('`cr`.`store_id` = s.`store_id`');
+ return $subSelect;
+ }
+}
diff --git a/src/Migration/Step/UrlRewrite/Model/Version11410to2000/ProductRewritesWithoutCategories.php b/src/Migration/Step/UrlRewrite/Model/Version11410to2000/ProductRewritesWithoutCategories.php
new file mode 100644
index 000000000..bf265be54
--- /dev/null
+++ b/src/Migration/Step/UrlRewrite/Model/Version11410to2000/ProductRewritesWithoutCategories.php
@@ -0,0 +1,165 @@
+source = $source;
+ $this->sourceAdapter = $this->source->getAdapter();
+ $this->suffix = $suffix;
+ $this->temporaryTable = $temporaryTable;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for default scope
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForDefaultScope()
+ {
+ $storeSubSelect = $this->getStoreSubSelect();
+ $subConcat = $this->sourceAdapter->getSelect()->getAdapter()->getConcatSql([
+ '`r`.`request_path`',
+ $this->suffix->getSuffix('product')
+ ]);
+
+ $select = $this->sourceAdapter->getSelect();
+ $select->from(
+ ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcat,
+ 'target_path' => 'r.target_path',
+ 'is_system' => 'r.is_system',
+ 'store_id' => 's.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "trim('0')",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'r.value_id = p.value_id',
+ []
+ );
+ $select->join(
+ ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
+ 'p.entity_id = cpw.product_id',
+ []
+ );
+ $select->join(
+ ['s' => $this->source->addDocumentPrefix('core_store')],
+ sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
+ []
+ );
+ $query = $select->where('`r`.`entity_type` = 3')
+ ->where('`r`.`store_id` = 0')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return query for retrieving product url rewrites
+ * when a product is saved for particular store view
+ *
+ * @return string
+ */
+ public function getQueryProductsSavedForParticularStoreView()
+ {
+ $select = $this->sourceAdapter->getSelect();
+ $subConcat = $select->getAdapter()->getConcatSql([
+ '`s`.`request_path`',
+ $this->suffix->getSuffix('product')
+ ]);
+ $select->from(
+ ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ [
+ 'id' => 'IFNULL(NULL, NULL)',
+ 'request_path' => $subConcat,
+ 'target_path' => 's.target_path',
+ 'is_system' => 's.is_system',
+ 'store_id' => 's.store_id',
+ 'entity_type' => "trim('product')",
+ 'redirect_type' => "trim('0')",
+ 'product_id' => "p.entity_id",
+ 'category_id' => "trim('0')",
+ 'cms_page_id' => "trim('0')",
+ 'priority' => "trim('4')"
+ ]
+ );
+ $select->join(
+ ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 's.value_id = p.value_id',
+ []
+ );
+ $query = $select->where('`s`.`entity_type` = 3')
+ ->where('`s`.`store_id` > 0')
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
+ return $query;
+ }
+
+ /**
+ * Return select for product url rewrite where store above 0
+ *
+ * @return DbSelect
+ */
+ private function getStoreSubSelect()
+ {
+ $storeSubSelect = $this->sourceAdapter->getSelect();
+ $storeSubSelect->from(
+ ['sr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
+ ['store_id' => 'sr.store_id']
+ );
+ $storeSubSelect->join(
+ ['srcu' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
+ 'srcu.value_id = sr.value_id',
+ []
+ );
+ $storeSubSelect->where('sr.entity_type = 3')
+ ->where('srcu.entity_id = p.entity_id')
+ ->where('sr.store_id > 0');
+ return $storeSubSelect;
+ }
+}
diff --git a/src/Migration/Step/UrlRewrite/Version11300to2000.php b/src/Migration/Step/UrlRewrite/Version11300to2000.php
index 0e253e014..277044979 100644
--- a/src/Migration/Step/UrlRewrite/Version11300to2000.php
+++ b/src/Migration/Step/UrlRewrite/Version11300to2000.php
@@ -10,22 +10,18 @@
use Migration\Reader\MapInterface;
use Migration\Step\DatabaseStage;
use Migration\ResourceModel\Document;
+use Migration\Step\UrlRewrite\Model;
/**
* Class Version11300to2000
- * @SuppressWarnings(PHPMD.TooManyFields)
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD)
*/
class Version11300to2000 extends DatabaseStage implements StageInterface, RollbackInterface
{
/**
- * Temporary table name
- *
- * @var string
+ * @var Model\TemporaryTable
*/
- protected $tableName;
+ private $temporaryTable;
/**
* @var string
@@ -109,6 +105,21 @@ class Version11300to2000 extends DatabaseStage implements StageInterface, Rollba
*/
protected $helper;
+ /**
+ * @var Model\Version11300to2000\ProductRewritesIncludedIntoCategories
+ */
+ private $productRewritesIncludedIntoCategories;
+
+ /**
+ * @var Model\Version11300to2000\ProductRewritesWithoutCategories
+ */
+ private $productRewritesWithoutCategories;
+
+ /**
+ * @var Model\Suffix
+ */
+ private $suffix;
+
/**
* @var array
*/
@@ -192,6 +203,10 @@ class Version11300to2000 extends DatabaseStage implements StageInterface, Rollba
* @param \Migration\ResourceModel\Record\CollectionFactory $recordCollectionFactory
* @param \Migration\ResourceModel\RecordFactory $recordFactory
* @param \Migration\Step\UrlRewrite\Helper $helper
+ * @param Model\Version11300to2000\ProductRewritesWithoutCategories $productRewritesWithoutCategories
+ * @param Model\Version11300to2000\ProductRewritesIncludedIntoCategories $productRewritesIncludedIntoCategories
+ * @param Model\Suffix $suffix
+ * @param Model\TemporaryTable $temporaryTable
* @param string $stage
* @throws \Migration\Exception
*/
@@ -204,6 +219,10 @@ public function __construct(
\Migration\ResourceModel\Record\CollectionFactory $recordCollectionFactory,
\Migration\ResourceModel\RecordFactory $recordFactory,
\Migration\Step\UrlRewrite\Helper $helper,
+ Model\Version11300to2000\ProductRewritesWithoutCategories $productRewritesWithoutCategories,
+ Model\Version11300to2000\ProductRewritesIncludedIntoCategories $productRewritesIncludedIntoCategories,
+ Model\Suffix $suffix,
+ Model\TemporaryTable $temporaryTable,
$stage
) {
$this->progress = $progress;
@@ -212,9 +231,12 @@ public function __construct(
$this->destination = $destination;
$this->recordCollectionFactory = $recordCollectionFactory;
$this->recordFactory = $recordFactory;
- $this->tableName = 'url_rewrite_m2' . md5('url_rewrite_m2');
+ $this->temporaryTable = $temporaryTable;
$this->stage = $stage;
$this->helper = $helper;
+ $this->productRewritesWithoutCategories = $productRewritesWithoutCategories;
+ $this->productRewritesIncludedIntoCategories = $productRewritesIncludedIntoCategories;
+ $this->suffix = $suffix;
parent::__construct($config);
}
@@ -242,7 +264,7 @@ protected function data()
$this->progress->start($this->getIterationsCount());
$this->destination->clearDocument('url_rewrite');
- $sourceDocument = $this->source->getDocument($this->tableName);
+ $sourceDocument = $this->source->getDocument($this->temporaryTable->getName());
$destinationDocument = $this->destination->getDocument('url_rewrite');
$destProductCategory = $this->destination->getDocument('catalog_url_rewrite_product_category');
@@ -311,7 +333,7 @@ protected function getRewritesSelect()
/** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
$adapter = $this->source->getAdapter();
$select = $adapter->getSelect();
- $select->from(['r' => $this->source->addDocumentPrefix($this->tableName)]);
+ $select->from(['r' => $this->source->addDocumentPrefix($this->temporaryTable->getName())]);
return $select;
}
@@ -328,7 +350,7 @@ protected function migrateRewrites($source, $destination)
$destinationRecord = $this->recordFactory->create();
$destinationRecord->setStructure($destination->getStructure());
- $destinationRecord->setValue('url_rewrite_id', null);
+ $destinationRecord->setValue('url_rewrite_id', $sourceRecord->getValue('id'));
$destinationRecord->setValue('store_id', $sourceRecord->getValue('store_id'));
$destinationRecord->setValue('description', $sourceRecord->getValue('description'));
$destinationRecord->setValue('redirect_type', 0);
@@ -539,7 +561,7 @@ protected function volume()
$this->progress->start(1);
$this->getRewritesSelect();
$this->progress->advance();
- $result = $this->source->getRecordsCount($this->tableName)
+ $result = $this->source->getRecordsCount($this->temporaryTable->getName())
== $this->destination->getRecordsCount('url_rewrite');
if (!$result) {
$this->logger->error('Mismatch of entities in the document: url_rewrite');
@@ -555,7 +577,7 @@ protected function volume()
*/
protected function getIterationsCount()
{
- return $this->source->getRecordsCount($this->tableName)
+ return $this->source->getRecordsCount($this->temporaryTable->getName())
+ $this->source->getRecordsCount('catalog_category_entity_url_key')
+ $this->source->getRecordsCount('catalog_product_entity_url_key');
}
@@ -574,7 +596,7 @@ protected function getDuplicatesList()
/** @var \Magento\Framework\DB\Select $select */
$select = $adapter->getSelect();
- $select->from(['t' => $this->source->addDocumentPrefix($this->tableName)], ['t.*'])
+ $select->from(['t' => $this->source->addDocumentPrefix($this->temporaryTable->getName())], ['t.*'])
->join(
['t2' => new \Zend_Db_Expr(sprintf('(%s)', $subSelect->assemble()))],
't2.request_path = t.request_path AND t2.store_id = t.store_id',
@@ -586,70 +608,6 @@ protected function getDuplicatesList()
return $resultData;
}
- /**
- * Get product suffix query
- *
- * @codeCoverageIgnore
- * @param string $suffixFor Can be 'product' or 'category'
- * @param string $mainTable
- * @return string
- */
- protected function getSuffix($suffixFor, $mainTable = 's')
- {
- if (empty($this->suffixData[$suffixFor])) {
- /** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
- $adapter = $this->source->getAdapter();
- $select = $adapter->getSelect();
-
- $select->from(
- ['s' => $this->source->addDocumentPrefix('core_store')],
- ['store_id' => 's.store_id']
- );
-
- $select->joinLeft(
- ['c1' => $this->source->addDocumentPrefix('core_config_data')],
- "c1.scope='stores' AND c1.path = 'catalog/seo/{$suffixFor}_url_suffix' AND c1.scope_id=s.store_id",
- ['store_path' => 'c1.path', 'store_value' => 'c1.value']
- );
- $select->joinLeft(
- ['c2' => $this->source->addDocumentPrefix('core_config_data')],
- "c2.scope='websites' AND c2.path = 'catalog/seo/{$suffixFor}_url_suffix' AND c2.scope_id=s.website_id",
- ['website_path' => 'c2.path', 'website_value' => 'c2.value']
- );
- $select->joinLeft(
- ['c3' => $this->source->addDocumentPrefix('core_config_data')],
- "c3.scope='default' AND c3.path = 'catalog/seo/{$suffixFor}_url_suffix'",
- ['admin_path' => 'c3.path', 'admin_value' => 'c3.value']
- );
-
- $result = $select->getAdapter()->fetchAll($select);
- foreach ($result as $row) {
- $suffix = 'html';
- if ($row['admin_path'] !== null) {
- $suffix = $row['admin_value'];
- }
- if ($row['website_path'] !== null) {
- $suffix = $row['website_value'];
- }
- if ($row['store_path'] !== null) {
- $suffix = $row['store_value'];
- }
- $this->suffixData[$suffixFor][] = [
- 'store_id' => $row['store_id'],
- 'suffix' => $suffix ? '.' . $suffix : ''
- ];
- }
- }
-
- $suffix = "CASE {$mainTable}.store_id";
- foreach ($this->suffixData[$suffixFor] as $row) {
- $suffix .= sprintf(" WHEN '%s' THEN '%s'", $row['store_id'], $row['suffix']);
- }
- $suffix .= " ELSE '.html' END";
-
- return $suffix;
- }
-
/**
* Initialize temporary table and insert UrlRewrite data
*
@@ -661,7 +619,7 @@ protected function initTemporaryTable()
{
/** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
$adapter = $this->source->getAdapter();
- $this->createTemporaryTable($adapter);
+ $this->temporaryTable->create();
$this->collectRedirects($adapter);
$this->collectProductRewrites($adapter);
$this->collectCategoryRewrites($adapter);
@@ -669,79 +627,6 @@ protected function initTemporaryTable()
self::$dataInitialized = true;
}
- /**
- * Crete temporary table
- *
- * @param \Migration\ResourceModel\Adapter\Mysql $adapter
- * @return void
- */
- protected function createTemporaryTable(\Migration\ResourceModel\Adapter\Mysql $adapter)
- {
- $select = $adapter->getSelect();
- $select->getAdapter()->dropTable($this->source->addDocumentPrefix($this->tableName));
- /** @var \Magento\Framework\DB\Ddl\Table $table */
- $table = $select->getAdapter()->newTable($this->source->addDocumentPrefix($this->tableName))
- ->addColumn(
- 'id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
- )
- ->addColumn(
- 'request_path',
- \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 255
- )
- ->addColumn(
- 'target_path',
- \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 255
- )
- ->addColumn(
- 'is_system',
- \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
- null,
- ['nullable' => false, 'default' => '0']
- )
- ->addColumn(
- 'store_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'entity_type',
- \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 32
- )
- ->addColumn(
- 'redirect_type',
- \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
- null,
- ['unsigned' => true, 'nullable' => false, 'default' => '0']
- )
- ->addColumn(
- 'product_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'category_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'cms_page_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'priority',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addIndex(
- 'url_rewrite',
- ['request_path', 'target_path', 'store_id'],
- ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
- ) ;
- $select->getAdapter()->createTable($table);
- }
-
/**
* Fulfill temporary table with category url rewrites
*
@@ -750,12 +635,13 @@ protected function createTemporaryTable(\Migration\ResourceModel\Adapter\Mysql $
*/
protected function collectCategoryRewrites(\Migration\ResourceModel\Adapter\Mysql $adapter)
{
+ $requestPath = sprintf("CONCAT(`r`.`request_path`, %s)", $this->suffix->getSuffix('category', 'eccr'));
$select = $adapter->getSelect();
$select->from(
['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
[
'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => sprintf("CONCAT(`r`.`request_path`, %s)", $this->getSuffix('category', 'eccr')),
+ 'request_path' => $requestPath,
'target_path' => 'r.target_path',
'is_system' => 'r.is_system',
'store_id' => 's.store_id',
@@ -784,14 +670,16 @@ protected function collectCategoryRewrites(\Migration\ResourceModel\Adapter\Mysq
);
$query = $select
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
+
+ $requestPath = sprintf("CONCAT(`r`.`request_path`, %s)", $this->suffix->getSuffix('category', 'eccr'));
$select = $adapter->getSelect();
$select->from(
['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
[
'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => sprintf("CONCAT(`r`.`request_path`, %s)", $this->getSuffix('category', 'eccr')),
+ 'request_path' => $requestPath,
'target_path' => 'r.target_path',
'is_system' => 'r.is_system',
'store_id' => 'eccr.store_id',
@@ -815,7 +703,7 @@ protected function collectCategoryRewrites(\Migration\ResourceModel\Adapter\Mysq
);
$query = $select
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
}
@@ -848,7 +736,7 @@ protected function collectCmsPageRewrites(\Migration\ResourceModel\Adapter\Mysql
'cps.page_id = cp.page_id',
[]
)->group(['request_path', 'cps.store_id']);
- $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
}
@@ -860,232 +748,13 @@ protected function collectCmsPageRewrites(\Migration\ResourceModel\Adapter\Mysql
*/
protected function collectProductRewrites(\Migration\ResourceModel\Adapter\Mysql $adapter)
{
- /** @var \Magento\Framework\Db\Select $select */
- $select = $adapter->getSelect();
- $subSelect = $adapter->getSelect();
- $subSelect->from(
- ['cr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- ['request_path' => 'cr.request_path']
- );
- $subSelect->join(
- ['ccr' => $this->source->addDocumentPrefix('enterprise_catalog_category_rewrite')],
- 'ccr.url_rewrite_id = cr.url_rewrite_id',
- []
- );
- $subSelect->where('`cr`.`value_id` = `cu`.`value_id`');
- //$subSelect->where('`cr`.`entity_type` = 2');
- $subSelect->where('`ccr`.`store_id` = ecpr.`store_id`');
- $subConcatCategories = $select->getAdapter()->getConcatSql([
- "($subSelect)",
- "'/'",
- '`r`.`request_path`',
- $this->getSuffix('product')
- ]);
- $storeSubSelect = $adapter->getSelect();
- $storeSubSelect->from(
- ['sr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- ['store_id' => 'ecpr.store_id']
- );
- $storeSubSelect->join(
- ['srcu' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 'srcu.value_id = sr.value_id',
- []
- );
- $storeSubSelect->join(
- ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
- 'ecpr.url_rewrite_id = sr.url_rewrite_id',
- []
- );
- $storeSubSelect
- ->where('srcu.entity_id = p.entity_id')
- ->where('ecpr.store_id > 0');
-
- $targetPath = 'IF(ISNULL(c.category_id), r.target_path, CONCAT(r.target_path, "/category/", c.category_id))';
- $select = $adapter->getSelect();
- $select->from(
- ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcatCategories,
- 'target_path' => $targetPath,
- 'is_system' => 'r.is_system',
- 'store_id' => 's.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "c.category_id",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
- 'ecpr.url_rewrite_id = r.url_rewrite_id',
- []
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 'r.value_id = p.value_id',
- []
- );
- $select->join(
- ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
- 'p.entity_id = c.product_id',
- []
- );
- $select->join(
- ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
- 'cu.entity_id = c.category_id',
- []
- );
- $select->join(
- ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
- 'c.product_id = cpw.product_id',
- []
- );
- $select->join(
- ['s' => $this->source->addDocumentPrefix('core_store')],
- sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
- []
- );
- $select->where('`ecpr`.`store_id` = 0');
-
- $query = $adapter->getSelect()->from(['result' => new \Zend_Db_Expr("($select)")])
- ->where('result.request_path IS NOT NULL')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
-
- $select = $adapter->getSelect();
- $subConcat = $select->getAdapter()->getConcatSql([
- '`r`.`request_path`',
- $this->getSuffix('product')
- ]);
-
- $select = $adapter->getSelect();
- $select->from(
- ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcat,
- 'target_path' => 'r.target_path',
- 'is_system' => 'r.is_system',
- 'store_id' => 's.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "trim('0')",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
- 'ecpr.url_rewrite_id = r.url_rewrite_id',
- []
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 'r.value_id = p.value_id',
- []
- );
- $select->join(
- ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
- 'p.entity_id = cpw.product_id',
- []
- );
- $select->join(
- ['s' => $this->source->addDocumentPrefix('core_store')],
- sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
- []
- );
- $query = $select
- ->where('`ecpr`.`store_id` = 0')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
-
- $select = $adapter->getSelect();
- $subConcatCategories = $select->getAdapter()->getConcatSql([
- "($subSelect)",
- "'/'",
- '`s`.`request_path`',
- $this->getSuffix('product', 'ecpr')
- ]);
- $select->from(
- ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcatCategories,
- 'target_path' => 's.target_path',
- 'is_system' => 's.is_system',
- 'store_id' => 'ecpr.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "c.category_id",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
- 'ecpr.url_rewrite_id = s.url_rewrite_id',
- []
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 's.value_id = p.value_id and `p`.`store_id` = ecpr.store_id',
- []
- );
- $select->join(
- ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
- 'p.entity_id = c.product_id',
- []
- );
- $select->join(
- ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
- 'cu.entity_id = c.category_id and cu.store_id = ecpr.store_id',
- []
- );
- $query = $select
- ->where('`ecpr`.`store_id` > 0')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
-
- $select = $adapter->getSelect();
- $subConcat = $select->getAdapter()->getConcatSql([
- '`s`.`request_path`',
- $this->getSuffix('product', 'ecpr')
- ]);
- $select->from(
- ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcat,
- 'target_path' => 's.target_path',
- 'is_system' => 's.is_system',
- 'store_id' => 'ecpr.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "trim('0')",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['ecpr' => $this->source->addDocumentPrefix('enterprise_catalog_product_rewrite')],
- 'ecpr.url_rewrite_id = s.url_rewrite_id',
- []
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 's.value_id = p.value_id',
- []
- );
- $query = $select
- ->where('`ecpr`.`store_id` > 0')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
+ $queryExecute = function ($query) use ($adapter) {
+ $adapter->getSelect()->getAdapter()->query($query);
+ };
+ $queryExecute($this->productRewritesWithoutCategories->getQueryProductsSavedForDefaultScope());
+ $queryExecute($this->productRewritesWithoutCategories->getQueryProductsSavedForParticularStoreView());
+ $queryExecute($this->productRewritesIncludedIntoCategories->getQueryProductsSavedForDefaultScope());
+ $queryExecute($this->productRewritesIncludedIntoCategories->getQueryProductsSavedForParticularStoreView());
}
/**
@@ -1130,7 +799,7 @@ protected function collectRedirects(\Migration\ResourceModel\Adapter\Mysql $adap
);
$query = $select
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
}
diff --git a/src/Migration/Step/UrlRewrite/Version11410to2000.php b/src/Migration/Step/UrlRewrite/Version11410to2000.php
index 2a600c839..06f2f7d93 100644
--- a/src/Migration/Step/UrlRewrite/Version11410to2000.php
+++ b/src/Migration/Step/UrlRewrite/Version11410to2000.php
@@ -10,22 +10,18 @@
use Migration\Reader\MapInterface;
use Migration\Step\DatabaseStage;
use Migration\ResourceModel\Document;
+use Migration\Step\UrlRewrite\Model;
/**
* Class Version11410to2000
- * @SuppressWarnings(PHPMD.TooManyFields)
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD)
*/
class Version11410to2000 extends DatabaseStage implements StageInterface, RollbackInterface
{
/**
- * Temporary table name
- *
- * @var string
+ * @var Model\TemporaryTable
*/
- protected $tableName;
+ private $temporaryTable;
/**
* @var string
@@ -109,6 +105,21 @@ class Version11410to2000 extends DatabaseStage implements StageInterface, Rollba
*/
protected $helper;
+ /**
+ * @var Model\Version11410to2000\ProductRewritesIncludedIntoCategories
+ */
+ private $productRewritesIncludedIntoCategories;
+
+ /**
+ * @var Model\Version11410to2000\ProductRewritesWithoutCategories
+ */
+ private $productRewritesWithoutCategories;
+
+ /**
+ * @var Model\Suffix
+ */
+ private $suffix;
+
/**
* @var array
*/
@@ -197,6 +208,10 @@ class Version11410to2000 extends DatabaseStage implements StageInterface, Rollba
* @param \Migration\ResourceModel\Record\CollectionFactory $recordCollectionFactory
* @param \Migration\ResourceModel\RecordFactory $recordFactory
* @param \Migration\Step\UrlRewrite\Helper $helper
+ * @param Model\Version11410to2000\ProductRewritesWithoutCategories $productRewritesWithoutCategories
+ * @param Model\Version11410to2000\ProductRewritesIncludedIntoCategories $productRewritesIncludedIntoCategories
+ * @param Model\Suffix $suffix
+ * @param Model\TemporaryTable $temporaryTable
* @param string $stage
* @throws \Migration\Exception
*/
@@ -208,7 +223,11 @@ public function __construct(
\Migration\ResourceModel\Destination $destination,
\Migration\ResourceModel\Record\CollectionFactory $recordCollectionFactory,
\Migration\ResourceModel\RecordFactory $recordFactory,
- \Migration\Step\UrlRewrite\Helper $helper,
+ Helper $helper,
+ Model\Version11410to2000\ProductRewritesWithoutCategories $productRewritesWithoutCategories,
+ Model\Version11410to2000\ProductRewritesIncludedIntoCategories $productRewritesIncludedIntoCategories,
+ Model\Suffix $suffix,
+ Model\TemporaryTable $temporaryTable,
$stage
) {
$this->progress = $progress;
@@ -217,9 +236,12 @@ public function __construct(
$this->destination = $destination;
$this->recordCollectionFactory = $recordCollectionFactory;
$this->recordFactory = $recordFactory;
- $this->tableName = 'url_rewrite_m2' . md5('url_rewrite_m2');
+ $this->temporaryTable = $temporaryTable;
$this->stage = $stage;
$this->helper = $helper;
+ $this->productRewritesWithoutCategories = $productRewritesWithoutCategories;
+ $this->productRewritesIncludedIntoCategories = $productRewritesIncludedIntoCategories;
+ $this->suffix = $suffix;
parent::__construct($config);
}
@@ -247,7 +269,7 @@ protected function data()
$this->progress->start($this->getIterationsCount());
$this->destination->clearDocument('url_rewrite');
- $sourceDocument = $this->source->getDocument($this->tableName);
+ $sourceDocument = $this->source->getDocument($this->temporaryTable->getName());
$destinationDocument = $this->destination->getDocument('url_rewrite');
$destProductCategory = $this->destination->getDocument('catalog_url_rewrite_product_category');
@@ -316,7 +338,7 @@ protected function getRewritesSelect()
/** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
$adapter = $this->source->getAdapter();
$select = $adapter->getSelect();
- $select->from(['r' => $this->source->addDocumentPrefix($this->tableName)]);
+ $select->from(['r' => $this->source->addDocumentPrefix($this->temporaryTable->getName())]);
return $select;
}
@@ -333,7 +355,7 @@ protected function migrateRewrites($source, $destination)
$destinationRecord = $this->recordFactory->create();
$destinationRecord->setStructure($destination->getStructure());
- $destinationRecord->setValue('url_rewrite_id', null);
+ $destinationRecord->setValue('url_rewrite_id', $sourceRecord->getValue('id'));
$destinationRecord->setValue('store_id', $sourceRecord->getValue('store_id'));
$destinationRecord->setValue('description', $sourceRecord->getValue('description'));
$destinationRecord->setValue('redirect_type', 0);
@@ -544,7 +566,7 @@ protected function volume()
$this->progress->start(1);
$this->getRewritesSelect();
$this->progress->advance();
- $result = $this->source->getRecordsCount($this->tableName)
+ $result = $this->source->getRecordsCount($this->temporaryTable->getName())
== $this->destination->getRecordsCount('url_rewrite');
if (!$result) {
$this->logger->error('Mismatch of entities in the document: url_rewrite');
@@ -560,7 +582,7 @@ protected function volume()
*/
protected function getIterationsCount()
{
- return $this->source->getRecordsCount($this->tableName)
+ return $this->source->getRecordsCount($this->temporaryTable->getName())
+ $this->source->getRecordsCount('catalog_category_entity_url_key')
+ $this->source->getRecordsCount('catalog_product_entity_url_key');
}
@@ -579,7 +601,7 @@ protected function getDuplicatesList()
/** @var \Magento\Framework\DB\Select $select */
$select = $adapter->getSelect();
- $select->from(['t' => $this->source->addDocumentPrefix($this->tableName)], ['t.*'])
+ $select->from(['t' => $this->source->addDocumentPrefix($this->temporaryTable->getName())], ['t.*'])
->join(
['t2' => new \Zend_Db_Expr(sprintf('(%s)', $subSelect->assemble()))],
't2.request_path = t.request_path AND t2.store_id = t.store_id',
@@ -591,70 +613,6 @@ protected function getDuplicatesList()
return $resultData;
}
- /**
- * Get product suffix query
- *
- * @codeCoverageIgnore
- * @param string $suffixFor Can be 'product' or 'category'
- * @param string $mainTable
- * @return string
- */
- protected function getSuffix($suffixFor, $mainTable = 's')
- {
- if (empty($this->suffixData[$suffixFor])) {
- /** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
- $adapter = $this->source->getAdapter();
- $select = $adapter->getSelect();
-
- $select->from(
- ['s' => $this->source->addDocumentPrefix('core_store')],
- ['store_id' => 's.store_id']
- );
-
- $select->joinLeft(
- ['c1' => $this->source->addDocumentPrefix('core_config_data')],
- "c1.scope='stores' AND c1.path = 'catalog/seo/{$suffixFor}_url_suffix' AND c1.scope_id=s.store_id",
- ['store_path' => 'c1.path', 'store_value' => 'c1.value']
- );
- $select->joinLeft(
- ['c2' => $this->source->addDocumentPrefix('core_config_data')],
- "c2.scope='websites' AND c2.path = 'catalog/seo/{$suffixFor}_url_suffix' AND c2.scope_id=s.website_id",
- ['website_path' => 'c2.path', 'website_value' => 'c2.value']
- );
- $select->joinLeft(
- ['c3' => $this->source->addDocumentPrefix('core_config_data')],
- "c3.scope='default' AND c3.path = 'catalog/seo/{$suffixFor}_url_suffix'",
- ['admin_path' => 'c3.path', 'admin_value' => 'c3.value']
- );
-
- $result = $select->getAdapter()->fetchAll($select);
- foreach ($result as $row) {
- $suffix = 'html';
- if ($row['admin_path'] !== null) {
- $suffix = $row['admin_value'];
- }
- if ($row['website_path'] !== null) {
- $suffix = $row['website_value'];
- }
- if ($row['store_path'] !== null) {
- $suffix = $row['store_value'];
- }
- $this->suffixData[$suffixFor][] = [
- 'store_id' => $row['store_id'],
- 'suffix' => $suffix ? '.' . $suffix : ''
- ];
- }
- }
-
- $suffix = "CASE {$mainTable}.store_id";
- foreach ($this->suffixData[$suffixFor] as $row) {
- $suffix .= sprintf(" WHEN '%s' THEN '%s'", $row['store_id'], $row['suffix']);
- }
- $suffix .= " ELSE '.html' END";
-
- return $suffix;
- }
-
/**
* Initialize temporary table and insert UrlRewrite data
*
@@ -666,7 +624,7 @@ protected function initTemporaryTable()
{
/** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
$adapter = $this->source->getAdapter();
- $this->createTemporaryTable($adapter);
+ $this->temporaryTable->create();
$this->collectProductRewrites($adapter);
$this->collectCategoryRewrites($adapter);
$this->collectCmsPageRewrites($adapter);
@@ -674,79 +632,6 @@ protected function initTemporaryTable()
self::$dataInitialized = true;
}
- /**
- * Crete temporary table
- *
- * @param \Migration\ResourceModel\Adapter\Mysql $adapter
- * @return void
- */
- protected function createTemporaryTable(\Migration\ResourceModel\Adapter\Mysql $adapter)
- {
- $select = $adapter->getSelect();
- $select->getAdapter()->dropTable($this->source->addDocumentPrefix($this->tableName));
- /** @var \Magento\Framework\DB\Ddl\Table $table */
- $table = $select->getAdapter()->newTable($this->source->addDocumentPrefix($this->tableName))
- ->addColumn(
- 'id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
- null,
- ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
- )
- ->addColumn(
- 'request_path',
- \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 255
- )
- ->addColumn(
- 'target_path',
- \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 255
- )
- ->addColumn(
- 'is_system',
- \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
- null,
- ['nullable' => false, 'default' => '0']
- )
- ->addColumn(
- 'store_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'entity_type',
- \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
- 32
- )
- ->addColumn(
- 'redirect_type',
- \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
- null,
- ['unsigned' => true, 'nullable' => false, 'default' => '0']
- )
- ->addColumn(
- 'product_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'category_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'cms_page_id',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addColumn(
- 'priority',
- \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
- )
- ->addIndex(
- 'url_rewrite',
- ['request_path', 'target_path', 'store_id'],
- ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
- ) ;
- $select->getAdapter()->createTable($table);
- }
-
/**
* Fulfill temporary table with category url rewrites
*
@@ -760,7 +645,7 @@ protected function collectCategoryRewrites(\Migration\ResourceModel\Adapter\Mysq
['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
[
'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => sprintf("CONCAT(`r`.`request_path`, %s)", $this->getSuffix('category', 'r')),
+ 'request_path' => sprintf("CONCAT(`r`.`request_path`, %s)", $this->suffix->getSuffix('category', 'r')),
'target_path' => 'r.target_path',
'is_system' => 'r.is_system',
'store_id' => 'r.store_id',
@@ -778,7 +663,7 @@ protected function collectCategoryRewrites(\Migration\ResourceModel\Adapter\Mysq
[]
);
$query = $select->where('`r`.`entity_type` = 2')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
}
@@ -811,7 +696,7 @@ protected function collectCmsPageRewrites(\Migration\ResourceModel\Adapter\Mysql
'cps.page_id = cp.page_id',
[]
)->group(['request_path', 'cps.store_id']);
- $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
}
@@ -823,203 +708,13 @@ protected function collectCmsPageRewrites(\Migration\ResourceModel\Adapter\Mysql
*/
protected function collectProductRewrites(\Migration\ResourceModel\Adapter\Mysql $adapter)
{
- /** @var \Magento\Framework\Db\Select $select */
- $select = $adapter->getSelect();
- $subSelect = $adapter->getSelect();
- $subSelect->from(
- ['cr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- ['request_path' => 'cr.request_path']
- );
- $subSelect->where('`cr`.`value_id` = `cu`.`value_id`');
- $subSelect->where('`cr`.`entity_type` = 2');
- $subSelect->where('`cr`.`store_id` = s.`store_id`');
- $subConcatCategories = $select->getAdapter()->getConcatSql([
- "($subSelect)",
- "'/'",
- '`r`.`request_path`',
- $this->getSuffix('product')
- ]);
- $storeSubSelect = $adapter->getSelect();
- $storeSubSelect->from(
- ['sr' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- ['store_id' => 'sr.store_id']
- );
- $storeSubSelect->join(
- ['srcu' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 'srcu.value_id = sr.value_id',
- []
- );
- $storeSubSelect->where('sr.entity_type = 3')
- ->where('srcu.entity_id = p.entity_id')
- ->where('sr.store_id > 0');
-
- $targetPath = 'IF(ISNULL(c.category_id), r.target_path, CONCAT(r.target_path, "/category/", c.category_id))';
- $select = $adapter->getSelect();
- $select->from(
- ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcatCategories,
- 'target_path' => $targetPath,
- 'is_system' => 'r.is_system',
- 'store_id' => 's.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "c.category_id",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 'r.value_id = p.value_id',
- []
- );
- $select->join(
- ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
- 'p.entity_id = c.product_id',
- []
- );
- $select->join(
- ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
- 'cu.entity_id = c.category_id',
- []
- );
- $select->join(
- ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
- 'c.product_id = cpw.product_id',
- []
- );
- $select->join(
- ['s' => $this->source->addDocumentPrefix('core_store')],
- sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
- []
- );
- $select->where('`r`.`entity_type` = 3')->where('`r`.`store_id` = 0');
-
- $query = $adapter->getSelect()->from(['result' => new \Zend_Db_Expr("($select)")])
- ->where('result.request_path IS NOT NULL')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName))
- ;
- $select->getAdapter()->query($query);
-
- $select = $adapter->getSelect();
- $subConcat = $select->getAdapter()->getConcatSql([
- '`r`.`request_path`',
- $this->getSuffix('product')
- ]);
-
- $select = $adapter->getSelect();
- $select->from(
- ['r' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcat,
- 'target_path' => 'r.target_path',
- 'is_system' => 'r.is_system',
- 'store_id' => 's.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "trim('0')",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 'r.value_id = p.value_id',
- []
- );
- $select->join(
- ['cpw' => $this->source->addDocumentPrefix('catalog_product_website')],
- 'p.entity_id = cpw.product_id',
- []
- );
- $select->join(
- ['s' => $this->source->addDocumentPrefix('core_store')],
- sprintf('cpw.website_id = s.website_id and s.store_id not in (%s)', $storeSubSelect),
- []
- );
- $query = $select->where('`r`.`entity_type` = 3')
- ->where('`r`.`store_id` = 0')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
-
- $select = $adapter->getSelect();
- $subConcatCategories = $select->getAdapter()->getConcatSql([
- "($subSelect)",
- "'/'",
- '`s`.`request_path`',
- $this->getSuffix('product')
- ]);
- $select->from(
- ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcatCategories,
- 'target_path' => 's.target_path',
- 'is_system' => 's.is_system',
- 'store_id' => 's.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "c.category_id",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 's.value_id = p.value_id',
- []
- );
- $select->join(
- ['c' => $this->source->addDocumentPrefix('catalog_category_product')],
- 'p.entity_id = c.product_id',
- []
- );
- $select->join(
- ['cu' => $this->source->addDocumentPrefix('catalog_category_entity_url_key')],
- 'cu.entity_id = c.category_id',
- []
- );
- $query = $select->where('`s`.`entity_type` = 3')
- ->where('`s`.`store_id` > 0')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
-
- $select = $adapter->getSelect();
- $subConcat = $select->getAdapter()->getConcatSql([
- '`s`.`request_path`',
- $this->getSuffix('product')
- ]);
- $select->from(
- ['s' => $this->source->addDocumentPrefix('enterprise_url_rewrite')],
- [
- 'id' => 'IFNULL(NULL, NULL)',
- 'request_path' => $subConcat,
- 'target_path' => 's.target_path',
- 'is_system' => 's.is_system',
- 'store_id' => 's.store_id',
- 'entity_type' => "trim('product')",
- 'redirect_type' => "trim('0')",
- 'product_id' => "p.entity_id",
- 'category_id' => "trim('0')",
- 'cms_page_id' => "trim('0')",
- 'priority' => "trim('4')"
- ]
- );
- $select->join(
- ['p' => $this->source->addDocumentPrefix('catalog_product_entity_url_key')],
- 's.value_id = p.value_id',
- []
- );
- $query = $select->where('`s`.`entity_type` = 3')
- ->where('`s`.`store_id` > 0')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
- $select->getAdapter()->query($query);
+ $queryExecute = function ($query) use ($adapter) {
+ $adapter->getSelect()->getAdapter()->query($query);
+ };
+ $queryExecute($this->productRewritesWithoutCategories->getQueryProductsSavedForDefaultScope());
+ $queryExecute($this->productRewritesWithoutCategories->getQueryProductsSavedForParticularStoreView());
+ $queryExecute($this->productRewritesIncludedIntoCategories->getQueryProductsSavedForDefaultScope());
+ $queryExecute($this->productRewritesIncludedIntoCategories->getQueryProductsSavedForParticularStoreView());
}
/**
@@ -1048,7 +743,7 @@ protected function collectRedirects(\Migration\ResourceModel\Adapter\Mysql $adap
]
);
$query = $select->where('`r`.`entity_type` = 1')
- ->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ ->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
$select = $adapter->getSelect();
@@ -1068,7 +763,7 @@ protected function collectRedirects(\Migration\ResourceModel\Adapter\Mysql $adap
'priority' => "trim('1')"
]
);
- $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->tableName));
+ $query = $select->insertFromSelect($this->source->addDocumentPrefix($this->temporaryTable->getName()));
$select->getAdapter()->query($query);
}
diff --git a/tests/integration/resource/ee.url_rewrite_11410/source.sql b/tests/integration/resource/ee.url_rewrite_11410/source.sql
index 0fc5a70a8..9f0cac6a1 100644
--- a/tests/integration/resource/ee.url_rewrite_11410/source.sql
+++ b/tests/integration/resource/ee.url_rewrite_11410/source.sql
@@ -150,10 +150,10 @@ CREATE TABLE `core_config_data` (
LOCK TABLES `core_config_data` WRITE;
/*!40000 ALTER TABLE `core_config_data` DISABLE KEYS */;
INSERT INTO `core_config_data` VALUES
-(1,'default',0,'catalog/seo/product_url_suffix','html'),
-(2,'default',0,'catalog/seo/category_url_suffix','html'),
-(3,'websites',1,'catalog/seo/product_url_suffix','html1'),
-(4,'stores',3,'catalog/seo/product_url_suffix','html2');
+(1,'default',0,'catalog/seo/product_url_suffix','.html'),
+(2,'default',0,'catalog/seo/category_url_suffix','.html'),
+(3,'websites',1,'catalog/seo/product_url_suffix','.html1'),
+(4,'stores',3,'catalog/seo/product_url_suffix','.html2');
/*!40000 ALTER TABLE `core_config_data` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/tests/integration/resource/url_rewrite_11410/source.sql b/tests/integration/resource/url_rewrite_11410/source.sql
index 0fc5a70a8..9f0cac6a1 100644
--- a/tests/integration/resource/url_rewrite_11410/source.sql
+++ b/tests/integration/resource/url_rewrite_11410/source.sql
@@ -150,10 +150,10 @@ CREATE TABLE `core_config_data` (
LOCK TABLES `core_config_data` WRITE;
/*!40000 ALTER TABLE `core_config_data` DISABLE KEYS */;
INSERT INTO `core_config_data` VALUES
-(1,'default',0,'catalog/seo/product_url_suffix','html'),
-(2,'default',0,'catalog/seo/category_url_suffix','html'),
-(3,'websites',1,'catalog/seo/product_url_suffix','html1'),
-(4,'stores',3,'catalog/seo/product_url_suffix','html2');
+(1,'default',0,'catalog/seo/product_url_suffix','.html'),
+(2,'default',0,'catalog/seo/category_url_suffix','.html'),
+(3,'websites',1,'catalog/seo/product_url_suffix','.html1'),
+(4,'stores',3,'catalog/seo/product_url_suffix','.html2');
/*!40000 ALTER TABLE `core_config_data` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php b/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php
index 77c0e75c2..08033c5be 100644
--- a/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php
+++ b/tests/integration/testsuite/Migration/App/SetupDeltaLogTest.php
@@ -12,32 +12,51 @@
class SetupDeltaLogTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @var SetupDeltaLog|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $setupDeltaLog;
+
+ /**
+ * @var \Magento\Framework\ObjectManagerInterface
+ */
+ private $objectManager;
+
+ /**
+ * @var \Migration\ResourceModel\Source
+ */
+ private $source;
+
/**
* @return void
*/
- public function testSetupTriggers()
+ public function setUp()
{
$helper = \Migration\TestFramework\Helper::getInstance();
- $objectManager = $helper->getObjectManager();
- $objectManager->get('\Migration\Config')
+ $this->objectManager = $helper->getObjectManager();
+ $this->objectManager->get('\Migration\Config')
->init(dirname(__DIR__) . '/_files/' . $helper->getFixturePrefix() . 'config.xml');
- /** @var \Migration\ResourceModel\Source $source */
- $source = $objectManager->create('\Migration\ResourceModel\Source');
- /** @var \Migration\App\SetupDeltaLog $setupDeltaLog */
- $setupDeltaLog = $objectManager->create(
+ $this->setupDeltaLog = $this->objectManager->create(
'\Migration\App\SetupDeltaLog'
);
+ $this->source = $this->objectManager->create('\Migration\ResourceModel\Source');
+ }
+ /**
+ * @return void
+ */
+ public function testSetupTriggers()
+ {
ob_start();
- $this->assertTrue($setupDeltaLog->perform());
+ $this->assertTrue($this->setupDeltaLog->perform());
ob_end_clean();
$dataTable = 'table_with_data';
- $this->checkDeltaLogTable($dataTable, $source);
- $this->checkDeltaLogTable('source_table_1', $source);
- $this->checkDeltaLogTable('source_table_2', $source);
+ $this->checkDeltaLogTable($dataTable, $this->source);
+ $this->checkDeltaLogTable('source_table_1', $this->source);
+ $this->checkDeltaLogTable('source_table_2', $this->source);
- $sourceAdapter = $source->getAdapter();
+ $sourceAdapter = $this->source->getAdapter();
$sourceAdapter->insertRecords(
$dataTable,
[
@@ -74,7 +93,7 @@ public function testSetupTriggers()
['key' => '9', 'operation' => 'INSERT', 'processed' => 0],
['key' => '10', 'operation' => 'INSERT', 'processed' => 0]
];
- $this->assertEquals($expectedData, $source->getRecords($source->getDeltaLogName($dataTable), 0));
+ $this->assertEquals($expectedData, $this->source->getRecords($this->source->getDeltaLogName($dataTable), 0));
}
/**
@@ -88,4 +107,21 @@ protected function checkDeltaLogTable($dataTable, $resource)
$deltaLogTable = $resource->getDocument($deltaLogTableName);
$this->assertEquals($deltaLogTableName, $deltaLogTable->getName());
}
+
+ /**
+ * @return void
+ */
+ public function testSetupTriggersFail()
+ {
+ $message = [
+ \Monolog\Logger::WARNING => ['Some of the delta log tables were not created. Expected:3. Actual:2']
+ ];
+ /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql $adapter */
+ $adapter = $this->source->getAdapter()->getSelect()->getAdapter();
+ $adapter->dropTable('source_table_1');
+ ob_start();
+ $this->assertTrue($this->setupDeltaLog->perform());
+ ob_end_clean();
+ $this->assertEquals($message, \Migration\Logger\Logger::getMessages());
+ }
}
diff --git a/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php b/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php
index f315ae87d..917aed81a 100644
--- a/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php
+++ b/tests/unit/testsuite/Migration/App/SetupDeltaLogTest.php
@@ -60,7 +60,10 @@ public function testPerform()
$progress->expects($this->once())
->method('finish');
- $deltaLog = new SetupDeltaLog($source, $groupsFactory, $progress);
+ /** @var \Migration\Logger\Logger|\PHPUnit_Framework_MockObject_MockObject $logger */
+ $logger = $this->getMock('\Migration\Logger\Logger', [], [], '', false);
+
+ $deltaLog = new SetupDeltaLog($source, $groupsFactory, $progress, $logger);
$this->assertTrue($deltaLog->perform());
}
}
diff --git a/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php b/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php
index fb88165ef..946fa1487 100644
--- a/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php
+++ b/tests/unit/testsuite/Migration/ResourceModel/RecordTest.php
@@ -150,6 +150,21 @@ public function testGetData()
$this->assertEquals(['id' => 10, 'name' => 'item1'], $this->record->getData());
}
+ /**
+ * @return void
+ */
+ public function testGetDataDefault()
+ {
+ $structureData = [
+ 'id' => ['NULLABLE' => true, 'DEFAULT' => 10],
+ 'sku' => ['NULLABLE' => true, 'DEFAULT' => 'item1'],
+ 'name' => ['NULLABLE' => true, 'DEFAULT' => null]
+ ];
+ $fieldsDefault = ['id' => 10, 'sku' => 'item1', 'name' => ''];
+ $this->structure->expects($this->any())->method('getFields')->willReturn($structureData);
+ $this->assertEquals($fieldsDefault, $this->record->getDataDefault());
+ }
+
/**
* @return array
*/
diff --git a/tests/unit/testsuite/Migration/Step/Customer/HelperTest.php b/tests/unit/testsuite/Migration/Step/Customer/HelperTest.php
deleted file mode 100644
index 534bf96f7..000000000
--- a/tests/unit/testsuite/Migration/Step/Customer/HelperTest.php
+++ /dev/null
@@ -1,397 +0,0 @@
-sourceAdapter = $this->getMockBuilder(\Migration\ResourceModel\Adapter\Mysql::class)
- ->disableOriginalConstructor()
- ->setMethods(['fetchAll', 'getSelect'])
- ->getMock();
- $this->destAdapter = $this->getMockBuilder(\Migration\ResourceModel\Adapter\Mysql::class)
- ->disableOriginalConstructor()
- ->setMethods(['getDocumentStructure'])
- ->getMock();
-
- $this->select = $this->getMockBuilder('Magento\Framework\DB\Select')
- ->setMethods(['from', 'join', 'where', 'union', 'getAdapter'])
- ->disableOriginalConstructor()
- ->getMock();
- $this->select->expects($this->any())->method('from')->willReturnSelf();
- $this->select->expects($this->any())->method('join')->willReturnSelf();
- $this->select->expects($this->any())->method('where')->willReturnSelf();
- $this->select->expects($this->any())->method('union')->willReturnSelf();
- $this->select->expects($this->any())->method('getAdapter')->willReturn($this->sourceAdapter);
- $this->sourceAdapter->expects($this->any())->method('getSelect')->willReturn($this->select);
-
- $this->source = $this->getMockBuilder(\Migration\ResourceModel\Source::class)
- ->disableOriginalConstructor()
- ->setMethods(['getAdapter', 'addDocumentPrefix'])
- ->getMock();
- $this->source->expects($this->any())->method('getAdapter')->willReturn($this->sourceAdapter);
- $this->source->expects($this->any())->method('addDocumentPrefix')->willReturnArgument(0);
-
- $this->destination = $this->getMockBuilder(\Migration\ResourceModel\Destination::class)
- ->disableOriginalConstructor()
- ->setMethods(['getAdapter'])
- ->getMock();
- $this->destination->expects($this->any())->method('getAdapter')->willReturn($this->destAdapter);
-
- $this->configReader = $this->getMockBuilder(\Migration\Config::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->readerAttributes = $this->getMockBuilder(\Migration\Reader\Groups::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->readerGroups = $this->getMockBuilder(\Migration\Reader\Groups::class)
- ->setMethods(['getGroup'])
- ->disableOriginalConstructor()
- ->getMock();
- $this->readerGroups->expects($this->at(0))
- ->method('getGroup')
- ->with('source_documents')
- ->willReturn([
- 'customer_entity' => 'entity_id',
- 'customer_address_entity' => 'entity_id'
- ]);
-
- $groupsFactory = $this->getMockBuilder(\Migration\Reader\GroupsFactory::class)
- ->setMethods(['create'])
- ->disableOriginalConstructor()
- ->getMock();
- $groupsFactory->expects($this->at(0))
- ->method('create')
- ->with('customer_attribute_groups_file')
- ->willReturn($this->readerAttributes);
- $groupsFactory->expects($this->at(1))
- ->method('create')
- ->with('customer_document_groups_file')
- ->willReturn($this->readerGroups);
-
- $this->helper = $this->getMockBuilder(Helper::class)
- ->setConstructorArgs([$this->source, $this->destination, $groupsFactory, $this->configReader])
- ->setMethods(['getAttributesData'])
- ->getMock();
- }
-
- /**
- * @param array $testMethodArguments
- * @param array $recordsData
- * @param array $attributesValues
- * @param array $upgradePasswordHash
- * @param array $recordsResult
- *
- * @dataProvider fixturesDataProvider
- * @return void
- */
- public function testUpdateAttributeData(
- $testMethodArguments,
- $recordsData,
- $attributesValues,
- $upgradePasswordHash,
- $recordsResult
- ) {
- $records = [];
- foreach ($recordsData as $recordData) {
- $records[] = $this->getMockBuilder(Record::class)
- ->setConstructorArgs([$recordData])
- ->setMethods(null)
- ->getMock();
- }
- $structure = $this->getMockBuilder(Structure::class)
- ->disableOriginalConstructor()
- ->getMock();
- $destinationRecords = new Collection($structure, $records);
-
- $this->initMaps();
-
- $this->sourceAdapter
- ->expects($this->once())
- ->method('fetchAll')
- ->with($this->select)
- ->willReturn($attributesValues);
-
- $this->configReader
- ->expects($this->any())
- ->method('getOption')
- ->willReturnMap([$upgradePasswordHash]);
-
- $this->helper->updateAttributeData(
- $testMethodArguments['entityTypeCode'],
- $testMethodArguments['sourceDocName'],
- $testMethodArguments['destinationDocName'],
- $destinationRecords
- );
-
- foreach ($destinationRecords as $key => $record) {
- $this->assertEquals($record->getData(), $recordsResult[$key]);
- }
- }
-
- /**
- * Initializes Mocks return maps
- *
- * @return void
- */
- private function initMaps()
- {
- $this->helper
- ->expects($this->any())
- ->method('getAttributesData')
- ->willReturnMap([
- [
- 'customer',
- [
- 'password_hash' => [
- 'attribute_id' => '12',
- 'backend_type' => 'varchar',
- 'attribute_code' => 'password_hash',
- 'entity_type_id' => '1'
- ],
- ]
- ], [
- 'customer_address',
- [
- 'company' => [
- 'attribute_id' => '13',
- 'backend_type' => 'varchar',
- 'attribute_code' => 'company',
- 'entity_type_id' => '2'
- ],
- 'country_id' => [
- 'attribute_id' => '14',
- 'backend_type' => 'varchar',
- 'attribute_code' => 'country_id',
- 'entity_type_id' => '2'
- ],
- ]
- ]
- ]);
- $this->readerAttributes
- ->expects($this->any())
- ->method('getGroup')
- ->willReturnMap([
- ['customer_entity', ['entity_id' => '', 'entity_type_id' => '', 'email' => '', 'password_hash' => '']],
- ['customer_address_entity', ['entity_id' => '', 'city' => '', 'company' => '', 'country_id' => '']]
- ]);
- $this->destAdapter
- ->expects($this->any())
- ->method('getDocumentStructure')
- ->willReturnMap([
- [
- 'customer_entity',
- [
- 'entity_id' => ['DEFAULT' => null, 'NULLABLE' => false],
- 'entity_type_id' => ['DEFAULT' => null, 'NULLABLE' => false],
- 'email' => ['DEFAULT' => null, 'NULLABLE' => true],
- 'password_hash' => ['DEFAULT' => null, 'NULLABLE' => false],
- ]
- ], [
- 'customer_address_entity',
- [
- 'entity_id' => ['DEFAULT' => null, 'NULLABLE' => false],
- 'city' => ['DEFAULT' => null, 'NULLABLE' => false],
- 'company' => ['DEFAULT' => null, 'NULLABLE' => true],
- 'country_id' => ['DEFAULT' => null, 'NULLABLE' => false],
- ]
- ]
- ]);
- }
-
- /**
- * @return array
- */
- public function fixturesDataProvider()
- {
- return [
- [
- 'testMethodArguments' => [
- 'entityTypeCode' => 'customer',
- 'sourceDocName' => 'customer_entity',
- 'destinationDocName' => 'customer_entity'
- ],
- 'recordsData' => [
- ['entity_id' => '1', 'entity_type_id' => '1', 'email' => 'customer1@example.com'],
- ['entity_id' => '2', 'entity_type_id' => '1', 'email' => 'customer2@example.com'],
- ['entity_id' => '3', 'entity_type_id' => '1', 'email' => 'customer3@example.com'],
- ['entity_id' => '4', 'entity_type_id' => '1', 'email' => 'customer4@example.com']
- ],
- 'attributesValues' => [
- [
- 'entity_id' => '1',
- 'attribute_id' => '12',
- 'value' => '34356a3d028accfb3c2996827b706bf5:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ], [
- 'entity_id' => '2',
- 'attribute_id' => '12',
- 'value' => '86a375aacb17606c185d31c8d3e320ce'
- ], [
- 'entity_id' => '3',
- 'attribute_id' => '12',
- 'value' => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
- ], [
- 'entity_id' => '4',
- 'attribute_id' => '12',
- 'value' => '123123q:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ]
- ],
- 'upgradePasswordHash' => [Helper::UPGRADE_CUSTOMER_PASSWORD_HASH, true],
- 'recordsResult' => [
- [
- 'entity_id' => '1',
- 'entity_type_id' => '1',
- 'email' => 'customer1@example.com',
- 'password_hash' => '34356a3d028accfb3c2996827b706bf5:UmPvGtih25eQCjC5f6NMwqkds500x2Jd:0'
- ], [
- 'entity_id' => '2',
- 'entity_type_id' => '1',
- 'email' => 'customer2@example.com',
- 'password_hash' => '86a375aacb17606c185d31c8d3e320ce::0'
- ], [
- 'entity_id' => '3',
- 'entity_type_id' => '1',
- 'email' => 'customer3@example.com',
- 'password_hash' => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855::1'
- ], [
- 'entity_id' => '4',
- 'entity_type_id' => '1',
- 'email' => 'customer4@example.com',
- 'password_hash' => '123123q:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ]
- ],
- ], [
- 'testMethodArguments' => [
- 'entityTypeCode' => 'customer',
- 'sourceDocName' => 'customer_entity',
- 'destinationDocName' => 'customer_entity'
- ],
- 'recordsData' => [
- ['entity_id' => '1', 'entity_type_id' => '1', 'email' => 'customer1@example.com'],
- ['entity_id' => '2', 'entity_type_id' => '1', 'email' => 'customer2@example.com']
- ],
- 'attributesValues' => [
- [
- 'entity_id' => '1',
- 'attribute_id' => '12',
- 'value' => '34356a3d028accfb3c2996827b706bf5:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ],
- [
- 'entity_id' => '2',
- 'attribute_id' => '12',
- 'value' => '123123q:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ]
- ],
- 'upgradePasswordHash' => [Helper::UPGRADE_CUSTOMER_PASSWORD_HASH, false],
- 'recordsResult' => [
- [
- 'entity_id' => '1',
- 'entity_type_id' => '1',
- 'email' => 'customer1@example.com',
- 'password_hash' => '34356a3d028accfb3c2996827b706bf5:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ],
- [
- 'entity_id' => '2',
- 'entity_type_id' => '1',
- 'email' => 'customer2@example.com',
- 'password_hash' => '123123q:UmPvGtih25eQCjC5f6NMwqkds500x2Jd'
- ]
- ],
- ], [
- 'testMethodArguments' => [
- 'entityTypeCode' => 'customer_address',
- 'sourceDocName' => 'customer_address_entity',
- 'destinationDocName' => 'customer_address_entity'
- ],
- 'recordsData' => [
- ['entity_id' => '1', 'city' => 'Austin'],
- ['entity_id' => '2', 'city' => 'Kiev']
- ],
- 'attributesValues' => [
- [
- 'entity_id' => '1',
- 'attribute_id' => '13',
- 'value' => 'Company Name'
- ]
- ],
- 'upgradePasswordHash' => [Helper::UPGRADE_CUSTOMER_PASSWORD_HASH, false],
- 'recordsResult' => [
- [
- 'entity_id' => '1',
- 'city' => 'Austin',
- 'company' => 'Company Name',
- 'country_id' => ''
- ], [
- 'entity_id' => '2',
- 'city' => 'Kiev',
- 'company' => null,
- 'country_id' => ''
- ]
- ],
- ]
- ];
- }
-}
diff --git a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
index cbd204216..173d1bc81 100644
--- a/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
+++ b/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php
@@ -5,8 +5,11 @@
*/
namespace Migration\Step\UrlRewrite;
+use Migration\Step\UrlRewrite\Model\Version11410to2000;
+
/**
* Class UrlRewriteTest
+ * @SuppressWarnings(PHPMD)
*/
class Version11410to2000Test extends \PHPUnit_Framework_TestCase
{
@@ -55,6 +58,26 @@ class Version11410to2000Test extends \PHPUnit_Framework_TestCase
*/
protected $helper;
+ /**
+ * @var ProductRewritesWithoutCategories|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $productRewritesWithoutCategories;
+
+ /**
+ * @var ProductRewritesIncludedIntoCategories|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $productRewritesIncludedIntoCategories;
+
+ /**
+ * @var Suffix|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $suffix;
+
+ /**
+ * @var TemporaryTable|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $temporaryTable;
+
/**
* @return void
*/
@@ -84,6 +107,22 @@ public function setUp()
);
$this->recordFactory = $this->getMock('\Migration\ResourceModel\RecordFactory', ['create'], [], '', false);
$this->helper = $this->getMock('\Migration\Step\UrlRewrite\Helper', [], ['processFields'], '', false);
+ $this->productRewritesWithoutCategories = $this->getMock(
+ '\Migration\Step\UrlRewrite\Model\Version11410to2000\ProductRewritesWithoutCategories',
+ [],
+ [],
+ '',
+ false
+ );
+ $this->productRewritesIncludedIntoCategories = $this->getMock(
+ '\Migration\Step\UrlRewrite\Model\Version11410to2000\ProductRewritesIncludedIntoCategories',
+ [],
+ [],
+ '',
+ false
+ );
+ $this->suffix = $this->getMock('\Migration\Step\UrlRewrite\Model\Suffix', [], [], '', false);
+ $this->temporaryTable = $this->getMock('\Migration\Step\UrlRewrite\Model\TemporaryTable', [], [], '', false);
}
/**
@@ -103,6 +142,10 @@ public function testIntegrity()
$this->recordCollectionFactory,
$this->recordFactory,
$this->helper,
+ $this->productRewritesWithoutCategories,
+ $this->productRewritesIncludedIntoCategories,
+ $this->suffix,
+ $this->temporaryTable,
'integrity'
);
}