Magento 2
Override config in env.php
https://r-martins.github.io/m1docs/guides/v2.4/config-guide/prod/config-reference-var-name.html
'system' => [
'stores' => [
'<store_code>' => [
'system' => [
'smtp' => [
'host' => 'localhost',
'port' => '25'
]
],
]
],
'default' => [
'system' => [
'smtp' => [
'host' => 'localhost',
'port' => '25'
]
],
'catalog' => [
'search' => [
'engine' => 'opensearch',
'opensearch_server_hostname' => 'opensearch',
'opensearch_server_port' => 9200,
'opensearch_index_prefix' => 'catalog'
]
],
'web' => [
'unsecure' => [
'base_url' => 'http://test/',
'base_link_url' => '{{unsecure_base_url}}'
],
'secure' => [
'base_url' => 'https://test/',
'base_link_url' => '{{secure_base_url}}'
],
'default' => [
'front' => 'cms'
],
'cookie' => [
'cookie_domain' => 'test'
]
],
],
],
Setup command:
bin/magento setup:install \
--base-url=http://pub.m246.php82/ \
--backend-frontname=admin \
--db-host=maziadb \
--db-name=m246 \
--db-user=root \
--db-password=1 \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=opensearch \
--opensearch-host=opensearch \
--opensearch-port=9200 \
--opensearch-index-prefix=m246 \
--opensearch-timeout=15
Disable 2fa module
php bin/magento module:disable Magento_TwoFactorAuth Magento_AdminAdobeImsTwoFactorAuth
Generate URN
php bin/magento dev:urn-catalog:generate --ide PHPSTORM .idea/misc.xml
1-line logger
\Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class)->debug('message');
logger with custom file
https://magento.stackexchange.com/questions/75935/how-to-create-custom-log-file-in-magento-2
v2.4.3 or newer
$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/custom.log');
$logger = new \Zend_Log();
$logger->addWriter($writer);
$logger->info('Custom message');
v2.4.2
$writer = new \Laminas\Log\Writer\Stream(BP . '/var/log/custom.log');
$logger = new \Laminas\Log\Logger();
$logger->addWriter($writer);
$logger->info('Custom message');
v2.4.1 or older
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/custom.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info('Custom message');
logger with custom file by di.xml
<virtualType name="Vendor\Module\Logger\Handler" type="Magento\Framework\Logger\Handler\Base">
<arguments>
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
<argument name="fileName" xsi:type="string">var/log/filename.log</argument>
</arguments>
</virtualType>
<virtualType name="Vendor\Module\Logger\Logger" type="Magento\Framework\Logger\Monolog">
<arguments>
<argument name="handlers" xsi:type="array">
<item name="system" xsi:type="object">Vendor\Module\Logger\Handler</item>
</argument>
</arguments>
</virtualType>
<type name="Vendor\Module\Model\YourClass">
<arguments>
<argument name="logger" xsi:type="object">Vendor\Module\Logger\Logger</argument>
</arguments>
</type>
Backup db
https://gitlab.com/chung1905/pysqldump/
Or
#!/bin/bash
NO_DATA_TABLES="report_viewed_product_index
report_event
report_viewed_product_aggregated_daily
report_viewed_product_aggregated_monthly
report_viewed_product_aggregated_yearly
report_compared_product_index
report_event_types"
BACKUP_FILE='./backup/backup.sql'
DB='db_name'
IGNORE_TABLE_CMD='mysqldump --single-transaction'
NO_DATA_CMD="mysqldump --no-data --single-transaction $DB"
for table in $NO_DATA_TABLES
do
IGNORE_TABLE_CMD="$IGNORE_TABLE_CMD --ignore-table=$DB.$table "
done
IGNORE_TABLE_CMD="$IGNORE_TABLE_CMD $DB"
for table in $NO_DATA_TABLES
do
NO_DATA_CMD="$NO_DATA_CMD $table"
done
$IGNORE_TABLE_CMD | sed -r 's=/\*!500.. DEFINER[^*]+\*/==g' > $BACKUP_FILE
$NO_DATA_CMD | sed -r 's=/\*!500.. DEFINER[^*]+\*/==g' >> $BACKUP_FILE
pigz -f $BACKUP_FILE
Magento 1
1-line logger
Mage::log($select->__toString(), Zend_Log::DEBUG, 'task807.log', 1);