Skip to content

Instantly share code, notes, and snippets.

View rafaelstz's full-sized avatar
👨‍🔬

Rafael Corrêa Gomes rafaelstz

👨‍🔬
View GitHub Profile
@rafaelstz
rafaelstz / 1step-Install-Deployer-Magento2-BitbucketPipelines.md
Last active April 4, 2024 18:52
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
@rafaelstz
rafaelstz / env.php
Last active January 16, 2018 21:05
Magento 2 Env.php configuration file by Platform.sh
<?php
return array (
'backend' =>
array (
'frontName' => 'admin',
),
'crypt' =>
array (
'key' => '2c4f7c9688dc808fe2e23935f7eeb255',
),
@rafaelstz
rafaelstz / SQL_Orders_Sales_Customers_Report.sql
Created November 6, 2017 19:17
Magento 1 - SQL to get the each customer sales and orders total
# Get the each customer sales and orders total
SELECT
-- Round to two decimal places and prepend with $
CONCAT('$', FORMAT(SUM(sales_flat_order.`grand_total`), 2)) AS 'Lifetime Sales',
COUNT(sales_flat_order.entity_id) AS 'Orders',
customer_entity.email AS 'Email',
MAX(sales_flat_order.created_at) AS 'Most Recent Order Date'
FROM `customer_entity`
LEFT JOIN sales_flat_order ON customer_entity.entity_id = sales_flat_order.customer_id
@rafaelstz
rafaelstz / auth.json
Last active November 10, 2017 15:58
Magento2 Auth.json
{"http-basic": {"repo.magento.com": {"username":"4663362708601ec0c460a36edf59c70d","password":"f30b05a56f3b06d8b134ef93da73be5e"}}}
@rafaelstz
rafaelstz / magento2-truncate.sql
Created August 29, 2017 14:40
Magento 2 truncate customers, products, reviews and orders table
SET FOREIGN_KEY_CHECKS = 0;
-- Truncate order tables
TRUNCATE TABLE `gift_message`;
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
@rafaelstz
rafaelstz / Robots.txt
Last active September 23, 2020 14:53
Robots.txt Magento 2
# Allow Full Access
User-agent:*
Disallow:
# Disallow Access to All Folders
User-agent:*
Disallow: /
@rafaelstz
rafaelstz / Magento2-multistore-locally.php
Last active May 21, 2019 19:10
Magento 2 Multistore to test
$params = $_SERVER;
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'website_code';
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_TYPE] = 'website';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
@rafaelstz
rafaelstz / Magento2-API-OAuth-based_authentication.php
Last active September 8, 2023 06:15
Sample files to use Magento 2 REST and SOAP API. Using Token-based authentication and OAuth-based authentication method.
<?php
function sign($method, $url, $data, $consumerSecret, $tokenSecret)
{
$url = urlEncodeAsZend($url);
$data = urlEncodeAsZend(http_build_query($data, '', '&'));
$data = implode('&', [$method, $url, $data]);
$secret = implode('&', [$consumerSecret, $tokenSecret]);
@rafaelstz
rafaelstz / magento1-rest.php
Last active December 9, 2019 02:37
Magento 1 - Sample PHP script to connect via API REST
<?php
// Created by Rafael Corrêa Gomes
// Reference http://devdocs.magento.com/guides/m1x/api/rest/introduction.html#RESTAPIIntroduction-RESTResources
// Custom Resource
$apiResources = "products?limit=2";
// Custom Values
$isAdminUser = true;
$adminUrl = "admin";
@rafaelstz
rafaelstz / upgrade-magento2-composer-cli.md
Last active October 25, 2016 15:59
Upgrade Magento 2

Please follow the same order and use the commands listed below:

composer require magento/product-community-edition 2.1.2 –no-update

Note: As 2.1.2 is the latest version, these numbers can be changed accordingly.

composer update