Skip to content

Instantly share code, notes, and snippets.

@DominicWatts
DominicWatts / magento-2-logging-useful.md
Last active March 24, 2023 16:16
magento 2 loggging useful
public function getLogger() 
{
    $writer = new \Zend_Log_Writer_Stream(BP . '/var/log/pixie.debug.log');
    $logger = new \Zend_Log();
    $logger->addWriter($writer);
    return $logger;
}
@DominicWatts
DominicWatts / magento-2-custom-patch-via-composer
Last active July 14, 2023 12:12 — forked from XigenDominic/magento-2-custom-patch
Create magento 2 custom patch via composer
# Patcher
composer require cweagans/composer-patches
git add -f ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
# Edit file in vendor e.g. ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
mkdir ./patches
mkdir ./patches/composer
@XigenDominic
XigenDominic / magento-2-custom-patch
Created April 28, 2021 19:58
Create magento 2 custom patch
# Patcher
composer require cweagans/composer-patches
git add -f ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
# Edit file in vendor e.g. ./vendor/magento/module-catalog/Model/ResourceModel/Product.php
mkdir ./patches
mkdir ./patches/composer
@DominicWatts
DominicWatts / XML-php-simpleXML-addChild-addAttribute
Created March 12, 2021 00:26
XML php simpleXML addChild addAttribute
$xml = new SimpleXMLElement('<note></note>');
// Add a child element to the body element
$xml->addChild("date","2014-01-01");
// Add a child element after the last element inside note
$footer = $xml->addChild("footer","Some footer text");
// Add attribute to chosen element
$footer->addAttribute('type', 'stars');
// render
echo $xml->asXML();
@DominicWatts
DominicWatts / elasticsearch-cheatsheet
Last active December 3, 2021 13:05
Elasticsearch Cheatsheet
http://magento2.docker:9200/
http://magento2.docker:9200/_cluster/health
http://magento2.docker:9200/_cat/nodes?v&pretty
http://magento2.docker:9200/_cat/indices?v&pretty
curl -s -X GET "magento2.docker:9200/[indice]/_search?q=sku:ABC123"
curl -s -X GET "127.0.0.1:9200/[indice]/_search?q=sku:ABC123"
curl -s -X GET "magento2.docker:9200/_cat/indices?v&pretty"
curl -s -X GET "magento2.docker:9200/_cat/nodes?v&pretty"
@DominicWatts
DominicWatts / magento-2-cloud-docker
Last active May 24, 2024 13:18
Magento 2 Cloud Docker
# steps
curl -sL https://github.com/magento/magento-cloud/archive/2.4.0.tar.gz | tar xz
mv magento-cloud-2.4.0/{.,}* ./
rm magento-cloud-2.4.0 -rf
wget -qO- https://magento.mirror.hypernode.com/releases/magento-2.4.0.tar.gz | tar xfz -
composer require magento/ece-tools symfony/config:^4.4 symfony/console:^4.0 symfony/dependency-injection:^4.3 symfony/process:^4.1 symfony/serializer:^4.0 symfony/yaml:^4.0 -v
./vendor/bin/ece-docker build:compose --mode="developer" --php="7.3" --nginx="1.19" --expose-db-port="3306" --no-varnish
docker-compose up -d
./bin/magento-docker
@DominicWatts
DominicWatts / Check-IP-on-server
Created January 15, 2021 00:00
Check IP on server
Check IP address
curl
curl -s checkip.amazonaws.com
curl -s ipv4.icanhazip.com
curl -s http://ipv4.icanhazip.com
curl -s http://ipv6.icanhazip.com
curl -s https://checkip.amazonaws.com
@DominicWatts
DominicWatts / kill-magento-processes
Last active May 22, 2023 13:44
kill-magento-processes
kill -9 $(ps -aux | grep 'bin/magento' | grep -v grep | awk '{print $2}')
kill -9 $(ps -aux | grep 'bin/magento cron:run' | grep -v grep | awk '{print $2}')
@DominicWatts
DominicWatts / debian install composer specific version
Last active December 17, 2022 13:33
debian install composer specific version
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --version=1.10.26 --install-dir=/usr/bin --filename=composer
php -r "unlink('composer-setup.php');"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --version=2.4.4 --install-dir=/usr/bin --filename=composer2
php -r "unlink('composer-setup.php');"
composer --version
@DominicWatts
DominicWatts / Linux-remove-session-files-from-folder-over-certain-age.md
Last active March 24, 2023 16:06
Linux remove session files from folder over certain age

remove session files

find ~/public_html/var/session -mtime +30 -type f -exec rm {} \;

further syntax

find all files older than 30 days recursively in current directory

find ./ -type f -mtime +30