2

I want to copy all data from one to another magento installation.

Wants to copy products,product-attributes,category,category-attributes,customers,cms-block,pages,rules everything except orders.
I can do it by take DB from one and setup it in new installation,but we have many modules and their data stores in DB and I'm not going to use so much modules for it.

So what will be best practice to achieve it without errors?
Old version : 2.2.2 to
latest version 2.3.2

Note : I don't want it happen by Upgrading Magento version.

0

The Best solution is to upgrade the Magento 2.2.2 to the Magento 2.3.2 version. Please run the following commands

php bin/magento maintenance:enable

composer require magento/product-community-edition 2.3.2 --no-update

composer update

rm -rf <Magento install dir>/var/cache/

rm -rf <Magento install dir>/var/page_cache/

rm -rf <Magento install dir>/var/generation/

php bin/magento setup:upgrade

php bin/magento maintenance:disable

And for Truncate the orders. Use the below link query:

https://stackoverflow.com/questions/37861046/how-to-remove-test-orders-from-magento2

This solution is worked for you .

  • I know that but dont want to use that there are many data from many extension,and some of them are conflicts,that's why – Ketan Borada Sep 17 at 6:21
  • You can delete these extensions columns from the database after update the Magento Version. – Hardik Makwana Sep 17 at 6:23
  • There is no other way to achieve. – Hardik Makwana Sep 17 at 6:25
  • By using API,Of course.but don't know in proper sequence.and may be also other,Thanks – Ketan Borada Sep 17 at 6:27
  • 1
    Hello @KetanBorada, If you find the solution then tell me – Hardik Makwana Sep 18 at 4:27
0
+50

Step - 1 : Create an instance of your database. Then delete all orders by execute below query

SET FOREIGN_KEY_CHECKS=0;

# Clean order history
TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;

# Clean order infos
TRUNCATE TABLE `sales_creditmemo`;
TRUNCATE TABLE `sales_creditmemo_comment`;
TRUNCATE TABLE `sales_creditmemo_grid`;
TRUNCATE TABLE `sales_creditmemo_item`;
TRUNCATE TABLE `sales_invoice`;
TRUNCATE TABLE `sales_invoiced_aggregated`;
TRUNCATE TABLE `sales_invoiced_aggregated_order`;
TRUNCATE TABLE `sales_invoice_comment`;
TRUNCATE TABLE `sales_invoice_grid`;
TRUNCATE TABLE `sales_invoice_item`;
TRUNCATE TABLE `sales_order`;
TRUNCATE TABLE `sales_order_address`;
TRUNCATE TABLE `sales_order_aggregated_created`;
TRUNCATE TABLE `sales_order_aggregated_updated`;
TRUNCATE TABLE `sales_order_grid`;
TRUNCATE TABLE `sales_order_item`;
TRUNCATE TABLE `sales_order_payment`;
TRUNCATE TABLE `sales_order_status_history`;
TRUNCATE TABLE `sales_order_tax`;
TRUNCATE TABLE `sales_order_tax_item`;
TRUNCATE TABLE `sales_payment_transaction`;
TRUNCATE TABLE `sales_refunded_aggregated`;
TRUNCATE TABLE `sales_refunded_aggregated_order`;
TRUNCATE TABLE `sales_shipment`;
TRUNCATE TABLE `sales_shipment_comment`;
TRUNCATE TABLE `sales_shipment_grid`;
TRUNCATE TABLE `sales_shipment_item`;
TRUNCATE TABLE `sales_shipment_track`;
TRUNCATE TABLE `sales_shipping_aggregated`;
TRUNCATE TABLE `sales_shipping_aggregated_order`;

# Clean cart infos
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
TRUNCATE TABLE `quote_shipping_rate`;

# Reset indexes (if you want your orders number start back to 1
TRUNCATE TABLE sequence_invoice_1;
TRUNCATE TABLE sequence_order_1;
TRUNCATE TABLE sequence_shipment_1;
TRUNCATE TABLE sequence_creditmemo_1;


SET FOREIGN_KEY_CHECKS=1;

Step 2 : Export database.

Step 3 : Import for magento 2.2.3

  • Please read the question they don't want to delete the order tables. – Hardik Makwana Sep 18 at 4:27
  • They want to copy all tables except orders. – Mousam Roy Sep 18 at 7:23
0

You can use mysqldump to create a dump that either includes only named tables, or excludes specific tables.

e.g.

mysqldump -u magento_user -p magento_db catalog_product_entity, catalog_category_entity > products_and_categories.dump;
mysqldump -u magento_user -p magento_db ignore_table=quote, ignore_table=sales_order > everything_except_orders_and_quotes.dump;

In both cases you can start with show tables and then use a text editor to refine the list of tables to include or exclude.

I have used these methods many times to copy product/category/cms data from production to development sites without having to duplicate customer and sales data.

0

If you are encountering an issue with Magento 2.3.2 wherein the products won't show up on frontend even if on the backend it is showing, the cause of the issue is due to Multi-Source Inventory module of Magento 2.

You might need to execute the following SQL command

CREATE ALGORITHM=UNDEFINED SQL SECURITY INVOKER VIEW `inventory_stock_1`  AS  select distinct `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` from (`cataloginventory_stock_status` `legacy_stock_status` join `catalog_product_entity` `product` on((`legacy_stock_status`.`product_id` = `product`.`entity_id`))) ;

Run bin/magento indexer:reindex

Run bin/magento cache:flush

The products will now show up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.