Skip to content

Instantly share code, notes, and snippets.

View cagartner's full-sized avatar

Carlos Augusto Gartner cagartner

View GitHub Profile
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.
type: upstream
upstream: "mymagento:http"
"^/customer/account/forgotpassword/.*": { to: "http://{all}/", regexp: true }


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 /
Created November 9, 2021 13:39 — forked from rafaelstz/
Magento 2 Deploy script
#!/usr/bin/env bash
# production or developer
COMPOSER=$(which composer)
PHP=$(which php)
cagartner / WebsiteAndStoreCreator.php
Created September 9, 2021 20:12 — forked from jqjk/WebsiteAndStoreCreator.php
Magento 2 : Create Programmatically Website/Store/StoreGroup
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 /
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 / 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 \
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:
find pub/static/ -maxdepth 1 -type l -delete
cagartner /
Created July 1, 2021 17:08 — forked from mtbottens/
Easily update, import and sanitize magento2 cloud databases
function m2-update-database() {
# m2-update-database 'Magento Cloud Project Title' ''
# $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 / 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 /
Created May 31, 2021 14:57 — forked from rafaelstz/
Automated deploy using Magento 2 + Bitbucket Pipelines + Deployer

Use both files in your root folder and run:

curl -LO && 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