Posts

Showing posts from July, 2023

Magento 2 test data clean using my sql query

Before runing this query please take your database backup.You may face too many redirect issue in category admin view. So that error please check any third party module is using the category data or not for ex.. mageplaza seo, amasty xsearch this type of module may cause some issue in category view page. Delete all customers at once. SET FOREIGN_KEY_CHECKS=0; -- Customers TRUNCATE TABLE `customer_address_entity`; TRUNCATE TABLE `customer_address_entity_datetime`; TRUNCATE TABLE `customer_address_entity_decimal`; TRUNCATE TABLE `customer_address_entity_int`; TRUNCATE TABLE `customer_address_entity_text`; TRUNCATE TABLE `customer_address_entity_varchar`; TRUNCATE TABLE `customer_entity`; TRUNCATE TABLE `customer_entity_datetime`; TRUNCATE TABLE `customer_entity_decimal`; TRUNCATE TABLE `customer_entity_int`; TRUNCATE TABLE `customer_entity_text`; TRUNCATE TABLE `customer_entity_varchar`; TRUNCATE TABLE `customer_grid_flat`; TRUNCATE TABLE `customer_log`; TRUNCATE TABL

Magento 2 upgrade steps

Step 1: Enable Maintenance Mode  php bin/magento maintenance:enable  Step 2 : Composer Backup:  Run the following command cp composer.json composer.json.bak  Step 3 : Run this command composer require-commerce magento/product-community-edition 2.4.6-p1 --no-update  Step 4 : composer clear-cache && composer update  Step 5: Magento Schema and Data Update: Run the following commands: sudo php bin/magento setup:upgrade sudo php bin/magento setup:di:compile  Step 6: Disable Maintenance Mode php bin/magento maintenance:disable

docker compose install in local system

apt install docker docker-compose #if not installed then run this command in local for installing docker-compose up -d #To start docker services if not run 4-services then use this commands docker-compose down #To stop docker if requited docker exec -it php-fpm bash #enter in docker cli docker exec -it db bash enter database on cli then use it. sudo a2enmod proxy_http #enable proxy module ===import Db in Docker==== docker exec -i [your Docker db host] mysql -u [userName] -p[pswd] [yourDatabaseName] < [SqlFilePath]; Example.1668176117_db_dbbackup.sql ==== VirtualHost for docker project : == create this virtual host using normal process as we create and put this code for docker project. ServerName [HostName] #xyz.local.com ServerAdmin webmaster@localhost ProxyPass / http://localhost:81/ ProxyPassReverse / http://localhost:81/ ProxyPreserveHost On ProxyRequests Off ProxyVia On ErrorLog ${APACHE_LOG_DIR}/error.log Custom

Magento 2 Set multi domain run using htaccess

Options +FollowSymLinks RewriteEngine on SetEnvIf Host [YourDomainName]* MAGE_RUN_CODE=[YourStoreCode] SetEnvIf Host [YourDomainName]* MAGE_RUN_TYPE=website

Xdebug configure in php.ini

First you need to go in /etc/apache2/php.ini dir. [xdebug] find this section or put this code under this xdebug section. Before doing this the xdebug should be installed in your local system. zend_extension="xdebug.so" xdebug.mode="debug" xdebug.start_with_request=trigger xdebug.client_port=9003 xdebug.log="/home/d45-bt/logs/xdebug.log" xdebug.start_with_request="yes"

Show current branch in CLI

You need to put this code in .bashrc file. You can get this file from /home/currentusename/.bashrc in your linux system. parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '

Magento 2 email print in browser

/vendor/magento/framework/Mail/Template/TransportBuilder.php Function --> prepareMessage put line 409 : echo " ";print_r($this->messageData);die;

Magento 2 code debug line by line

$result = ''; foreach( debug_backtrace() as $_stack) { $result .= ' ' . (isset($_stack['file']) ? $_stack['file'] : '') . ' ' . (isset($_stack['line']) ? $_stack['line'] : '') . ' ' . (isset($_stack['function']) ? $_stack['function'] : '') . ' '; } echo ' ' . 'file' . ' File Line Function ' . $result . ' ';die;

get category custom attribute value using sql

This query will get robot_index attribute value with list of categories.you can join multiple attribute as per your requirement. SELECT `c1`.* from catalog_category_entity_varchar AS c1 JOIN catalog_category_entity AS c2 ON c1.row_id = c2.entity_id JOIN eav_attribute AS e ON c1.attribute_id = e.attribute_id WHERE `attribute_code` = 'robot_index' AND `entity_type_id` = '3' AND c2.path LIKE '%1/1830/2355/%'

Magento 2 product varchar table eav attribute data update using sql query

UPDATE catalog_product_entity_varchar AS c1 JOIN catalog_product_entity AS c2 ON c1.row_id = c2.entity_id JOIN eav_attribute AS e ON c1.attribute_id = e.attribute_id SET c1.value = 'NOINDEX,NOFOLLOW' WHERE `attribute_code` = 'robot_index' AND `entity_type_id` = '4' AND c1.row_id = '86211' AND c1.store_id -- Row id u can use dynamic it's for only one record update. = '0'

Magento 2 update custom category attribute value

UPDATE catalog_category_entity_varchar AS c1 JOIN catalog_category_entity AS c2 ON c1.row_id = c2.entity_id JOIN eav_attribute AS e ON c1.attribute_id = e.attribute_id SET c1.value = 'NOINDEX,NOFOLLOW' --Here put your value WHERE `attribute_code` = 'robot_index' AND `entity_type_id` = '3' AND c2.path LIKE '%1/1830/2355/%' -- put atribute code and it's entity type id and category which you want to update in condition mention or you can modify it's condtion based on requirement.