Skip to content

Instantly share code, notes, and snippets.

View roma-glushko's full-sized avatar
🦁
Hacking my way to the promised land

Roman Glushko roma-glushko

🦁
Hacking my way to the promised land
View GitHub Profile
@roma-glushko
roma-glushko / gist:399fd34235774ae24c35900471e2aa88
Last active April 14, 2016 11:51
Update product attribute of Magento 1.x
<?php
$allProductIds = Mage::getModel('catalog/product')->getCollection()->getAllIds();
$attributeCode = 'some_eav_attribute';
$attrData[$attributeCode] = 'some_value';
$storeId = 0;
Mage::getSingleton('catalog/resource_product_action')->updateAttributes($allProductIds, $attrData, $storeId);
<?php
namespace Vendor\Module\Test\Unit;
use Magento\Framework\App\ObjectManagerFactory as AppObjectManagerFactory;
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\App\Filesystem\DirectoryList;
@roma-glushko
roma-glushko / cache-warmup.sh
Created May 15, 2018 09:08 — forked from rogyar/cache-warmup.sh
Cache Warmup
wget -O - dev.mage2.com:1005/sitemap-1-1.xml | grep -E -o '<loc>.*</loc>' | sed -e 's/<loc>//g' -e 's/<\/loc>//g' > ~/sitemaps/mage2.txt
sudo siege -c100 -d5 -r1 -v -i -f ~/sitemaps/mage2.txt
@roma-glushko
roma-glushko / xdebug.bash
Created May 31, 2018 09:01
A bash script to toggle xdebug module
#!/bin/env bash
# Simple script to enable or disable the xdebug extension
case $1 in
on)
sudo sudo phpenmod xdebug
sudo service apache2 restart
echo "Xdebug is ON"
;;
@roma-glushko
roma-glushko / README.md
Created June 19, 2018 09:21 — forked from amenk/README.md
How To Apply a Magento 2 Patch to your project
  • Find the commit a GitHub
  • Add .patch to the URL
  • Require vaimo/composer-patches
  • Add an entry like the above, with path-removal-level 5, to the composer.json
@roma-glushko
roma-glushko / Vendor\Module\Plugin\Checkout\AddProductLabelPlugin
Created April 8, 2019 08:16
Usage of Magento\Framework\Stdlib\ArrayManager in Magento 2 while working with nested arrays
<?php
declare(strict_types=1);
namespace Vendor\Module\Plugin\Checkout;
use Magento\Checkout\Model\DefaultConfigProvider;
use Magento\Framework\Stdlib\ArrayManager;
class AddProductLabelPlugin
<?php
require __DIR__ . "/app/bootstrap.php";
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\ObjectManager\ConfigLoader;
use GuzzleHttp\Client;
use Magento\Framework\Stdlib\ArrayManager;
$bootstrap = Bootstrap::create(BP, $_SERVER);
@roma-glushko
roma-glushko / apache-config.conf
Last active June 18, 2020 12:58
Disable HTTP auth for specific IP on the Apache server which is behind Varnish proxy
<Directory /home/usr/sites/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AuthType Basic
AuthName "HTTP Auth"
AuthUserFile /etc/apache2/.htpasswd
SetEnvIf X-Forwarded-For ^1\.2\.3\.4 env_no_http_auth
<RequireAny>
@roma-glushko
roma-glushko / commands.js
Created June 22, 2020 09:56
Cypress - Magento2 loginAsCustomer() command
Cypress.Commands.add("loginAsCustomer", (username, password) => {
cy.request('/customer/account/login')
.its('body')
.then((body) => {
const $html = Cypress.$(body)
const formKey = $html.find('input[name="form_key"]').val()
cy.request({
method: 'POST',
url: '/customer/account/loginPost',
@roma-glushko
roma-glushko / patchy.sh
Created June 23, 2020 18:29
A simple interface around git commands that simplifies patch creation
#!/bin/bash
command=$1
path=$2
currentDir="`pwd`"
# display usage
# run commands one after the other using
[ $# -eq 0 ] && { echo -e "Usage: $0 command [path]"; exit 1; }
case $command in