Skip to content

Instantly share code, notes, and snippets.

View cagartner's full-sized avatar

Carlos Augusto Gartner cagartner

View GitHub Profile
@cagartner
cagartner / routes.yaml
Created March 31, 2022 16:15 — forked from LucasCalazans/routes.yaml
Magento Cloud - Redirect customer pages to home
# The routes of the project.
#
# Each route describes how an incoming URL is going to be processed.
"http://{all}/":
type: upstream
upstream: "mymagento:http"
redirects:
paths:
"^/customer/account/forgotpassword/.*": { to: "http://{all}/", regexp: true }

Usage

If you need to add more items to the CSP go to the line 36 and add more items inside the object.

Here I used as an example the font-src. In this case I just needed to add 1 more URL, so I added a string to the font-src key.

If you need to add more than 1 item you can use the value as an array. Also, if you need to add more keys, just add it to the object, like this:

updateContentSecurityPolicy(definitions, {
@cagartner
cagartner / magedeploy.sh
Created November 9, 2021 13:39 — forked from rafaelstz/magedeploy.sh
Magento 2 Deploy script
#!/usr/bin/env bash
LANGUAGES="en_US pt_BR"
# production or developer
ENVIRONMENT="production"
COMPOSER=$(which composer)
PHP=$(which php)
ROOT=$(pwd)
@cagartner
cagartner / WebsiteAndStoreCreator.php
Created September 9, 2021 20:12 — forked from jqjk/WebsiteAndStoreCreator.php
Magento 2 : Create Programmatically Website/Store/StoreGroup
<?php
namespace Example\Store\Setup;
use Magento\Framework\App\Area;
use Magento\Framework\App\State;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\Group;
use Magento\Store\Model\GroupFactory;
@cagartner
cagartner / magento-mysql8-fix.md
Last active September 9, 2021 17:14
Patch for fix Magento 2.4.3 and Mysql 8.0+, this error happens during the reindex process and happens because they can't create the temporary table.

Step 1

Install the composer patch modules:

composer require cweagans/composer-patches

Step 2

Copy the patch file content/name and add to your root magento in patchs/composer/mysql-temporary-tables-fix.patch

@cagartner
cagartner / m2.jmeter.cmd
Created July 6, 2021 14:17
Jmeter Magento Benchmark test
jmeter -n -t ./benchmark.jmx -j ./benchmark.log -l ./benchmark-results.jtl \
-Jhost={host} \
-Jbase_path=/ \
-Jadmin_path=admin \
-Jadmin_user={user} \
-Jadmin_password={pass} \
-JfrontendPoolUsers=90 \
-JadminPoolUsers=10
@cagartner
cagartner / cmd.cmd
Created July 2, 2021 18:14
Magento Cloud The path "/app/pub/static/deployed_version.txt" is not writable. error
# If you need to run bin/magento setup:static-content:deploy manually on
# Magento cloud but are getting The path "/app/pub/static/deployed_version.txt" is not writable. error
# just run the following command:
# @see: https://support.magento.com/hc/en-us/articles/360000338413-run-setup-static-content-deploy-deployed-version-txt-issue
find pub/static/ -maxdepth 1 -type l -delete
@cagartner
cagartner / notreallyimportant.sh
Created July 1, 2021 17:08 — forked from mtbottens/notreallyimportant.sh
Easily update, import and sanitize magento2 cloud databases
function m2-update-database() {
# USAGE
# m2-update-database 'Magento Cloud Project Title' 'http://project.dev/'
# $1 = Project Title
# $2 = Local URL
# Get the project ID by the project title
PROJECT_ID=$(magento-cloud project:list --title=$1 --pipe)
GIT_BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
@cagartner
cagartner / magento2-js-translate.js
Created June 8, 2021 14:16
Translate strings on Magento 2 on Javascript components
define (['jquery', 'mage/translate'], function ($, $t) {
return function () {
// 1. $.mage.__('<string>');
var string1 = $.mage.__('<string>');
// 2. Use the $.mage.__('') function when adding a string:
var string2 = $.mage.__('<string>');
// or
var string3 = $t('<string>');
@cagartner
cagartner / 1step-Install-Deployer-Magento2-BitbucketPipelines.md
Created May 31, 2021 14:57 — forked from rafaelstz/1step-Install-Deployer-Magento2-BitbucketPipelines.md
Automated deploy using Magento 2 + Bitbucket Pipelines + Deployer

Use both files in your root folder and run:

curl -LO https://deployer.org/deployer.phar && sudo mv deployer.phar /usr/local/bin/dep && sudo chmod +x /usr/local/bin/dep
composer require deployer/recipes --dev
composer require rafaelstz/deployer-magento2 dev-master --dev