Created
December 24, 2017 14:11
-
-
Save ceckoslab/e4810ce15720b3aad63a0032e3530573 to your computer and use it in GitHub Desktop.
Script that syncs Magento catalog, cms blocks and pages, sales rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $mysqlCommandPath = 'mysql'; | |
| $mysqldumptCommandPath = 'mysqldump'; | |
| $remoteDbUnsername = ''; | |
| $remoteDbPassword = ''; | |
| $remotePort = ''; | |
| $remotHost = ''; | |
| $remoteDb = ''; | |
| $localDbUnsername = ''; | |
| $localDbPassword = ''; | |
| $localDb = ''; | |
| $con = mysqli_connect($remotHost, $remoteDbUnsername, $remoteDbPassword, $remoteDb, $remotePort); | |
| if (!$con) | |
| { | |
| die('Could not connect: ' . mysqli_error($con)); | |
| } | |
| $tables = 'catalog_category_anc_categs_index_idx | |
| catalog_category_anc_categs_index_tmp | |
| catalog_category_anc_products_index_idx | |
| catalog_category_anc_products_index_tmp | |
| catalog_category_entity | |
| catalog_category_entity_datetime | |
| catalog_category_entity_decimal | |
| catalog_category_entity_int | |
| catalog_category_entity_text | |
| catalog_category_entity_varchar | |
| catalog_category_flat_store_1 | |
| catalog_category_flat_store_2 | |
| catalog_category_product | |
| catalog_category_product_index | |
| catalog_category_product_index_enbl_idx | |
| catalog_category_product_index_enbl_tmp | |
| catalog_category_product_index_idx | |
| catalog_category_product_index_tmp | |
| catalog_compare_item | |
| catalog_eav_attribute | |
| catalog_product_bundle_option | |
| catalog_product_bundle_option_value | |
| catalog_product_bundle_price_index | |
| catalog_product_bundle_selection | |
| catalog_product_bundle_selection_price | |
| catalog_product_bundle_stock_index | |
| catalog_product_enabled_index | |
| catalog_product_entity | |
| catalog_product_entity_datetime | |
| catalog_product_entity_decimal | |
| catalog_product_entity_gallery | |
| catalog_product_entity_group_price | |
| catalog_product_entity_int | |
| catalog_product_entity_media_gallery | |
| catalog_product_entity_media_gallery_value | |
| catalog_product_entity_text | |
| catalog_product_entity_tier_price | |
| catalog_product_entity_varchar | |
| catalog_product_flat_1 | |
| catalog_product_flat_2 | |
| catalog_product_index_eav | |
| catalog_product_index_eav_decimal | |
| catalog_product_index_eav_decimal_idx | |
| catalog_product_index_eav_decimal_tmp | |
| catalog_product_index_eav_idx | |
| catalog_product_index_eav_tmp | |
| catalog_product_index_group_price | |
| catalog_product_index_price | |
| catalog_product_index_price_bundle_idx | |
| catalog_product_index_price_bundle_opt_idx | |
| catalog_product_index_price_bundle_opt_tmp | |
| catalog_product_index_price_bundle_sel_idx | |
| catalog_product_index_price_bundle_sel_tmp | |
| catalog_product_index_price_bundle_tmp | |
| catalog_product_index_price_cfg_opt_agr_idx | |
| catalog_product_index_price_cfg_opt_agr_tmp | |
| catalog_product_index_price_cfg_opt_idx | |
| catalog_product_index_price_cfg_opt_tmp | |
| catalog_product_index_price_downlod_idx | |
| catalog_product_index_price_downlod_tmp | |
| catalog_product_index_price_final_idx | |
| catalog_product_index_price_final_tmp | |
| catalog_product_index_price_idx | |
| catalog_product_index_price_opt_agr_idx | |
| catalog_product_index_price_opt_agr_tmp | |
| catalog_product_index_price_opt_idx | |
| catalog_product_index_price_opt_tmp | |
| catalog_product_index_price_tmp | |
| catalog_product_index_tier_price | |
| catalog_product_index_website | |
| catalog_product_link | |
| catalog_product_link_attribute | |
| catalog_product_link_attribute_decimal | |
| catalog_product_link_attribute_int | |
| catalog_product_link_attribute_varchar | |
| catalog_product_link_type | |
| catalog_product_option | |
| catalog_product_option_price | |
| catalog_product_option_title | |
| catalog_product_option_type_price | |
| catalog_product_option_type_title | |
| catalog_product_option_type_value | |
| catalog_product_relation | |
| catalog_product_super_attribute | |
| catalog_product_super_attribute_label | |
| catalog_product_super_attribute_pricing | |
| catalog_product_super_link | |
| catalog_product_website | |
| catalogindex_aggregation | |
| catalogindex_aggregation_tag | |
| catalogindex_aggregation_to_tag | |
| catalogindex_eav | |
| catalogindex_eav | |
| catalogindex_minimal_price | |
| catalogindex_price | |
| cataloginventory_stock | |
| cataloginventory_stock_item | |
| cataloginventory_stock_status | |
| cataloginventory_stock_status_idx | |
| cataloginventory_stock_status_tmp | |
| catalogrule | |
| catalogrule_affected_product | |
| catalogrule_customer_group | |
| catalogrule_group_website | |
| catalogrule_product | |
| catalogrule_product_price | |
| catalogrule_website | |
| review | |
| review_detail | |
| review_entity | |
| review_entity_summary | |
| review_status | |
| review_store | |
| core_url_rewrite | |
| cms_block | |
| cms_block_store | |
| cms_page | |
| cms_page_store | |
| eav_attribute | |
| eav_attribute_group | |
| eav_attribute_label | |
| eav_attribute_option | |
| eav_attribute_option_value | |
| eav_attribute_set | |
| eav_entity | |
| eav_entity_attribute | |
| eav_entity_store | |
| eav_entity_type | |
| eav_entity_varchar | |
| eav_form_element | |
| eav_form_fieldset_label | |
| eav_form_type | |
| eav_form_type_entity | |
| epetworld_product_badges | |
| rating | |
| rating_entity | |
| rating_option | |
| rating_option_vote | |
| rating_option_vote_aggregated | |
| rating_store | |
| salesrule | |
| salesrule_coupon | |
| salesrule_coupon_usage | |
| salesrule_customer | |
| salesrule_customer_group | |
| salesrule_label | |
| salesrule_product_attribute | |
| salesrule_website'; | |
| $talesArr = explode(PHP_EOL, $tables); | |
| // Dumps the data | |
| foreach ($talesArr as $table) { | |
| $table = trim($table); | |
| echo 'Dumping table: ' . $table . PHP_EOL; | |
| $command = $mysqldumptCommandPath . ' -u ' . $remoteDbUnsername . ' -P ' . $remotePort . ' -h ' . $remotHost . ' -p' . $remoteDbPassword . ' --single-transaction --no-create-db --extended-insert --net_buffer_length=20000 --quick ' . $remoteDb . ' ' . $table . ' > magento-mini-dump/' . $table . '.sql'; | |
| shell_exec($command); | |
| } | |
| // Importing the data | |
| foreach ($talesArr as $table) { | |
| $table = trim($table); | |
| echo 'Importing table: ' . $table . PHP_EOL; | |
| shell_exec($mysqlCommandPath . ' -u ' . $localDbUnsername . ' -p' . $localDbPassword . ' ' . $localDb . ' < magento-mini-dump/' . $table . '.sql'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment