Skip to content

Instantly share code, notes, and snippets.

View andriantilica's full-sized avatar

Andrian Țîlica andriantilica

View GitHub Profile
@andriantilica
andriantilica / README.md
Last active March 6, 2025 08:09
[M2 - Validation tools] How to check files for errors through different tools? #CLI #Magento2 #SSH

PHPCS validation:

vendor/bin/phpcs --standard=Magento2 [path/to/folder]

PHPMD validation:

@andriantilica
andriantilica / Success.php
Created July 2, 2024 09:27
[M2 - Stop redirecting Success Page] Stop redirecting success page for testing or styling #Magento2
/*
* @path vendor/magento/module-checkout/Controller/Onepage/Success.php
* @function execute()
*/
...
/**
* Order success action
*
@andriantilica
andriantilica / Readme.md
Last active May 30, 2025 08:14
[WP - Change/Update Wordpress URLs] How to change Wordpress URLs in the database when site is moved to a new host #Wordpress #Database #CLI #MySQL #SSH

After migrating a Wordpress site to a new host, you would need to change the URLs in the various MySQL database tables.

  1. Run the following MySQL queries in the phpmyadmin:
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.oldurl', 'http://www.newurl');
@andriantilica
andriantilica / Readme.md
Last active January 30, 2024 15:02
[M2 - Add custom Javascript in Magento 2] How to add custom Javascript in Magento 2 #Magento2 #JS

There are many ways to add custom JS in Magento 2.

Magento 2 uses RequireJS and Knockout.js libraries to solve the page speed and manage the JS dependency.

The custom JS files should be placed in the following locations:

- view/[area]/web/js/
- [theme]/[module]/web/js/
- [theme]/web/js/
@andriantilica
andriantilica / index.html
Created January 30, 2024 11:03
[CSS - Truncate multi-line text] How to truncate multiple lines of text with CSS #CSS
...
<div class="container">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc lacinia et elit quis vehicula. Praesent fermentum finibus felis, vitae tristique lorem fringilla nec.</p>
</div>
...
@andriantilica
andriantilica / README.md
Last active January 30, 2024 10:53
[M2 - Install module via composer artifact] How to install a module via composer artifact #CLI #Magento2 #SSH
  1. Create a new folder into the Magento root directory (e.g. "/repo")
  2. Create a new folder into the newly created directory with the name of the module vendor (e.g. "/repo/[vendor]")
  3. Upload the module archive into the "/repo/[vendor]" directory
  4. Run the following commands in the terminal:
composer config repositories.[vendor] artifact repo/[vendor]/
composer require ...
@andriantilica
andriantilica / SqlVersionProvider.php
Last active January 30, 2024 10:48
[M2 - Error: Current version of RDBMS is not supported] Fix for the following error: Current version of RDBMS is not supported. Used Version: 10.6.9-MariaDB-1:10.6.9+maria~deb11. Supported versions: MySQL-8, MySQL-5.7, MariaDB-(10.2-10.4) #Magento2
/*
* $path vendor/magento/framework/DB/Adapter/SqlVersionProvider.php
* $function getVersionString(string $resource)
*/
...
$pattern = sprintf('/(%s)/', implode('|', $this->supportedVersionPatterns));
- $sqlVersionOutput = $this->fetchSqlVersion($resource);
+ $sqlVersionOutput = '10.2.37-MariaDB';
preg_match($pattern, $sqlVersionOutput, $match);
@andriantilica
andriantilica / README.md
Last active January 30, 2024 10:44
[GIT - Delete branch] How to delete a branch locally and/or remotely #GIT #CLI #SSH

Delete a branch locally:

git branch -d [branch-name]

Delete a branch remotely:

git push origin --delete [branch-name]
@andriantilica
andriantilica / README.md
Last active January 30, 2024 10:39
[CLI - Find recently modified files] Find files that have been modified recently through command line interface #CLI #Linux #SSH

Run the following command in the terminal:

find -type f -mtime -[count_of_days] -ls
@andriantilica
andriantilica / README.md
Last active January 30, 2024 10:28
[DB - Remove DEFINER] How to remove DEFINER statements from MySQL dump #CLI #SSH #Database #MySQL

Sometimes when you try to run a database import, you encounter an error like the following:

ERROR 1227 (42000) at line XXXX: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

This means that there are DEFINER statements in the database dump file.

The easiest way to remove them is to run the following command: