System - letronghieu4897/magento GitHub Wiki

System

System


1. Set mode

$ php bin/magento deploy:mode:show

$ php bin/magento deploy:mode:set developer

$ php bin/magento deploy:mode:set production

2. Clear cache

$ php bin/magento cache:status

$ php bin/magento cache:clean

$ php bin/magento cache:flush

$ php bin/magento cache:disable CACHE_TYPE

$ php bin/magento cache:enable CACHE_TYPE

3. Indexer

$ php bin/magento indexer:info

$ php bin/magento indexer:status [indexer]

$ php bin/magento indexer:reindex [indexer]

4. Log

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Your text message');
$logger->info($e->getMessage());
$class = get_class($value);
$type = gettype($value);
$print = print_r($value);

$logger->info($class);
$logger->info($type);
$logger->info($print);

5. Migrate M1 to M2

LINK WIKI : https://netpower.atlassian.net/wiki/spaces/M2/pages/109608961/Migrations

NOTE : Using database default of Magento 2.
1. Install Migrate tool of Magento

LINK DOWNLOAD: https://devdocs.magento.com/guides/v2.3/migration/migration-tool-install.html

2. Check version of Magento 1. Choose exactly version folder on vender/magento/data-migration-tool/etc/opensource-to-opensource/
3. cp folder found above to your extension /etc : Example Netpower/Base/etc
4. cp settings.xml, class-map.xml to folder in STEP 3
5. Edit file config.xml on above folder
    <source>
        <database host="192.168.181.40" name="Magento_1" user="" password="" />
    </source>

    <destination>
        <database host="192.168.181.40" name="Magento_2" user="" password="" />
    </destination>

    <options>
       <map_file>../../../app/code/Netpower/Base/etc/migrate/1.9.2.3/map.xml</map_file> //EXAMPLE LINK FILE
       <settings_map_file>../../../app/code/Netpower/Base/etc/migrate/settings.xml</settings_map_file>
       <class_map>../../../app/code/Netpower/Base/etc/migrate/class-map.xml</class_map>
       <crypt_key> ... crypt key of magento 1 </crypt_key>
    </options>
6. Add information error to map.xml to fix
--- ignore document (table) does'nt exist on M1 (exist on M2) => inside source tag
<source>
     ... (example)
    <ignore>
        <document>googleshopping_attributes</document>
     </ignore>
</source>

--- ignore document (table) does'nt exist on M2 (exist on M1) => inside destination tag
<destination>
    ... (example)
     <ignore>
         <document>catalog_product_index_price*</document>
     </ignore>
</destination>

--- COMMON : Define exactly tag error. And put them into right place. 
 + field      :  ignore field
 + document   :  ignore document
7. Delete field with error FK
DELETE FROM `customer_address_entity_text` where entity_id not in (select entity_id from customer_address_entity);
 
DELETE FROM `customer_address_entity_int` where entity_id not in (select entity_id from customer_address_entity);
 
DELETE FROM `customer_address_entity_varchar` where entity_id not in (select `entity_id` from `customer_address_entity`);
 
DELETE FROM `wishlist` where customer_id not in (select `entity_id` from `customer_entity`);



MAYBE IN OTHER TABLE.
8. Change name class in class-map.xml to fix class name error
   <rename>
        <from>ultramegamenu/category_attribute_helper_dropdown_blocks</from>
        <to/>
    </rename>
    <rename>
        <from>sarp/source_subscription_periods</from>
        <to/>
    </rename>
    <rename>
        <from>sarp/source_customer_groups</from>
        <to/>
    </rename>
    <rename>
        <from>sarp/source_yesnoglobal</from>
        <to/>
    </rename>
    <rename>
        <from>sarp/source_yesnopleaseselect</from>
        <to/>
    </rename>
...
...
9. Run
 --- app/code/Netpower/Base/etc/migrate/1.9.2.3/config.xml : path go to config.xml


php72 bin/magento migrate:settings -r app/code/Netpower/Base/etc/migrate/1.9.2.3/config.xml

php72 bin/magento migrate:data -r app/code/Netpower/Base/etc/migrate/1.9.2.3/config.xml    //TEST

php72 bin/magento migrate:delta -r app/code/Netpower/Base/etc/migrate/1.9.2.3/config.xml

COMPLETELY WORK (The way above is error)

= = = = = = = = = = = = = = = = = = = = = = = = = = = 
                COMPLETELY MIGRATE
= = = = = = = = = = = = = = = = = = = = = = = = = = = 

LINK WIKI : WIKI MIGRATE

STEP 1 : Install extension

Copy into app/code then extract
run command: php bin/magento setup:di:compile

STEP 2 : Configure source and destination database, crypt key

Change these files: 
app/code/Netpower/Blf/etc/1.9.2.3/config/config.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_cms.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_tax.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_product_attribute.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_category.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_product.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_customer.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_orders.xml
app/code/Netpower/Blf/etc/1.9.2.3/config/netpower/config_migrate_other.xml

Replace config line:
<source>
    <database host="192.168.181.40" name="Magento_CE_1_9_2_3_Blf_Production" user="netpower" password="webPower2010" />
</source>
<destination>
    <database host="192.168.181.40" name="Magento_CE_2_3_Blf" user="netpower" password="webPower2010" />
</destination>
<options>
    <crypt_key>f49a3167568e4e0fa953bb3fd9797e6d</crypt_key>
    <!-- from magento 1 -->
</options>

STEP 3 : Migrate data

1. Migrate setting:

php72 bin/magento migrate:settings -r app/code/Netpower/Blf/etc/1.9.2.3/config/config.xml

2. Migrate cms, static block:

php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_cms.xml

3. Migrate tax, tax rule:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_tax.xml

4. Migrate product attribute:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_product_attribute.xml

5. Migrate category:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_category.xml

6. Migrate product:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_product.xml

7. Migrate customer:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_customer.xml

8. Migrate order, invoice, shipment:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_orders.xml

9. Migrate other table:
php72 bin/magento migrate:data -r app/code/Netpower/Blf/etc/1.9.2.3/config/config_migrate_order.xml

FIX ERROR BEFORE REINDEX :

IMAGE ERROR

Solution: go to vendor\magento\module-store\Model\StoreRepository.php function getById($id) and log the store id that is mismatched then insert that store to either core_store of M1 or table store of M2

No such enity error when reindex (Before run reindex)

No such entity error

Cause: The store in store table having group_id that does not exist in table store_group

Solution: Set the group_id to existing group_id in table store_group and set is_active to 0 for unused stores

IMAGE DATABASE

Note:

  • Re-index without customer grid:

php bin/magento indexer:reindex design_config_grid && php bin/magento indexer:reindex catalog_product_flat && php bin/magento indexer:reindex catalog_category_product && php bin/magento indexer:reindex catalog_product_category && php bin/magento indexer:reindex catalog_product_price && php bin/magento indexer:reindex catalog_product_attribute && php bin/magento indexer:reindex catalogrule_rule && php bin/magento indexer:reindex catalogrule_product && php bin/magento indexer:reindex cataloginventory_stock && php bin/magento indexer:reindex catalogsearch_fulltext

  • Php memory limit:

Add "-dmemory_limit=6G" Ex: php -dmemory_limit=6G bin/magento setup:di:compile

DETAIL

6. Quick deploy css on production

rm -rf pub/static/frontend/* && rm -rf var/view_preprocessed/pub/static/frontend/* && php bin/magento setup:static-content:deploy nb_NO -a frontend

Footer

⚠️ **GitHub.com Fallback** ⚠️